Merge pull request #8649 from influxdata/savage/cover-wal-replay-of-empty-wal-file
test(ingester): Cover WAL replay of empty filespull/24376/head
commit
8f6b416d3f
|
@ -124,9 +124,7 @@ where
|
||||||
"dropping empty wal segment",
|
"dropping empty wal segment",
|
||||||
);
|
);
|
||||||
|
|
||||||
// TODO(test): empty WAL replay
|
// A failure to delete an empty file MUST not prevent WAL
|
||||||
|
|
||||||
// A failure to delete an empty file should not prevent WAL
|
|
||||||
// replay from continuing.
|
// replay from continuing.
|
||||||
if let Err(error) = wal.delete(file.id()).await {
|
if let Err(error) = wal.delete(file.id()).await {
|
||||||
error!(
|
error!(
|
||||||
|
@ -381,7 +379,8 @@ mod tests {
|
||||||
|
|
||||||
// The write portion of this test.
|
// The write portion of this test.
|
||||||
//
|
//
|
||||||
// Write two ops, rotate the file, and write a third op.
|
// Write two ops, rotate the file twice (ensuring an empty file is
|
||||||
|
// handled ok), write a third op and finally an empty op.
|
||||||
{
|
{
|
||||||
let inner = Arc::new(MockDmlSink::default().with_apply_return(vec![
|
let inner = Arc::new(MockDmlSink::default().with_apply_return(vec![
|
||||||
Ok(()),
|
Ok(()),
|
||||||
|
@ -414,6 +413,10 @@ mod tests {
|
||||||
// Rotate the log file
|
// Rotate the log file
|
||||||
wal.rotate().expect("failed to rotate WAL file");
|
wal.rotate().expect("failed to rotate WAL file");
|
||||||
|
|
||||||
|
// Rotate the log file again, in order to create an empty segment and ensure
|
||||||
|
// replay is tolerant to it
|
||||||
|
wal.rotate().expect("failed to rotate WAL file");
|
||||||
|
|
||||||
// Write the third op
|
// Write the third op
|
||||||
wal_sink
|
wal_sink
|
||||||
.apply(IngestOp::Write(op3.clone()))
|
.apply(IngestOp::Write(op3.clone()))
|
||||||
|
@ -435,7 +438,8 @@ mod tests {
|
||||||
.await
|
.await
|
||||||
.expect("failed to initialise WAL");
|
.expect("failed to initialise WAL");
|
||||||
|
|
||||||
assert_eq!(wal.closed_segments().len(), 2);
|
// Must be 3 segments, 1 OK, 1 Empty and 1 with a normal op and blank op
|
||||||
|
assert_eq!(wal.closed_segments().len(), 3);
|
||||||
|
|
||||||
// Initialise the mock persist system
|
// Initialise the mock persist system
|
||||||
let persist = Arc::new(MockPersistQueue::default());
|
let persist = Arc::new(MockPersistQueue::default());
|
||||||
|
@ -497,7 +501,7 @@ mod tests {
|
||||||
.join()
|
.join()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
// Ensure the replayed segments were dropped
|
// Ensure the replayed segments were dropped, including the empty one
|
||||||
let wal = Wal::new(dir.path())
|
let wal = Wal::new(dir.path())
|
||||||
.await
|
.await
|
||||||
.expect("failed to initialise WAL");
|
.expect("failed to initialise WAL");
|
||||||
|
@ -511,7 +515,7 @@ mod tests {
|
||||||
.get_observer(&Attributes::from([]))
|
.get_observer(&Attributes::from([]))
|
||||||
.expect("attributes not found")
|
.expect("attributes not found")
|
||||||
.fetch();
|
.fetch();
|
||||||
assert_eq!(files, 2);
|
assert_eq!(files, 3);
|
||||||
let ops = metrics
|
let ops = metrics
|
||||||
.get_instrument::<Metric<U64Counter>>("ingester_wal_replay_ops")
|
.get_instrument::<Metric<U64Counter>>("ingester_wal_replay_ops")
|
||||||
.expect("file counter not found")
|
.expect("file counter not found")
|
||||||
|
|
Loading…
Reference in New Issue