This is an automated email from the ASF dual-hosted git repository.

vpyatkov pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/ignite-3.git


The following commit(s) were added to refs/heads/main by this push:
     new 02f5682181 IGNITE-21641 Fixed OOM in PartitionReplicaListenerTest 
(#3357)
02f5682181 is described below

commit 02f5682181e82d87c1fddc157edbb6475ebf818b
Author: Denis Chudov <[email protected]>
AuthorDate: Tue Mar 12 20:19:10 2024 +0300

    IGNITE-21641 Fixed OOM in PartitionReplicaListenerTest (#3357)
---
 .../replication/PartitionReplicaListenerTest.java  | 46 +++++++++++-----------
 1 file changed, 22 insertions(+), 24 deletions(-)

diff --git 
a/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/replication/PartitionReplicaListenerTest.java
 
b/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/replication/PartitionReplicaListenerTest.java
index fdd5116522..d8c39e3540 100644
--- 
a/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/replication/PartitionReplicaListenerTest.java
+++ 
b/modules/table/src/test/java/org/apache/ignite/internal/table/distributed/replication/PartitionReplicaListenerTest.java
@@ -1524,6 +1524,7 @@ public class PartitionReplicaListenerTest extends 
IgniteAbstractTest {
 
         BinaryRow br2Pk = marshalQuietly(new TestKey(2, "k" + 2), 
kvMarshaller);
 
+        // Preloading the data if needed.
         if (insertFirst) {
             UUID tx0 = newTxId();
             upsert(tx0, br1);
@@ -1533,40 +1534,37 @@ public class PartitionReplicaListenerTest extends 
IgniteAbstractTest {
 
         txState = null;
 
+        // Delete the same row 2 times within the same transaction to generate 
garbage rows in storage.
+        // If the data was not preloaded, there will be one deletion actually.
         UUID tx1 = newTxId();
         delete(tx1, br1Pk);
         upsert(tx1, br1);
+        delete(tx1, br1Pk);
 
-        while (true) {
-            delete(tx1, br1Pk);
-
-            if (upsertAfterDelete) {
-                upsert(tx1, br1);
-            }
+        if (upsertAfterDelete) {
+            upsert(tx1, br1);
+        }
 
+        if (!insertFirst && !upsertAfterDelete) {
             Cursor<RowId> cursor = pkStorage().get(br1);
 
-            if (!insertFirst) {
-                if (!upsertAfterDelete) {
-                    assertFalse(cursor.hasNext());
-                }
-
-                // If there were no other entries in index, break after first 
iteration.
-                break;
-            } else {
-                // This check is only for cases when new rows generation mess 
the index contents and some rows there have no value.
-                // We try to reach the point when the first row in cursor have 
no value, to test that this row will be skipped by RO tx.
-                // TODO https://issues.apache.org/jira/browse/IGNITE-18767 
after this, the following check may be not needed.
-                RowId rowId = cursor.next();
-
-                BinaryRow row = testMvPartitionStorage.read(rowId, 
HybridTimestamp.MAX_VALUE).binaryRow();
-
-                if (row == null) {
-                    break;
-                }
+            // Data was not preloaded or inserted after deletion.
+            assertFalse(cursor.hasNext());
+        } else {
+            // We create a null row with a row id having minimum possible 
value to ensure this row would be the first in cursor.
+            // This is needed to check that this row will be skipped by RO tx 
and it will see the data anyway.
+            // TODO https://issues.apache.org/jira/browse/IGNITE-18767 after 
this, the following check may be not needed.
+            RowId emptyRowId = new RowId(PART_ID, new UUID(Long.MIN_VALUE, 
Long.MIN_VALUE));
+            testMvPartitionStorage.addWrite(emptyRowId, null, tx1, TABLE_ID, 
PART_ID);
+
+            if (committed) {
+                testMvPartitionStorage.commitWrite(emptyRowId, clock.now());
             }
+
+            pkStorage().put(br1, emptyRowId);
         }
 
+        // If committed, there will be actual values in storage, otherwise 
write intents.
         if (committed) {
             cleanup(tx1);
         }

Reply via email to