(2.12) Atomic batch: support Nats-Expected-Last-Sequence
, Nats-Rollup
, DiscardNew
#7119
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add support for the
Nats-Expected-Last-Sequence
andNats-Rollup
headers for batching, as well asDiscardNew
support.To do this we need to be able to fully rely on clustered-level consistency checks, such that followers will always apply them and never call
bumpCLFS()
. Just a few cases remain, but these should not be problematic. Now we can rely onmset.clseq - mset.clfs
to be what the highest last sequence is going to be, which can then be compared in consistency checks.Nats-Rollup
additionally has some batch-specific consistency checks:Nats-Rollup: all
is allowed only on the first message. Using it on any later message would mean you'd be purging data at the start of the batch.Nats-Rollup: sub
is only allowed on the first message of a specific subject. If allowed on a later message with the same subject, that would mean you'd be purging data at the start of the batch. This means we can allow rolling up multiple subjects in the batch at once.Resolves #6975
Signed-off-by: Maurice van Veen [email protected]