adityamukho commented on code in PR #7489:
URL: https://github.com/apache/ignite-3/pull/7489#discussion_r2735089377


##########
modules/storage-page-memory/src/test/java/org/apache/ignite/internal/storage/pagememory/mv/PersistentPageMemoryMvPartitionStorageConcurrencyTest.java:
##########
@@ -96,4 +105,49 @@ protected void tearDown() throws Exception {
                 engine == null ? null : engine::stop
         );
     }
+
+    /**
+     * Reproducer for a <a 
href="https://issues.apache.org/jira/browse/IGNITE-27638";>corrupted Write 
Intent list</a>.
+     * During replace of the value found both in inner and leaf nodes of 
VersionChain tree, we tried to remove WI from the WI list twice.
+     * If neighboring WI in the WI double-linked list was invalidated between 
these removals, we would get an exception trying to access it
+     * to change its links.
+     * <p>
+     * Test builds a 3-level tree, and creates a race between aborting B and D 
write intents. WI are large, so they don't share the same
+     * page.
+     * <p>           C
+     * <p>          /  \
+     * <p>        B     D
+     * <p>       / \    | \
+     * <p>      A   B   C  D
+     */
+    @Test
+    void testAbortWriteIntentsListRace() throws IgniteInternalCheckedException 
{
+        // Build a 3-level tree.
+        int rowsCount = 50_000;
+        UUID txId = newTransactionId();
+        RowId[] rowIds = new RowId[rowsCount];
+
+        for (int i = 0; i < rowsCount; i++) {
+            rowIds[i] = new RowId(PARTITION_ID, i, i);
+            addWriteCommitted(rowIds[i], TABLE_ROW, HybridTimestamp.MAX_VALUE);
+        }
+
+        // Check that the tree has 3 levels, first level is 0.
+        assertThat((((PersistentPageMemoryMvPartitionStorage) 
storage).renewableState.versionChainTree().rootLevel()), is(2));
+
+        // First index that will be in the inner node, "B" on the javadoc 
diagram. Value was found experimentally.
+        int bIndex = 163;

Review Comment:
   This hard-coded index used to jump to node 'B' seems too fragile. There 
should be a better way - perhaps adding a `@TestOnly` method inside 
`VersionChain` to get the page size could help.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to