Commit Graph

8053 Commits

Author SHA1 Message Date
Derek Collison
0bd4763584 Revert lock guard
Signed-off-by: Derek Collison <derek@nats.io>
2023-08-31 08:58:22 -07:00
Derek Collison
fbaed8f220 Merge branch 'main' into dev 2023-08-31 08:29:30 -07:00
Derek Collison
887a4ae692 [FIXED] Unlock needed to be guarded, could deadlock filestore (#4461)
Needed to check guard for unlock here.

Signed-off-by: Derek Collison <derek@nats.io>
2023-08-31 08:24:08 -07:00
Derek Collison
2b677c231a Unlock needed to be guarded
Signed-off-by: Derek Collison <derek@nats.io>
2023-08-31 08:16:47 -07:00
Derek Collison
9e26574707 Make sure we unlock only if we did not acquire
Signed-off-by: Derek Collison <derek@nats.io>
2023-08-31 08:09:16 -07:00
Derek Collison
b25b4f2cff Fix lock issue in filestore (#4458)
This should hopefully fix a panic on unlock of unlocked mutex in the
file store.

Signed-off-by: Neil Twigg <neil@nats.io>
2023-08-31 07:59:02 -07:00
Neil Twigg
af2ff3d17d Fix lock issue in filestore
Signed-off-by: Neil Twigg <neil@nats.io>
2023-08-31 15:16:15 +01:00
Waldemar Quevedo
ee4c04dec4 Run tests using Go 1.21 (#4433)
Flips the order to test with ~~Go 1.20~~ Go 1.21 instead of Go 1.19
2023-08-30 17:02:38 -07:00
Derek Collison
b9b284dffa Updates to the way meta indexing is handled for filestore. (#4450)
Historically we kept indexing information, either by sequence or by
subject, as a per msg block operation. These were the "*.idx" and
"*.fss" indexing files. When streams became very large this could have
an impact on recovery time. Also, for encryption the fast path for
determining if the indexing was current would require loading and
decrypting the complete block.

This design moves to a more traditional WAL and snapshot approach. The
snapshots for the complete stream, including summary information, global
per subject information maps (PSIM) and per msg block details including
summary and dmap, are processed asynchronously. The snapshot includes
the msg block and has for the last record hash that was considered in
the snapshot. On recovery the snapshot is read and processed and any
additional records past the point of the snapshot itself are processed.
To this end, any non-system removal of a message has to be expressed as
a delete tombstone that is always added the the fs.lmb file. These are
processed on recovery and our indexing layer knows to skip them.

Changing to this method drastically improves startup and recovery times,
and has simplified the code. Some normal performance benefits have been
seen as well.

Signed-off-by: Derek Collison <derek@nats.io>
2023-08-30 16:49:37 -07:00
Waldemar Quevedo
4eedcecf78 Run tests using Go 1.21
Signed-off-by: Waldemar Quevedo <wally@nats.io>
2023-08-30 16:24:08 -07:00
Derek Collison
2e1392a234 [FIXED] potential message duplication from sources when downgrading back from 2.10 (#4454)
- [X] Changes squashed to a single commit (described
[here](http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html))
 - [ ] Build is green in Travis CI
- [X] You have certified that the contribution is your original work and
that you license the work to the project under the [Apache 2
license](https://github.com/nats-io/nats-server/blob/main/LICENSE)

2.10 adds a couple space separated fields to the sourcing message header
from 2 to 4 but the current 2.9 code is too strict of checking the
number of fields is exactly 2 rather than at least 2
2023-08-30 16:21:59 -07:00
Derek Collison
415bbb2ee1 [FIXED] Make sure order correct (#4455)
Signed-off-by: Derek Collison <derek@nats.io>
2023-08-30 16:17:12 -07:00
Derek Collison
abae24086c Make sure order correct
Signed-off-by: Derek Collison <derek@nats.io>
2023-08-30 16:13:56 -07:00
Derek Collison
adef8281a2 Updates to the way meta indexing is handled for filestore.
Historically we kept indexing information, either by sequence or by subject, as a per msg block operation. These were the "*.idx" and "*.fss" indexing files. When streams became very large this could have an impact on recovery time. Also, for encryption the fast path for determining if the indexing was current would require loading and decrypting the complete block.

This design moves to a more traditional WAL and snapshot approach. The snapshots for the complete stream, including sumary information, global per subject information maps (PSIM) and per msg block details including summary and dmap, are processed asynchronously. The snapshot includes the msh block and has for the last record considered in the snapshot. On recovery the snapshot is read and processed and any additional records past the point of the snapshot itself are processed. To this end, any removal of a message has to be expressed as a delete tombstone that is always added the the fs.lmb file. These are processed on recovery and our indexing layer knows to skip them.

Changing to this method drastically improves startup and recovery times, and has simplified the code. Some normal performance benefits have been seen as well.

Signed-off-by: Derek Collison <derek@nats.io>
2023-08-30 16:12:45 -07:00
Derek Collison
1de649a690 Remove OCSP debug log on reload (#4453)
When reloading TLS we would always be logging the attempt to plug OCSP:

```
[42801] 2023/08/30 14:52:33.766638 [INF] Reloaded: authorization users
[42801] 2023/08/30 14:52:33.766648 [INF] Reloaded: accounts
[42801] 2023/08/30 14:52:33.766652 [INF] Reloaded: tls = enabled
[42801] 2023/08/30 14:52:33.766756 [DBG] Plugging TLS OCSP peer for [Client]
[42801] 2023/08/30 14:52:33.766763 [INF] Reloaded server configuration
```
2023-08-30 16:05:24 -07:00
Derek Collison
3be9e97760 Bump to 2.9.22-RC.2
Signed-off-by: Derek Collison <derek@nats.io>
2023-08-30 15:32:31 -07:00
Derek Collison
774987cd99 [IMPROVED] Allow 2.10 tombstones to be skipped and allow us to recover on downgrade (#4452)
Also fixed small bug that could set bad first sequence for subject
tracking info.

Signed-off-by: Derek Collison <derek@nats.io>
2023-08-30 15:31:51 -07:00
Jean-Noël Moyne
003daf3db8 Fixes possible message duplication in sourcing streams if upgrading to 2.10 and then back down to 2.9
2.10 adds a couple space separated fields to the sourcing message header from 2 to 4 but the current 2.9 code is too strict of checking the number of fields is exactly 2 rather than at least 2

Signed-off-by: Jean-Noël Moyne <jnmoyne@gmail.com>
2023-08-30 15:27:26 -07:00
Waldemar Quevedo
4109e420d2 Remove ocsp debug log on reload
Signed-off-by: Waldemar Quevedo <wally@nats.io>
2023-08-30 14:54:30 -07:00
Derek Collison
8841432d03 Allow 2.10 tombstones to be skipped and allow us to recover on downgrade from 2.10 to 2.9.
Also fixed small bug that could set bad first seq.

Signed-off-by: Derek Collison <derek@nats.io>
2023-08-30 14:38:41 -07:00
Neil
ce08d452d4 Tweak TestJetStreamClusterMetaSnapshotsMultiChange and TestJetStreamClusterStreamUpdateSyncBug (#4449)
This should resolve a couple flakes.

Signed-off-by: Neil Twigg <neil@nats.io>
2023-08-30 17:35:09 +01:00
Neil Twigg
8d194e8bf9 Tweak TestJetStreamClusterMetaSnapshotsMultiChange and TestJetStreamClusterStreamUpdateSyncBug
Signed-off-by: Neil Twigg <neil@nats.io>
2023-08-30 15:49:50 +01:00
Ginger Collison
d6e7106eee Update Slack invite URL for Slack badge (#4448)
This badge was using an old expired invite URL for NATS Slack. Updating
to the general slack.nats.io URL for invites
2023-08-30 09:35:31 -05:00
Ginger Collison
6ab7f0c0a8 Update Slack invite URL for badges
This badge was using an old expired invite URL for NATS Slack. Updating to the general slack.nats.io URL for invites
2023-08-30 09:30:50 -05:00
Neil
bd23469ebe Add benchmark for request-reply workload over encrypted connection (#4399)
- [x] Tests added
- [x] Branch rebased on top of current main (`git pull --rebase origin
main`)
- [x] Changes squashed to a single commit (described
[here](http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html))
- [x] You have certified that the contribution is your original work and
that you license the work to the project under the [Apache 2
license](https://github.com/nats-io/nats-server/blob/main/LICENSE)

### Changes proposed in this pull request:
- Creates new TLS certificates and private keys for testing with various
key types
    - RSA (1024, 2048, 4096)
    - ED25519
- Adds a benchmark that measures NATS Core request-reply performance
over TLS-encrypted connections
2023-08-30 10:10:25 +01:00
Derek Collison
7f884062d1 Merge branch 'main' into dev 2023-08-29 20:01:26 -07:00
Derek Collison
1f89e7ef86 [FIXED] Fix on rebuild first when rebuild results in empty block (#4447)
Pulled from fs-meta branch.

Signed-off-by: Derek Collison <derek@nats.io>
2023-08-29 20:00:45 -07:00
Derek Collison
e4a1b81d30 Fix on rebuild first when rebuild results in empty block (from dev branch)
Signed-off-by: Derek Collison <derek@nats.io>
2023-08-29 19:50:33 -07:00
Derek Collison
acfb593ed5 Merge branch 'main' into dev 2023-08-29 16:48:04 -07:00
Derek Collison
abf5e0bc0f [FIXED] Max msgs per subject config update to lower values (#4446)
We were not recalculating first correctly since we were not considering
seq < mb.first.seq.

Signed-off-by: Derek Collison <derek@nats.io>

Resolves #4445
2023-08-29 16:47:05 -07:00
Derek Collison
8865c2a703 Fix for update to max msgs per where recalculating first was not checking for seq < mb.first.seq
Signed-off-by: Derek Collison <derek@nats.io>
2023-08-29 16:02:52 -07:00
Derek Collison
a64f7a0d18 MQTT: Cleanup code regarding retain flag and add test (#4443)
As per specification MQTT-3.3.1-8, we are now setting the RETAIN flag
when delivering to new subscriptions and clear the flag in all other
conditions.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2023-08-29 15:58:11 -07:00
Derek Collison
d61466c63f Fixed a route pooling flapper (#4444)
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2023-08-29 15:57:07 -07:00
Ivan Kozlovic
d6bc12d18b Since the server is connected to 2 servers and the pool size is 5
the limit of 10 was too small.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2023-08-29 15:18:56 -06:00
reubenninan
8c10cb3591 Add benchmark for req-reply with various TLS schemes 2023-08-29 17:00:28 -04:00
Ivan Kozlovic
0d74453919 Fixed a route pooling flapper
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2023-08-29 14:20:36 -06:00
Ivan Kozlovic
8bd68b550d [FIXED] MQTT: Retain flag did not always have the correct value.
As per specification MQTT-3.3.1-8, we are now setting the RETAIN
flag when delivering to new subscriptions and clear the flag in
all other conditions.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2023-08-29 12:39:59 -06:00
Lev
dbd2cb61da [FIXED] MQTT: Removed the use of tkDomain from retained msg subjects (#4440)
(Partially?) addresses
https://github.com/nats-io/nats-server/pull/4349#discussion_r1306576048

@kozlovic @neilalexander I did not remove the use of `domainTk` in the
session subject since it seems to have significance to it; removing it
failed `TestMQTTSessionsDifferentDomains` and I did not understand the
specifics of the issue enough. Please let me know your thoughts.
2023-08-29 11:13:02 -07:00
Lev
bd93f087d4 [Added] MQTT: QoS2 support (#4349)
@derekcollison @neilalexander @kozlovic 

#### Summary

Adds MQTT QoS2 support

 - [X] Resolves https://github.com/nats-io/nats-server/issues/3244
 - [X] Tests added
 - [x] Build is green in Travis CI
2023-08-29 11:09:49 -07:00
Waldemar Quevedo
63f81ae0d8 Fix resetting TLS name from solicited remotes (#4442)
In +Go 1.20, the `x509.HostnameError` changed to be wrapped in a
[tls.CertificateVerificationError](https://pkg.go.dev/crypto/tls#CertificateVerificationError)
so sometimes the name would not be reset causing tests to be extra
flaky.
2023-08-28 20:04:49 -07:00
Lev Brouk
ad2e9d7b8d MQTT QoS2 support 2023-08-28 11:52:01 -07:00
Waldemar Quevedo
d366027bbf Fix resetting TLS name from solicited remotes
In +Go 1.20, the x509.HostnameError changed to be wrapped in a
tls.CertificateVerificationError so sometimes the name would not
be reset causing tests to be extra flaky.

Signed-off-by: Waldemar Quevedo <wally@nats.io>
2023-08-28 10:09:55 -07:00
Lev Brouk
b9ea85b5d0 MQTT: Removed the use of tkDomain from retained msg subjects 2023-08-28 04:13:50 -07:00
Derek Collison
f50b772a14 Merge branch 'main' into dev 2023-08-27 14:20:45 -07:00
Derek Collison
f9a2efdc5c [FIXED] Expire on recover could not update global per subject map (#4439)
When expiring complete blocks on recover make sure to update global
subject index psim.

Signed-off-by: Derek Collison <derek@nats.io>
2023-08-27 14:20:10 -07:00
Derek Collison
b66a7f6e9f When expiring complete blocks make sure to update global subject index psim.
Signed-off-by: Derek Collison <derek@nats.io>
2023-08-27 12:03:44 -07:00
Derek Collison
70bbf5081a Merge branch 'main' into dev
Signed-off-by: Derek Collison <derek@nats.io>
2023-08-26 12:53:07 -07:00
Derek Collison
5b18e80d42 Added CORS support for the monitoring server (#4423)
- [x] Link to issue, e.g. `Resolves #NNN`
 - [ ] Documentation added (if applicable)
 - [x] Tests added
- [ ] Branch rebased on top of current main (`git pull --rebase origin
main`)
- [ ] Changes squashed to a single commit (described
[here](http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html))
 - [ ] Build is green in Travis CI
- [x] You have certified that the contribution is your original work and
that you license the work to the project under the [Apache 2
license](https://github.com/nats-io/nats-server/blob/main/LICENSE)

Resolves #4422 

### Changes proposed in this pull request:

- Added `Access-Control-Allow-Origin` header to allow CORS requests for
the monitoring server
- Added a check in the tests for the header when the `Content-Type` is
`application/json`
2023-08-25 14:49:09 -07:00
Derek Collison
0d135d4161 Bump to 2.9.22-RC.1
Signed-off-by: Derek Collison <derek@nats.io>
2023-08-25 11:04:37 -07:00
Derek Collison
f1bf4127c5 Merge branch 'main' into dev 2023-08-25 11:03:54 -07:00