chore: always obsolete wal to avoid discontinuous log entries (#3789)

This commit is contained in:
Lei, HUANG
2024-04-24 15:08:01 +08:00
committed by GitHub
parent 42e7403fcc
commit 8d229dda98

View File

@@ -441,13 +441,11 @@ pub(crate) async fn replay_memtable<S: LogStore>(
// data in the WAL.
let mut last_entry_id = flushed_entry_id;
let replay_from_entry_id = flushed_entry_id + 1;
let mut stale_entry_found = false;
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?;
if entry_id <= flushed_entry_id {
stale_entry_found = true;
warn!("Stale WAL entries read during replay, region id: {}, flushed entry id: {}, entry id read: {}", region_id, flushed_entry_id, entry_id);
ensure!(
allow_stale_entries,
@@ -476,11 +474,8 @@ pub(crate) async fn replay_memtable<S: LogStore>(
region_write_ctx.write_memtable();
}
if allow_stale_entries && stale_entry_found {
wal.obsolete(region_id, flushed_entry_id, wal_options)
.await?;
info!("Force obsolete WAL entries, region id: {}, flushed entry id: {}, last entry id read: {}", region_id, flushed_entry_id, last_entry_id);
}
wal.obsolete(region_id, flushed_entry_id, wal_options)
.await?;
info!(
"Replay WAL for region: {}, rows recovered: {}, last entry id: {}",