refactor(storage): create new read snapshot to read for StateStore trait #20172
+663
−344
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.
I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.
What's changed and what's your intention?
Previously we have two traits to read in storage,
LocalStateStore
andStateStoreRead
. One difference in the two traits is that, forStateStoreRead
, we have to specify the epoch to read on, while forLocalStateStore
, since its read methods always read from the latest snapshot, we don't need to specify the epoch.In #20153, we introduce a new associated type
FlushedSnapshotReader
, which also reads data from the latest snapshot. However, since it implements theStateStoreRead
trait, when we call its read methods, we still need to specify the epoch, which is actually unnecessary. Besides, it will be cleaner if we are able to make the read methods more unified in the trait definition.Therefore, in this PR, we will remove the
epoch
parameter from the read methods ofStateStoreRead
trait. Instead, we add a new methodnew_read_snapshot
toStateStore
, whose return type is a new associated typeReadSnapshot
that implementsStateStoreRead
. In thenew_read_snapshot
method, we specify theepoch
andtable_id
to read. In the implementation ofHummockStorage
onnew_read_snapshot
, we also dotry_wait_epoch
on the epoch, so that the returnedReadSnapshot
is ready to read.Changes in the trait definition is as followed:
Checklist
Documentation
Release note