ascherbakoff commented on code in PR #4540:
URL: https://github.com/apache/ignite-3/pull/4540#discussion_r1812149089


##########
modules/transactions/src/main/java/org/apache/ignite/internal/tx/impl/HeapLockManager.java:
##########
@@ -158,14 +162,22 @@ public HeapLockManager(DeadlockPreventionPolicy 
deadlockPreventionPolicy, int ma
         }
 
         slots = tmp; // Atomic init.
-
-        parentLockManager.listen(LockEvent.LOCK_CONFLICT, 
parentLockConflictListener);
     }
 
     @Override
     public CompletableFuture<Lock> acquire(UUID txId, LockKey lockKey, 
LockMode lockMode) {
-        if (lockKey.contextId() == null) { // Treat this lock as a hierarchy 
lock.
-            return parentLockManager.acquire(txId, lockKey, lockMode);
+        if (lockKey.contextId() == null) { // Treat this lock as a 
hierarchy(coarse) lock.
+            // Try fast path.
+            CoarseLockState state = coarseMap.get(lockKey);
+
+            if (state == null) {
+                // Atomically init state.
+                CoarseLockState s = new CoarseLockState(lockKey);
+                CoarseLockState cur = coarseMap.putIfAbsent(lockKey, s);
+                state = (cur == null ? s : cur);

Review Comment:
   They are not the same.
   computeIfAbsent will take a lock on closure computation.
   putIfAbsent can work without taking a lock.



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