tkalkirill commented on code in PR #3409:
URL: https://github.com/apache/ignite-3/pull/3409#discussion_r1524308145


##########
modules/storage-page-memory/src/main/java/org/apache/ignite/internal/storage/pagememory/index/AbstractPageMemoryIndexStorage.java:
##########
@@ -368,7 +368,7 @@ private boolean advanceIfNeededBusy() throws 
IgniteInternalCheckedException {
         }
     }
 
-    protected <V> V busy(Supplier<V> supplier) {
+    protected <T> T busy(Supplier<T> supplier) {

Review Comment:
   Meow



##########
modules/storage-page-memory/src/main/java/org/apache/ignite/internal/storage/pagememory/mv/ScanVersionsCursor.java:
##########
@@ -63,34 +63,42 @@ public void close() {
 
     @Override
     public boolean hasNext() {
-        if (hasNext != null) {
-            return hasNext;
-        }
+        return storage.busy(() -> {
+            storage.throwExceptionIfStorageNotInRunnableState();
 
-        assert 
AbstractPageMemoryMvPartitionStorage.rowIsLocked(versionChain.rowId());
+            if (hasNext != null) {
+                return hasNext;
+            }
 
-        hasNext = (nextLink != NULL_LINK);
+            assert 
AbstractPageMemoryMvPartitionStorage.rowIsLocked(versionChain.rowId());
 
-        if (hasNext) {
-            currentRowVersion = storage.readRowVersion(nextLink, 
ALWAYS_LOAD_VALUE);
+            hasNext = (nextLink != NULL_LINK);
 
-            nextLink = currentRowVersion.nextLink();
-        }
+            if (hasNext) {
+                currentRowVersion = storage.readRowVersion(nextLink, 
ALWAYS_LOAD_VALUE);
+
+                nextLink = currentRowVersion.nextLink();
+            }
 
-        return hasNext;
+            return hasNext;
+        });
     }
 
     @Override
     public ReadResult next() {
-        assert 
AbstractPageMemoryMvPartitionStorage.rowIsLocked(versionChain.rowId());
+        return storage.busy(() -> {

Review Comment:
   Same



##########
modules/storage-rocksdb/src/main/java/org/apache/ignite/internal/storage/rocksdb/RocksDbMvPartitionStorage.java:
##########
@@ -848,16 +848,20 @@ protected ReadResult decodeEntry(byte[] key, byte[] 
value) {
 
                 @Override
                 public boolean hasNext() {
-                    assert rowIsLocked(rowId);
+                    return busy(() -> {

Review Comment:
   Same



##########
modules/storage-rocksdb/src/main/java/org/apache/ignite/internal/storage/rocksdb/RocksDbMvPartitionStorage.java:
##########
@@ -848,16 +848,20 @@ protected ReadResult decodeEntry(byte[] key, byte[] 
value) {
 
                 @Override
                 public boolean hasNext() {
-                    assert rowIsLocked(rowId);
+                    return busy(() -> {
+                        assert rowIsLocked(rowId);

Review Comment:
   ```suggestion
                           assert rowIsLocked(rowId) : "rowId=" + rowId + ", " 
+ createStorageInfo();
   ```



##########
modules/storage-page-memory/src/main/java/org/apache/ignite/internal/storage/pagememory/mv/ScanVersionsCursor.java:
##########
@@ -63,34 +63,42 @@ public void close() {
 
     @Override
     public boolean hasNext() {
-        if (hasNext != null) {
-            return hasNext;
-        }
+        return storage.busy(() -> {

Review Comment:
   Not long ago I heard that `busyLock` cause performance degradation.
   Maybe we shouldn't use them in the cursor?
   Maybe it's enough to check some field?



##########
modules/storage-rocksdb/src/main/java/org/apache/ignite/internal/storage/rocksdb/RocksDbMvPartitionStorage.java:
##########
@@ -848,16 +848,20 @@ protected ReadResult decodeEntry(byte[] key, byte[] 
value) {
 
                 @Override
                 public boolean hasNext() {
-                    assert rowIsLocked(rowId);
+                    return busy(() -> {
+                        assert rowIsLocked(rowId);
 
-                    return super.hasNext();
+                        return super.hasNext();
+                    });
                 }
 
                 @Override
                 public ReadResult next() {
-                    assert rowIsLocked(rowId);
+                    return busy(() -> {
+                        assert rowIsLocked(rowId);

Review Comment:
   ```suggestion
                           assert rowIsLocked(rowId) : "rowId=" + rowId + ", " 
+ createStorageInfo();
   ```



##########
modules/storage-rocksdb/src/main/java/org/apache/ignite/internal/storage/rocksdb/RocksDbMvPartitionStorage.java:
##########
@@ -848,16 +848,20 @@ protected ReadResult decodeEntry(byte[] key, byte[] 
value) {
 
                 @Override
                 public boolean hasNext() {
-                    assert rowIsLocked(rowId);
+                    return busy(() -> {
+                        assert rowIsLocked(rowId);
 
-                    return super.hasNext();
+                        return super.hasNext();
+                    });
                 }
 
                 @Override
                 public ReadResult next() {
-                    assert rowIsLocked(rowId);
+                    return busy(() -> {

Review Comment:
   same



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