kvclient: serve point read-your-own-writes from the buffer #140713
+284
−11
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.
This patch teaches the txnWriteBuffer to recognize when a point-read (i.e. a Get request) should be served from its local buffer. In such cases, we eschew sending the request to the KV layer, and instead stitch the result back on the response path.
The approach above is fairly straightforward. The only thing we must take care of is ensuring the correct value is returned based on the Get request's sequence number. The logic here mirrors that of
getOne
inpebble_mvcc_scanner.go
. It's a bit simpler, as we don't have to account for sequence number rollbacks here. Unlike on the server, we'll proactively rollback writes belonging to sequence numbers that have been ignored as part of a savepoint rollback. As a result, we can be sure that any writes in the buffer aren't rolled back.In a followup patch, we'll add support for Scan/Reverse requests that overlap with a part of the butffer.
Informs #139054
Release note: None