mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-01-15 01:32:56 +00:00
chore: always obsolete wal to avoid discontinuous log entries (#3789)
This commit is contained in:
@@ -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: {}",
|
||||
|
||||
Reference in New Issue
Block a user