You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by "ibessonov (via GitHub)" <gi...@apache.org> on 2023/04/28 12:26:28 UTC

[GitHub] [ignite-3] ibessonov commented on a diff in pull request #1992: IGNITE-19302 Phantom reads fixed

ibessonov commented on code in PR #1992:
URL: https://github.com/apache/ignite-3/pull/1992#discussion_r1180342821


##########
modules/runner/src/integrationTest/java/org/apache/ignite/internal/table/ItTableScanTest.java:
##########
@@ -590,14 +513,71 @@ public void testScanWithUpperBound() throws Exception {
                 null
         );
 
-        ArrayList<BinaryRow> scannedRows2 = scanAllRows(publisher2);
+        List<BinaryRow> scannedRows2 = scanAllRows(publisher2);
 
         assertEquals(5, scannedRows2.size());
 
         log.info("Result of scanning after insert rows: " + scannedRows2.stream().map(binaryRow -> rowToString(binaryRow))
                 .collect(Collectors.joining(", ")));
     }
 
+    @Test
+    public void testPhantomReads() throws Exception {
+        int iterations = 10;
+
+        // "for" is better at detecting data races than RepeatedTest.
+        for (int i = 0; i < iterations; i++) {
+            KeyValueView<Tuple, Tuple> kvView = table.keyValueView();
+
+            UUID sortedIndexId = getSortedIndexId();
+
+            int partId = 0;
+
+            InternalTransaction tx = startTxWithEnlistedPartition(partId);
+
+            try {
+                IgniteBiTuple<ClusterNode, Long> leaderWithTerm = tx.enlistedNodeAndTerm(new TablePartitionId(table.tableId(), partId));
+
+                PrimaryReplica recipient = new PrimaryReplica(leaderWithTerm.get1(), leaderWithTerm.get2());
+
+                Publisher<BinaryRow> publisher = internalTable.scan(partId, tx.id(), recipient, sortedIndexId, null, null, 0, null);
+
+                // Non-thread-safe collection is fine, HB is guaranteed by "Thread#join" inside of "runRace".

Review Comment:
   I don't like using thread-safe collections when no one needs them, I consider this a bad practice.



-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org