Description
StandaloneWalIterator return wrong record if lowBound point to the end of archive.
Reproducer:
Index: modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StandaloneWalRecordsIteratorTest.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StandaloneWalRecordsIteratorTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StandaloneWalRecordsIteratorTest.java --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StandaloneWalRecordsIteratorTest.java (revision 77b1357c913984a43facc654200dc6053ed8b736) +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StandaloneWalRecordsIteratorTest.java (date 1641887736346) @@ -93,10 +93,13 @@ cleanPersistenceDir(); } - /** - * - */ + /** */ private String createWalFiles() throws Exception { + return createWalFiles(1); + } + + /** */ + private String createWalFiles(int segRecCnt) throws Exception { IgniteEx ig = (IgniteEx)startGrid(); String archiveWalDir = getArchiveWalDirPath(ig); @@ -112,7 +115,10 @@ sharedMgr.checkpointReadLock(); try { - walMgr.log(new SnapshotRecord(i, false), RolloverType.NEXT_SEGMENT); + for (int j = 0; j < segRecCnt - 1; j++) + walMgr.log(new SnapshotRecord(i * segRecCnt + j, false)); + + walMgr.log(new SnapshotRecord(i * segRecCnt + segRecCnt - 1, false), RolloverType.NEXT_SEGMENT); } finally { sharedMgr.checkpointReadUnlock(); @@ -144,6 +150,37 @@ ); } + /** + * Check correct check bounds. + * + * @throws Exception if test failed. + */ + @Test + public void testNextRecordReturnedForLowBounds() throws Exception { + String dir = createWalFiles(3); + + WALIterator iter = createWalIterator(dir, null, null, false); + + IgniteBiTuple<WALPointer, WALRecord> prev = iter.next(); + + iter = createWalIterator(dir, iter.lastRead().get(), null, false); + + while (iter.hasNext()) { + IgniteBiTuple<WALPointer, WALRecord> cur = iter.next(); + + assertFalse( + "Should read next record[prev=" + prev.get1() + ", cur=" + cur.get1() + ']', + prev.get1().equals(cur.get1()) + ); + + assertFalse(prev.get1().equals(iter.lastRead().get())); + + prev = cur; + + iter = createWalIterator(dir, iter.lastRead().get(), null, false); + } + } + /** * Check correct check bounds. * @@ -273,7 +310,7 @@ if (lowBound != null) params.from(lowBound); - if (lowBound != null) + if (highBound != null) params.to(highBound); return new IgniteWalIteratorFactory(log).iterator(params);
Attachments
Attachments
Issue Links
- is a clone of
-
IGNITE-14351 Runtime change of WAL force rollover parameters
-
- Open
-
- links to