NRG (2.11): Completeness/consistency after leader changes #6485
+182
−72
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.
Previously #6194 implemented a way to wait for entries that are stored in the new leader's log but not yet applied, before allowing 'expected per subject' operations to go through. This protected against KV/stream desync.
That protection is now extended to the whole of (clustered) JetStream, and not specific to this one operation anymore. Meaning that if the new leader recognizes it has entries in its log that have not yet been applied, it waits for those to be applied before responding to any read/write operations. In essence it's the 'Leader Completeness Property' as described by the Raft paper. This also brings us closer to 'read-your-writes' when only requesting reads from the leader.
Signed-off-by: Maurice van Veen github@mauricevanveen.com