denis-chudov commented on code in PR #2720:
URL: https://github.com/apache/ignite-3/pull/2720#discussion_r1406026214


##########
modules/table/src/main/java/org/apache/ignite/internal/table/RecordBinaryViewImpl.java:
##########
@@ -430,7 +431,18 @@ public CompletableFuture<Void> streamData(Publisher<Tuple> 
publisher, @Nullable
 
         var partitioner = new 
TupleStreamerPartitionAwarenessProvider(rowConverter.registry(), 
tbl.partitions());
         StreamerBatchSender<Tuple, Integer> batchSender = (partitionId, items) 
-> withSchemaSync(null, (schemaVersion) -> {
-            return this.tbl.upsertAll(mapToBinary(items, schemaVersion, 
false), partitionId);
+            System.out.println("BEGIN " + partitionId);
+            return this.tbl.upsertAll(mapToBinary(items, schemaVersion, 
false), partitionId).thenAccept(new Consumer<Void>() {
+                @Override
+                public void accept(Void unused) {
+                    try {
+                        Thread.sleep(500);
+                    } catch (InterruptedException e) {
+                        throw new RuntimeException(e);
+                    }
+                    System.out.println("END " + partitionId);
+                }
+            });

Review Comment:
   Please remove the debug code.



##########
modules/table/src/testFixtures/java/org/apache/ignite/internal/table/TxAbstractTest.java:
##########
@@ -69,6 +69,7 @@
 import org.apache.ignite.internal.tx.TxManager;
 import org.apache.ignite.internal.tx.TxState;
 import org.apache.ignite.internal.tx.TxStateMeta;
+import org.apache.ignite.internal.tx.Waiter;

Review Comment:
   unused import



##########
modules/transactions/src/main/java/org/apache/ignite/internal/tx/impl/HeapLockManager.java:
##########
@@ -646,6 +820,8 @@ private void notifyLocked() {
             } else {
                 assert lockMode != null;
 
+                // TODO FIXME complete async if waiters are in queue to 
prevent to prevent thread pool starvation.

Review Comment:
   we need a ticket here



##########
modules/table/src/main/java/org/apache/ignite/internal/table/distributed/replicator/PartitionReplicaListener.java:
##########
@@ -1078,7 +1078,7 @@ private CompletableFuture<List<BinaryRow>> 
processScanRetrieveBatchAction(
 
         IgniteUuid cursorId = new IgniteUuid(txId, request.scanId());
 
-        return lockManager.acquire(txId, new LockKey(tableId()), LockMode.S)
+        return lockManager.parentLockManager().acquire(txId, new 
LockKey(tableId()), LockMode.S)

Review Comment:
   Assuming that parentLockManager is nullable, it's not safe to call it 
everywhere like that.



##########
modules/table/src/testFixtures/java/org/apache/ignite/internal/table/TxAbstractTest.java:
##########
@@ -82,9 +83,11 @@
 import org.apache.ignite.tx.TransactionException;
 import org.apache.ignite.tx.TransactionOptions;
 import org.jetbrains.annotations.Nullable;
+import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.Disabled;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.Mockito;

Review Comment:
   unused imports



##########
modules/transactions/src/test/java/org/apache/ignite/internal/tx/HeapUnboundedLockManagerTest.java:
##########
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.tx;
+
+import org.apache.ignite.internal.tx.impl.HeapUnboundedLockManager;
+import org.apache.ignite.internal.tx.impl.WaitDieDeadlockPreventionPolicy;
+
+/**
+ * Test class for {@link HeapUnboundedLockManager}.
+ */
+public class HeapUnboundedLockManagerTest extends AbstractLockManagerTest {

Review Comment:
   Could you please do the same to the descendants of AbstractLockingTest?



##########
modules/transactions/src/main/java/org/apache/ignite/internal/tx/LockManager.java:
##########
@@ -76,13 +86,21 @@ public interface LockManager {
      * @return The waiter.
      */
     @TestOnly
-    public Waiter waiter(LockKey key, UUID txId);
+    Waiter waiter(LockKey key, UUID txId);
 
     /**
      * Returns {@code true} if no locks have been held.
      *
      * @return {@code true} if no locks have been held.
      */
     @TestOnly
-    public boolean isEmpty();
+    boolean isEmpty();
+
+    /**
+     * Get parent lock manager.
+     *
+     * @return Parent lock manager in lock hierarchy.
+     */
+    @Nullable
+    LockManager parentLockManager();

Review Comment:
   This brings unnecessary complexity to the interface, taking into account the 
changes you made in PartitionReplicaListener. Moreover, it can't be safely 
called assuming it is nullable. Why should anyone care is there any parent or 
not?



##########
modules/transactions/src/main/java/org/apache/ignite/internal/tx/impl/HeapLockManager.java:
##########
@@ -149,7 +263,30 @@ public Iterator<Lock> locks(UUID txId) {
      * @param key The key.
      */
     private LockState lockState(LockKey key) {
-        return locks.computeIfAbsent(key, k -> new 
LockState(deadlockPreventionPolicy, delayedExecutor));
+        int h = spread(key.hashCode());
+        int index = h & (slots.length - 1);
+
+        LockState[] res = new LockState[1];
+
+        locks.compute(key, (k, v) -> {
+            if (v == null) {
+                if (empty.isEmpty()) {
+                    res[0] = slots[index];
+                } else {
+                    v = empty.poll();
+                    v.markedForRemove = false;
+                    v.key = k;
+                    res[0] = v;
+                }
+            } else {
+                res[0] = v;
+                // assert v.waitersCount() == 1;

Review Comment:
   is it still needed?



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