You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by "rpuch (via GitHub)" <gi...@apache.org> on 2023/05/02 08:43:58 UTC

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

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


##########
modules/table/src/main/java/org/apache/ignite/internal/table/distributed/SortedIndexLocker.java:
##########
@@ -155,15 +154,15 @@ public CompletableFuture<Lock> locksForInsert(UUID txId, BinaryRow tableRow, Row
 
         BinaryTuplePrefix prefix = BinaryTuplePrefix.fromBinaryTuple(key);
 
-        // find next key
-        Cursor<IndexRow> cursor = storage.scan(prefix, null, SortedIndexStorage.GREATER);
+        // Find next key.
+        PeekCursor<IndexRow> cursor = storage.scan(prefix, null, SortedIndexStorage.GREATER);
 
-        BinaryTuple nextKey;
-        if (cursor.hasNext()) {
-            nextKey = cursor.next().indexColumns();
-        } else { // otherwise INF
-            nextKey = POSITIVE_INF;
-        }
+        //noinspection ResultOfMethodCallIgnored
+        cursor.hasNext();
+
+        // "peek" works the same as "next" when "hasNext" is called. The only difference is that it returns null instead of throwing
+        // an exception, if nothing is found.
+        BinaryTuple nextKey = indexKey(cursor.peek());

Review Comment:
   > "peek" works the same as "next" when "hasNext" is called
   
   So I concluded that the code after the change works in the same way as the code before the change. If this is not the case, could you please describe a scenario that would demonstrate a difference?



-- 
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