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

* fix: replay memtable should from flushed_entry_id + 1

* chore: apply suggestions from CR
This commit is contained in:
Weny Xu
2023-12-29 01:12:07 +09:00
committed by GitHub
parent 7152407428
commit b526d159c3

View File

@@ -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,
@@ -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?;
debug_assert!(entry_id > flushed_entry_id);
last_entry_id = last_entry_id.max(entry_id);
for mutation in entry.mutations {
rows_replayed += mutation