Commit Graph

241 Commits

Author SHA1 Message Date
Derek Collison
ca12a11be3 There were situations where invalid subjects could be assigned to streams.
This will patch them on the fly during recovery. Specifically subjects with leading or trailing spaces and mirror streams with any subjects at all.

Signed-off-by: Derek Collison <derek@nats.io>
2021-12-01 14:00:23 -07:00
Ivan Kozlovic
1cf8b40304 Merge pull request #2719 from nats-io/js_mem_corruption
[FIXED] Corrupted headers receiving from consumer with meta-only
2021-12-01 13:42:47 -07:00
Ivan Kozlovic
9f30bf00e0 [FIXED] Corrupted headers receiving from consumer with meta-only
When a consumer is configured with "meta-only" option, and the
stream was backed by a memory store, a memory corruption could
happen causing the application to receive corrupted headers.

Also replaced most of usage of `append(a[:0:0], a...)` to make
copies. This was based on this wiki:
https://github.com/go101/go101/wiki/How-to-efficiently-clone-a-slice%3F

But since Go 1.15, it is actually faster to call make+copy instead.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2021-12-01 10:50:15 -07:00
R.I.Pienaar
c025d25899 prevent stream update to add subjects to mirrors
Signed-off-by: R.I.Pienaar <rip@devco.net>
2021-12-01 18:12:49 +01:00
R.I.Pienaar
cf097bfab4 Merge pull request #2717 from ripienaar/stream_valid_subjects
Stream valid subjects
2021-12-01 17:43:41 +01:00
R.I.Pienaar
4f1bfa969f ensure streams have only valid interest subjects
Signed-off-by: R.I.Pienaar <rip@devco.net>
2021-12-01 17:03:28 +01:00
Derek Collison
529095be40 [FIXED #2708] Removing a source depending on timing could cause a server panic.
Signed-off-by: Derek Collison <derek@nats.io>
2021-11-29 12:48:08 -08:00
Derek Collison
e65f3d4a30 [FIXED #2706] - Only utilize full state with deleted details when really needed. Otherwise fast state will suffice.
Signed-off-by: Derek Collison <derek@nats.io>
2021-11-29 10:50:28 -08:00
Derek Collison
49c5c873ca Better handling of stream mismatch scenarios.
1. When a snapshot did not yield actionable data, we were not setting new last sequence if we have to readjust based on snapshot. This could lead to spinning on stream reset for followers.
2. When a stream has lots of failures by design, like KV abstraction, if we cleared the clfs state we would endlessly spin trying to reset the stream.

Signed-off-by: Derek Collison <derek@nats.io>
2021-11-18 14:00:41 -08:00
Derek Collison
ae999aabe9 Merge pull request #2669 from nats-io/fix-2658
[FIXED] Duplicate stream create returned wrong response type #2658
2021-11-02 15:39:30 -07:00
Derek Collison
c78d700e90 Fix for #2658
Signed-off-by: Derek Collison <derek@nats.io>
2021-11-02 15:23:15 -07:00
Derek Collison
1af3ab1b4e Fix for #2666
When encountering errors for sequence mismatches that were benign we were returning an error and not processing the rest of the entries.
This would lead to more severe sequence mismatches later on that would cause stream resets.

Also added code to deal with server restarts and the clfs fixup states which should have been reset properly.

Signed-off-by: Derek Collison <derek@nats.io>
2021-11-02 14:38:22 -07:00
Derek Collison
0f7cdb00e8 Fix for #2633
Signed-off-by: Derek Collison <derek@nats.io>
2021-10-27 15:07:59 -07:00
Derek Collison
d4b0b38a8f Fix for #2642
There was a bug that would erase the sync subject for upper level catchup for streams.
Raft layer repair was ok but if that was compacted it gets kicked up to the upper layers which would fail.
Users would see "Catchup stalled" messages repeatedly and consumers that had their leaders attached to that replica would also stop working.

Changes were put in to repair the corrupt state after the fact as well, regardless of presence of fix.

Signed-off-by: Derek Collison <derek@nats.io>
2021-10-26 20:09:00 -07:00
Derek Collison
678469b40b Fix for #2644
Signed-off-by: Derek Collison <derek@nats.io>
2021-10-25 13:12:37 -07:00
Ivan Kozlovic
cd23c70ad8 Fixed data race in setSourceConsumer
Call to mset.unsubscribe() need to use the version that uses
locking when invoked from the subscription callback or from the
go routine when the 10secs have elapsed.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2021-10-12 14:25:46 -06:00
R.I.Pienaar
e73cddc2de error when a stream requesting rollups deny purge
Signed-off-by: R.I.Pienaar <rip@devco.net>
2021-10-07 14:07:10 +02:00
Derek Collison
3f12216fcc Merge pull request #2595 from nats-io/stream-perms
In addition to sealed we add in other stream perms to control purge, msg deletes and rollups.
2021-10-06 07:55:08 -07:00
Derek Collison
1b7e184c9e Update rollup based on feedback
Signed-off-by: Derek Collison <derek@nats.io>
2021-10-06 07:18:46 -07:00
Derek Collison
58e5c7c681 Allow consumers to request only headers to be delivered
Signed-off-by: Derek Collison <derek@nats.io>
2021-10-05 18:54:52 -07:00
Derek Collison
aff0f62106 In addition to sealed we add in other stream perms to control purge, msg deletes and rollups.
Signed-off-by: Derek Collison <derek@nats.io>
2021-10-05 17:43:24 -07:00
Derek Collison
df2147bc7c Fix for rollups and filtered purge
Signed-off-by: Derek Collison <derek@nats.io>
2021-10-04 10:01:36 -07:00
Derek Collison
c062190b0a Rollup functionality.
Messages published with the rollup header will place the new message onto the stream and purge all others based on subject, or the complete stream.

Signed-off-by: Derek Collison <derek@nats.io>
2021-09-29 18:59:21 -07:00
Derek Collison
5fc2cc5754 Allow streams to be sealed through a stream update.
Sealed streams can not accept new messages, allow you to delete or purge messages, or have messages expire due to age.
Sealed stream can not be unsealed through an update.

Signed-off-by: Derek Collison <derek@nats.io>
2021-09-29 15:25:38 -07:00
Derek Collison
ebb24006c2 Direct consumers used for mirroring should not be affected by max consumer limits
Signed-off-by: Derek Collison <derek@nats.io>
2021-09-22 15:01:51 -07:00
Derek Collison
eab45b404a Fix for deadlock with stream mirrors or sources where origin is interest or workqueue policy.
Signed-off-by: Derek Collison <derek@nats.io>
2021-09-22 10:59:02 -07:00
R.I.Pienaar
3be0b23a3e Merge pull request #2546 from ripienaar/negative_dupe_window_protection
protect against negative dupe window via negative max age
2021-09-20 18:09:19 +02:00
R.I.Pienaar
34b5a11e20 protect against negative dupe window via negative max age
Signed-off-by: R.I.Pienaar <rip@devco.net>
2021-09-20 17:34:48 +02:00
Derek Collison
c764da328c Make sure to set last sequence on recovery, check for ddloaded on last msg id
Signed-off-by: Derek Collison <derek@nats.io>
2021-09-20 07:11:15 -07:00
Derek Collison
cfb69bbd1f Only rebuild dedupe state as needed versus always on startup.
Was penalizing large non-dedupe streams on startup.

Signed-off-by: Derek Collison <derek@nats.io>
2021-09-19 13:27:26 -07:00
Derek Collison
ebc581012e Fixed a condition where JetStream assets could be created in multiple leafnodes.
Also added in optional Domain to StreamInfo.

Signed-off-by: Derek Collison <derek@nats.io>
2021-09-14 14:17:49 -07:00
Derek Collison
20574ffaad Merge pull request #2526 from nats-io/issue-2525
[FIXED] #2525
2021-09-14 06:41:18 -07:00
Derek Collison
9cdab0682a Bump version
Signed-off-by: Derek Collison <derek@nats.io>
2021-09-13 18:41:12 -07:00
Derek Collison
4cfffc6fa6 We use u16 to encide header len when replicating JetStream messages.
Make sure to error if we exceed that limit.

Signed-off-by: Derek Collison <derek@nats.io>
2021-09-13 18:13:07 -07:00
Derek Collison
e18a278196 Added ability to check if no message exists as a test to store the message.
Signed-off-by: Derek Collison <derek@nats.io>
2021-09-09 11:41:23 -07:00
Derek Collison
dadc3b9fae Fixed a bug when an interest retention stream with noack consumers is in clustered mode.
We were not properly propagating the ack state and proper cleanup of the stream messages.

Signed-off-by: Derek Collison <derek@nats.io>
2021-09-08 15:02:09 -07:00
Derek Collison
d809b02491 Fix for Issue #2397
When we had partial state due to server failure or being shutdown ungracefully we could enter into a stream reset state.
The stream reset state is harsh but worked, however there was a bug that would not restart consumers that were attached.
Also if no state exists, or state was truncated, we can detect that and not go through a full reset.

Signed-off-by: Derek Collison <derek@nats.io>
2021-09-01 07:04:50 -07:00
Derek Collison
70d28bd221 Use append in case pubAck is larger than stack []byte
Signed-off-by: Derek Collison <derek@nats.io>
2021-08-20 15:53:37 -07:00
Derek Collison
d349edeeb6 When a JetStream stream was used as a KV, there could be times where we have lots of file storage unused.
This change introduces utilization, better interior block deletes, and individual block compaction when we are below 50% utilization of the block.

Signed-off-by: Derek Collison <derek@nats.io>
2021-08-19 18:24:41 -07:00
Derek Collison
98f7d63b84 Fix for data race and corruption
Signed-off-by: Derek Collison <derek@nats.io>
2021-08-12 06:14:19 -07:00
Derek Collison
da3c89efda Add domain to PubAck1
Signed-off-by: Derek Collison <derek@nats.io>
2021-08-11 13:25:24 -07:00
R.I.Pienaar
a3bbb04748 Merge pull request #2409 from ripienaar/js_errors_redux
attempt to improve UX of the error system
2021-08-10 20:01:24 +02:00
Derek Collison
7dd399e355 Merge branch 'main' into max-per-default
Signed-off-by: Derek Collison <derek@nats.io>
2021-08-10 07:33:58 -07:00
R.I.Pienaar
76ab1b8d17 attempt to improve UX of the error system
Previously we had a few confusing functions like NewT
and similar that were quite fragile to use due to minimal
validation and a panic in go stdlib string Replacer.

Now we generate helper methods for every string, these
are used to access errors, fill in templates and conditional
returns of error type using the new Unless() option

We now get compile time errors for some common mistakes
and have better IDE helpers for arguments etc

Signed-off-by: R.I.Pienaar <rip@devco.net>
2021-08-10 16:08:28 +02:00
Derek Collison
633763a202 Fix for #2420
Signed-off-by: Derek Collison <derek@nats.io>
2021-08-10 06:36:08 -07:00
Derek Collison
29536629eb Simplified flow control, avoid stalls due to msg loss
Signed-off-by: Derek Collison <derek@nats.io>
2021-08-09 20:13:17 -07:00
Derek Collison
40c21934c5 Fix for #2416
Signed-off-by: Derek Collison <derek@nats.io>
2021-08-06 14:58:25 -07:00
Derek Collison
154bc40718 Fix for reentrant read lock on a stream that once anyone else wanted the write lock would deadlock.
Signed-off-by: Derek Collison <derek@nats.io>
2021-08-03 15:46:40 -07:00
Derek Collison
98970ac03d Add descriptions to JetStream streams and consumers. 2021-07-27 14:05:25 -07:00
Derek Collison
f13fa767c2 Remove the swapping of accounts during processing of service imports.
When processing service imports we would swap out the accounts during processing.
With the addition of internal subscriptions and internal clients publishing in JetStream we had an issue with the wrong account being used.
This was specific to delyaed pull subscribers trying to unsubscribe due to max of 1 while other JetStream API calls were running concurrently.
2021-07-26 07:57:10 -07:00