Commit Graph

8034 Commits

Author SHA1 Message Date
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
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
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
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
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
Derek Collison
e19f883120 [FIX] PurgeEx with keep and deleted bug (#4431)
Fix for purge with keep bug with user deletes and improved search for
large number of blocks.

Signed-off-by: Derek Collison <derek@nats.io>
2023-08-25 11:03:32 -07:00
Derek Collison
e637f3793a [FIXED] NRG layer could loop if leader asked for an item and we have none. (#4432)
If a leader is asked for an item and we have no items left, make sure to
also step-down.

Signed-off-by: Derek Collison <derek@nats.io>
2023-08-25 11:03:20 -07:00
Derek Collison
e5625b9d9b If a leader is asked for an item and we have no items left, make sure to also step-down.
Signed-off-by: Derek Collison <derek@nats.io>
2023-08-25 10:20:07 -07:00
Derek Collison
22ed97c6c9 Fix for purge with keep bug and improved search for large number of blocks.
Signed-off-by: Derek Collison <derek@nats.io>
2023-08-25 08:59:47 -07:00
Waldemar Quevedo
1417ca6671 Fix shutdown deadlock in TestJetStreamClusterMemLeaderRestart (#4430)
While shutting down a server an error during purge from a memory stream
would cause a deadlock sometimes, this would sometimes show up in the
`TestJetStreamClusterMemLeaderRestart` while tearing down the cluster.

This was introduced in
4d8d01949b
so only relates to v2.10.
2023-08-25 07:41:23 -07:00
Tomasz Pietrek
6df4403913 Fix flaky TestJetStreamClusterConsumerFollowerStoreStateAckFloorBug
Signed-off-by: Tomasz Pietrek <tomasz@nats.io>
2023-08-25 15:31:20 +02:00
Waldemar Quevedo
f8b6728d3a Fix shutdown deadlock in TestJetStreamClusterMemLeaderRestart
While shutting down a server an error during purge from a memory stream
would cause a deadlock sometimes, this would sometimes show up in the
TestJetStreamClusterMemLeaderRestart while tearing down the cluster.

Signed-off-by: Waldemar Quevedo <wally@nats.io>
2023-08-25 01:23:24 -07:00
Derek Collison
fd50bc2918 Merge branch 'main' into dev 2023-08-24 21:10:22 -07:00
Derek Collison
5a497272c3 [FIXED] Make sure to reset election timer on catching up (#4428)
Thanks to @yuzhou-nj for the catch and fix.

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

Resolves #4363
2023-08-24 21:07:57 -07:00
Derek Collison
2669f77190 Make sure to reset election timer on catching up
Signed-off-by: Derek Collison <derek@nats.io>
2023-08-24 19:58:08 -07:00
Derek Collison
346c22788e Merge branch 'main' into dev 2023-08-24 16:20:46 -07:00
Derek Collison
c9b5b329a4 [FIXED] Consumer ack pending > max ack pending on restart or leader change (#4427)
When a consumer reached a max delivered condition, we did not properly
synchronize the state such that on a restore or leader switch the ack
pending could jump and be higher than max ack pending and block the
consumer.

This propagates a delivered update and we updated the store state engine
to do the right thing when the condition is reached.

Signed-off-by: Derek Collison <derek@nats.io>
2023-08-24 16:19:39 -07:00
Derek Collison
48bf7ba151 When a consumer reached a max delivered condition, we did not properly synchronize the state such that on a restore or leader switch the ack pending could jump and be higher than max ack pending and block the consumer.
This propagates a delivered update and we updated the store state engine to do the right thing when the condition is reached.

Signed-off-by: Derek Collison <derek@nats.io>
2023-08-24 16:00:27 -07:00
Pierre Mdawar
e5836fc98d Added CORS support for the monitoring server 2023-08-23 16:47:30 +03:00
Derek Collison
a04a3154af Bump to 2.10.0-beta.52
Signed-off-by: Derek Collison <derek@nats.io>
2023-08-22 20:05:45 -07:00
Derek Collison
8544cb7adf Merge branch 'main' into dev
Signed-off-by: Derek Collison <derek@nats.io>
2023-08-22 20:04:59 -07:00
Derek Collison
5a926f1911 [FIXED] A peer-remove of an R1 could brick the stream. (#4420)
We should not remove a peer from a stream when we can not find a
replacement unless R>1.

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

Resolves #4396
2023-08-22 20:01:27 -07:00
Derek Collison
ddb7f9f9d5 Fix for a peer-remove of an R1 that would brick the stream.
Signed-off-by: Derek Collison <derek@nats.io>
2023-08-22 17:45:19 -07:00