(2.12) Linearizable Message Get request #7146
Closed
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.
Support for read-after-write and monotonic reads was added in #6970. This allows you to guarantee these properties, given you have access to the minimum last sequence to observe all writes up to that point.
If you don't have access to this sequence, for example when receiving an event via a side channel (that doesn't contain a sequence) you can't use these mechanisms. This PR adds support for Linearizable reads through single-message get requests. An alternative method that doesn't require any knowledge about a sequence, but has the additional cost of requiring replication to ensure the data is most recent.
An overview of consistency levels provided depending on which settings are used:
MinLastSeq
constraint in eitherJSApiMsgGetRequest
orConsumerConfig
. Requiring the server that answers reads or serves consumer data to contain all writes up to and including the specified sequence.Linearizable
constraint in theJSApiMsgGetRequest
. This ensures the most recent real-time data is returned, at the cost of: requiring replication when the stream is replicated, only allowing message get requests (not direct get), and the read to be served only by the stream leader.Consumers only offer read-after-write and monotonic reads through the use of
MinLastSeq
. But consumers can be made to guarantee linearizability if the first request to a stream is done using theLinearizable
constraint to get the last message of the stream withJSApiMsgGetRequest
. This sequence can then be used in the consumer create request to guarantee linearizability regardless of on which replica it is placed.The default should be used when eventual consistency is desired for highest possible scale and speed. Read-after-write and monotonic reads can be used when desiring a minimal level of consistency, ensuring a specified amount of writes can be observed, allowing for high scale and speed, but optionally needing to handle additional error conditions or minor speed reductions. Linearizability adds the highest level of consistency at the tradeoff of scale and speed, only the original stream leader can answer these message get requests. This flexibility lets user choose between scale, speed, and levels of consistency/constraints on the topology.
Signed-off-by: Maurice van Veen [email protected]