Commit Graph

149 Commits

Author SHA1 Message Date
Derek Collison
b517229c32 Fix for #2417
Signed-off-by: Derek Collison <derek@nats.io>
2021-08-06 14:44:00 -07:00
Derek Collison
398ae95a4a Various bug fixes and improvements to filestore consumer stores.
Improved behavior around clustered persistent consumers.

Signed-off-by: Derek Collison <derek@nats.io>
2021-08-03 22:17:49 -07:00
Derek Collison
22af59f758 Merge pull request #2387 from nats-io/expire-on-start-fixes
[IMPROVED] Server restart time with many expired JetStream messages.
2021-07-30 12:49:50 -07:00
Derek Collison
4e92b0ed6e When a server was restarting, if a stream had a MaxAge and there were a very large amount of messages to expire, this would take too long.
During normal operation and quick restarts the number of expired messages per cycle is manageable and correct.
However if a server is shutdown for quite a long time and many messages have expired this process is too slow.

This commit introduces an optimized expiration tailored for startup vs running state.

Signed-off-by: Derek Collison <derek@nats.io>
2021-07-30 12:48:47 -07:00
Derek Collison
9b0158daf9 Allow delivery policy of DeliverLastPerSubject, which is helpful for scoped watchers for K/V.
Signed-off-by: Derek Collison <derek@nats.io>
2021-07-28 12:49:02 -07:00
Derek Collison
960c45df81 Use of sync.Pool for filestore could cause msg corruption.
Signed-off-by: Derek Collison <derek@nats.io>
2021-07-06 08:41:01 -07:00
Derek Collison
c2c146c9f2 Fix for #2329.
When we created a filestore we would figure out if we should track by subject based on stream config.
This would cause bad results when a stream was updated to multiple subjects or wildcards.
This change tightens when and what we track but turns it on all the time now.

Signed-off-by: Derek Collison <derek@nats.io>
2021-06-30 19:10:31 -07:00
Derek Collison
35f6be2056 If dirty flag set always write state out
Signed-off-by: Derek Collison <derek@nats.io>
2021-06-29 12:25:28 -07:00
Derek Collison
99fed910f0 Improvements to large numbers of JetStream R1 consumers per stream.
1. We were holding open FDs longer than we should for consumers causing issues with open FD limits. We now do not hold them open and cap updates a bit better.

2. When doing a stream delete, consumer delete was repeating alot of work that was not necessary, causing longer delays. This has been optimized a bit, still more improvements to be made.

3. We cover all JS under a single export, but that was also trapping GetNext for pull based consumers, and since this was a no-op (is handled at user account level) we were creating alot of garbage service import responses and reverse map entries that had to be garbage collected. We have a fix in to avoind this but still looking for a better one.

4. Still had some lingering references to all exports vs single JS export.

Signed-off-by: Derek Collison <derek@nats.io>
2021-06-29 05:45:55 -07:00
Derek Collison
bb84ef7d91 Added ability to match based on last expected sequence per subject.
Signed-off-by: Derek Collison <derek@nats.io>
2021-06-28 10:57:50 -07:00
Derek Collison
c0e47966ab Added in Stream get last message by subject.
This is to aid in K/V overlay for simple Get ops vs creating a full blown consumer.

Signed-off-by: Derek Collison <derek@nats.io>
2021-06-24 13:21:39 -07:00
Derek Collison
6bbc29281c Make sure to return tmp bufs to pool when we can
Signed-off-by: Derek Collison <derek@nats.io>
2021-06-22 16:11:21 -07:00
Derek Collison
b3753aba1b Improvements to filtered purge and general memory use for filestore.
We optimized the filtered purge to skip msgBlks that are not in play.
Also optimized msgBlock buffer usage by using two sync.Pools to enhance reuse.

Signed-off-by: Derek Collison <derek@nats.io>
2021-06-22 15:47:26 -07:00
Derek Collison
7739eae45a Merge pull request #2302 from nats-io/js-encryption
JetStream Encryption at Rest
2021-06-22 10:35:02 -07:00
Derek Collison
2e145196b8 Fix for extended purge by sequence.
Signed-off-by: Derek Collison <derek@nats.io>
2021-06-22 07:38:30 -07:00
Derek Collison
bf6335dff9 Add in ability to have encrypted JetStream filestores.
This supports XChaChaPoly1305 for Seal and Open and ChaCha20 for our message blocks which use highway hashes and sequence numbers for authenticity.
We support snapshot and restore as well.

Signed-off-by: Derek Collison <derek@nats.io>
2021-06-21 19:28:10 -07:00
Derek Collison
89d930fd0f Updates and fixes to PurgeEx
Signed-off-by: Derek Collison <derek@nats.io>
2021-06-20 10:34:27 -07:00
Derek Collison
9398c3ca28 Allow for more advanced purge operations that filter by subject, specify the sequence or number of messages to keep.
Signed-off-by: Derek Collison <derek@nats.io>
2021-06-19 07:04:44 -07:00
Derek Collison
d0ac1a40ca Added in per subject limits for streams.
Signed-off-by: Derek Collison <derek@nats.io>
2021-06-15 06:36:34 -07:00
Derek Collison
08cdb2d2ea Make filtered consumers in large mixed streams more efficient.
Allow wider scoped filtered subjects.

We introduce a per subject information tracking to filestore to optimize for large mux'd streams and more efficient filtered consumers.

Signed-off-by: Derek Collison <derek@nats.io>
2021-06-15 04:44:05 -07:00
Derek Collison
a27b0dd673 Move default file and dir perms
Signed-off-by: Derek Collison <derek@nats.io>
2021-05-19 14:46:07 -07:00
Derek Collison
ad32edfb59 If a consumer state has a redelivered that is not quite correct that should not be a corrupt state error.
Signed-off-by: Derek Collison <derek@nats.io>
2021-05-17 17:44:58 -07:00
Derek Collison
9bfab00194 Add in comments to help with usage
Signed-off-by: Derek Collison <derek@nats.io>
2021-05-05 08:58:14 -07:00
Derek Collison
a33c64959d [FIXED] Under certain conditions with messages being auto-deleted we would not honor blk size properly.
Signed-off-by: Derek Collison <derek@nats.io>
2021-05-05 08:27:22 -07:00
Derek Collison
71ba4b1bf6 Improved stability when expireMsgs and writeMsg and Compact/Purge all concurrent.
We had issues of instability and incorrect behavior during concurrent operations.
This CL optimizes expiring msgs to be more efficient and hold the lock until completion.
Compact will also now hold the top level lock through completion.

Signed-off-by: Derek Collison <derek@nats.io>
2021-05-04 20:12:38 -07:00
scottf
486df98373 close tempfiles, fix path print 2021-04-22 12:47:21 -04:00
Waldemar Quevedo
2976a78f57 js: msgblock close fix
Also swaps order of cleaning up resource directory in cluster tests.
2021-04-15 09:16:02 -07:00
Derek Collison
90989d57d6 Change to report total deleted by default for stream info.
Allow deleted details if requested.

Signed-off-by: Derek Collison <derek@nats.io>
2021-04-12 18:10:11 -07:00
Derek Collison
bbb03af442 Make sure we do not set last to -1. #2068
Signed-off-by: Derek Collison <derek@nats.io>
2021-04-12 11:01:41 -07:00
Derek Collison
e0eaf704dc Partial fix for #2068.
This will not protect against the index file being completely removed.

Signed-off-by: Derek Collison <derek@nats.io>
2021-04-10 12:46:31 -07:00
Derek Collison
a5440f4ae7 Merge pull request #2080 from nats-io/compact_bug
Fix bug that could cause panic and corruption on filestore compact.
2021-04-07 15:38:42 -07:00
Derek Collison
bfb482121d In some scenarios compact could count messages it should not and make mb.msgs go negative which meant max uint64.
Signed-off-by: Derek Collison <derek@nats.io>
2021-04-07 14:39:23 -07:00
Derek Collison
1b5f0edbab Quiet race detector
Signed-off-by: Derek Collison <derek@nats.io>
2021-04-07 14:25:21 -07:00
Derek Collison
c0e8590c0f During startup each filtered consumer could do a linear scan of the stream
to determine number of messages pending. This improves that with a startup cache.

Signed-off-by: Derek Collison <derek@nats.io>
2021-04-07 09:15:01 -07:00
Derek Collison
44ada49b16 During repeated server restarts or failures consumer state could drift between replicas.
We now make sure to sync state of the replicas when a new leader takes over. We also update ack floors regardless of detection on pending list.

Signed-off-by: Derek Collison <derek@nats.io>
2021-04-02 08:20:29 -07:00
Derek Collison
c3ec8d9fb3 Agressive cache expiration was hindering performance when publishing and receiving from a stream concurrently.
Signed-off-by: Derek Collison <derek@nats.io>
2021-04-01 16:32:43 -07:00
Derek Collison
bb7a8a5f79 Introduced default max ack pending for ack explicit.
Fixed a bug that would introduce performance degradation for durable consumers R>1.

Signed-off-by: Derek Collison <derek@nats.io>
2021-03-30 11:47:24 -07:00
Derek Collison
e53caee5e8 Enforce server limits even when dynamic limits for accounts in play.
We were not properly enforcing server limits. This commit will allow a server to enforce limits but still remain functional even at the JetStream level.
Also fixed a bug for RAFT replay that could cause instability.

Signed-off-by: Derek Collison <derek@nats.io>
2021-03-25 16:06:27 -07:00
Derek Collison
358ac6a956 Fix for race detector
Signed-off-by: Derek Collison <derek@nats.io>
2021-03-18 11:09:28 -07:00
Derek Collison
566937a880 Updates to memory pressure.
1. Release cache during heavy writes when we move to a new block if no read activity.
2. If we detect a linear scan reading dump the cache on the last seq read for the mb.

Signed-off-by: Derek Collison <derek@nats.io>
2021-03-17 18:51:34 -07:00
Derek Collison
2e9ae92bb5 Fix for #2011 and atomics on 32bit systems.
Signed-off-by: Derek Collison <derek@nats.io>
2021-03-16 13:57:28 -07:00
Derek Collison
e079d75d8b Fixes for index first from idx file
Signed-off-by: Derek Collison <derek@nats.io>
2021-03-14 12:26:30 -07:00
Derek Collison
a2cdbdff2e Make setting of mb.first.seq more reliable
Signed-off-by: Derek Collison <derek@nats.io>
2021-03-14 11:37:43 -07:00
Derek Collison
dab6bd2310 Make Compact to higher first seq atomic
Signed-off-by: Derek Collison <derek@nats.io>
2021-03-13 17:50:15 -05:00
Derek Collison
e776013bf0 Close FDs when we are done writing
Signed-off-by: Derek Collison <derek@nats.io>
2021-03-13 16:28:25 -05:00
Derek Collison
1d20636405 Make max block size 16MB
Signed-off-by: Derek Collison <derek@nats.io>
2021-03-13 16:28:24 -05:00
Derek Collison
8a44c41910 Tune down default blk sizes for streams
Signed-off-by: Derek Collison <derek@nats.io>
2021-03-13 16:28:24 -05:00
Derek Collison
d31fda5dac Added code to constrain size of WAL under most scenarios.
Signed-off-by: Derek Collison <derek@nats.io>
2021-03-06 08:38:56 -08:00
Derek Collison
507eb25dc1 Fix for not placing checksum back properly on manual check restore
Signed-off-by: Derek Collison <derek@nats.io>
2021-03-05 09:18:20 -08:00
Derek Collison
18ee2b7a40 Changes to handle short writes. Bug fixes to truncation.
Signed-off-by: Derek Collison <derek@nats.io>
2021-03-03 20:07:39 -08:00