From 36604d30ae7d4ca3be8c6438345d2d4423734631 Mon Sep 17 00:00:00 2001 From: Fraser Savage Date: Wed, 6 Sep 2023 11:26:00 +0100 Subject: [PATCH] refactor(ingester): Only automatically recover when encountering `IncompleteEntry` during wal replay --- ingester/src/init/wal_replay.rs | 22 +++++++++++++++++----- wal/src/blocking/reader.rs | 2 +- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/ingester/src/init/wal_replay.rs b/ingester/src/init/wal_replay.rs index 54e8d73c1b..89e012aa41 100644 --- a/ingester/src/init/wal_replay.rs +++ b/ingester/src/init/wal_replay.rs @@ -214,7 +214,12 @@ where let segment_id = batches.id(); for batch in batches { - if let Err(err @ wal::Error::UnableToReadNextOps { .. }) = batch { + if let Err( + err @ wal::Error::UnableToReadNextOps { + source: wal::blocking::ReaderError::IncompleteEntry { .. }, + }, + ) = batch + { error!(%err, ?segment_id, "unable to recover further op batches from wal segment"); break; } @@ -618,7 +623,12 @@ mod tests { Ok([arbitrary_sequenced_wal_op(SequenceNumber::new(2))] .into_iter() .collect()), - Err(wal::Error::SegmentFileIdentifierMismatch {}), + Err(wal::Error::UnableToReadNextOps { + source: wal::blocking::ReaderError::ChecksumMismatch { + expected: 1, + actual: 2, + }, + }), ] .into_iter() .collect::>(), @@ -657,9 +667,11 @@ mod tests { .into_iter() .collect()), Err(wal::Error::UnableToReadNextOps { - source: wal::blocking::ReaderError::LengthMismatch { - expected: 1, - actual: 2, + source: wal::blocking::ReaderError::IncompleteEntry { + source: std::io::Error::new( + std::io::ErrorKind::UnexpectedEof, + "gremlins in the drive", + ), }, }), ] diff --git a/wal/src/blocking/reader.rs b/wal/src/blocking/reader.rs index f1dd1ce070..07f9411fd2 100644 --- a/wal/src/blocking/reader.rs +++ b/wal/src/blocking/reader.rs @@ -164,7 +164,7 @@ pub enum Error { source: io::Error, }, - /// An [`IncompleteEntry`] error is returned when the reader is unable to + /// An [`Error::IncompleteEntry`] error is returned when the reader is unable to /// read an entry because of an unexpected end of file. IncompleteEntry { source: io::Error,