From e209b4e5090b11dc31e89cd64b38a069748dad83 Mon Sep 17 00:00:00 2001 From: Zach Bray Date: Tue, 2 Apr 2024 10:23:43 +0100 Subject: [PATCH] Fix ReplayIndex to delete all index segments on sequence reset. Previously, if any index segments had been updated, it would only delete those. Now, it deletes all segments regardless of what has been touched. --- .../uk/co/real_logic/artio/engine/logger/ReplayIndex.java | 6 ++++-- .../co/real_logic/artio/engine/logger/ReplayIndexTest.java | 2 -- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/artio-core/src/main/java/uk/co/real_logic/artio/engine/logger/ReplayIndex.java b/artio-core/src/main/java/uk/co/real_logic/artio/engine/logger/ReplayIndex.java index 8e419f85ba..06d2c8463e 100644 --- a/artio-core/src/main/java/uk/co/real_logic/artio/engine/logger/ReplayIndex.java +++ b/artio-core/src/main/java/uk/co/real_logic/artio/engine/logger/ReplayIndex.java @@ -621,9 +621,11 @@ void reset() evictionHandler.onReset(fixSessionId); deleteFile(headerFile); - for (final File segmentFile: segmentBufferFiles) + + for (int segmentIndex = 0; segmentIndex < segmentCount; segmentIndex++) { - if (segmentFile != null) + final File segmentFile = replayIndexSegmentFile(fixSessionId, segmentIndex); + if (segmentFile.exists()) { deleteFile(segmentFile); } diff --git a/artio-core/src/test/java/uk/co/real_logic/artio/engine/logger/ReplayIndexTest.java b/artio-core/src/test/java/uk/co/real_logic/artio/engine/logger/ReplayIndexTest.java index 85e3e16e41..dafe3531e4 100644 --- a/artio-core/src/test/java/uk/co/real_logic/artio/engine/logger/ReplayIndexTest.java +++ b/artio-core/src/test/java/uk/co/real_logic/artio/engine/logger/ReplayIndexTest.java @@ -42,7 +42,6 @@ import org.agrona.concurrent.status.AtomicCounter; import org.junit.After; import org.junit.Before; -import org.junit.Ignore; import org.junit.Test; import org.mockito.Mockito; @@ -442,7 +441,6 @@ public void shouldDeleteIndexSegmentsOnSequenceResetWhenNoSegmentsHaveBeenTouche } @Test(timeout = 20_000L) - @Ignore public void shouldDeleteIndexSegmentsOnSequenceResetWhenASegmentHasBeenTouched() { int seqNo = 1;