Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(wal): replay memtable should from flushed_entry_id + 1 #3038

Merged
merged 2 commits into from
Dec 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/mito2/src/region/opener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,9 @@ impl RegionOpener {
let version_control = Arc::new(VersionControl::new(version));
if !self.skip_wal_replay {
info!(
"Start replaying memtable at flushed_entry_id {} for region {}",
flushed_entry_id, region_id
"Start replaying memtable at flushed_entry_id + 1 {} for region {}",
flushed_entry_id + 1,
region_id
);
replay_memtable(
wal,
Expand Down Expand Up @@ -380,9 +381,12 @@ pub(crate) async fn replay_memtable<S: LogStore>(
// data in the WAL.
let mut last_entry_id = flushed_entry_id;
let mut region_write_ctx = RegionWriteCtx::new(region_id, version_control, wal_options.clone());
let mut wal_stream = wal.scan(region_id, flushed_entry_id, wal_options)?;

let replay_from_entry_id = flushed_entry_id + 1;
let mut wal_stream = wal.scan(region_id, replay_from_entry_id, wal_options)?;
while let Some(res) = wal_stream.next().await {
let (entry_id, entry) = res?;
WenyXu marked this conversation as resolved.
Show resolved Hide resolved
debug_assert!(entry_id > flushed_entry_id);
last_entry_id = last_entry_id.max(entry_id);
for mutation in entry.mutations {
rows_replayed += mutation
Expand Down
Loading