You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ignite.apache.org by "Luchnikov Alexander (Jira)" <ji...@apache.org> on 2022/05/13 09:23:00 UTC

[jira] [Updated] (IGNITE-16255) WalIterator#lastRead point to the next record in the middle of iteration

     [ https://issues.apache.org/jira/browse/IGNITE-16255?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Luchnikov Alexander updated IGNITE-16255:
-----------------------------------------
    Labels: IEP-59 ise.lts  (was: IEP-59)

> WalIterator#lastRead point to the next record in the middle of iteration
> ------------------------------------------------------------------------
>
>                 Key: IGNITE-16255
>                 URL: https://issues.apache.org/jira/browse/IGNITE-16255
>             Project: Ignite
>          Issue Type: Bug
>            Reporter: Nikolay Izhikov
>            Assignee: Nikolay Izhikov
>            Priority: Major
>              Labels: IEP-59, ise.lts
>             Fix For: 2.13
>
>          Time Spent: 1.5h
>  Remaining Estimate: 0h
>
> StandaloneWalIterator return wrong record if lowBound point to the end of archive.
> Reproducer:
> {noformat}
> 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);
> {noformat}



--
This message was sent by Atlassian Jira
(v8.20.7#820007)