Uploaded image for project: 'Ignite'
  1. Ignite
  2. IGNITE-16255

WalIterator#lastRead point to the next record in the middle of iteration

Agile BoardAttach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 2.13
    • None

    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

        Issue Links

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            nizhikov Nikolay Izhikov
            nizhikov Nikolay Izhikov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - Not Specified
              Not Specified
              Remaining:
              Remaining Estimate - 0h
              0h
              Logged:
              Time Spent - 1.5h
              1.5h

              Slack

                Issue deployment