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


##########
modules/transactions/src/test/java/org/apache/ignite/internal/tx/AbstractLockManagerTest.java:
##########
@@ -1125,6 +1126,78 @@ public void testAcquireLockAfterFail() {
         assertThat(f, willCompleteSuccessfully());
     }
 
+    @Test
+    public void testFailWaiter() {
+        UUID older = TestTransactionIds.newTransactionId();
+        UUID newer = TestTransactionIds.newTransactionId();
+
+        CompletableFuture<Lock> fut1 = lockManager.acquire(newer, lockKey(), 
X);
+        assertTrue(fut1.isDone());
+
+        // Currently only S locks are allowed to wait.
+        CompletableFuture<Lock> fut2 = lockManager.acquire(older, lockKey(), 
S);
+        assertFalse(fut2.isDone());
+
+        // Should do nothing.
+        lockManager.failAllWaiters(newer, new Exception());
+        assertFalse(fut2.isDone());
+
+        lockManager.failAllWaiters(older, new Exception("test"));
+        assertThat(fut2, willThrowWithCauseOrSuppressed(Exception.class, 
"test"));
+
+        lockManager.releaseAll(older);
+        lockManager.releaseAll(newer);
+    }
+
+    @Test
+    public void testFailWaiter2() {
+        UUID tx1 = TestTransactionIds.newTransactionId();
+        UUID tx2 = TestTransactionIds.newTransactionId();
+        UUID tx3 = TestTransactionIds.newTransactionId();
+
+        CompletableFuture<Lock> fut1 = lockManager.acquire(tx1, lockKey(), S);
+        assertTrue(fut1.isDone());
+
+        CompletableFuture<Lock> fut2 = lockManager.acquire(tx2, lockKey(), S);
+        assertTrue(fut2.isDone());
+
+        CompletableFuture<Lock> fut3 = lockManager.acquire(tx3, lockKey(), S);
+        assertTrue(fut3.isDone());
+
+        CompletableFuture<Lock> fut4 = lockManager.acquire(tx2, lockKey(), X);
+        assertFalse(fut4.isDone());
+
+        lockManager.releaseAll(tx3);
+
+        lockManager.failAllWaiters(tx2, new Exception());
+
+        lockManager.releaseAll(tx2);

Review Comment:
   The test chechs that failing already invalidated waiter does nothing bad.
   Added the comment.



##########
modules/transactions/src/test/java/org/apache/ignite/internal/tx/AbstractLockManagerTest.java:
##########
@@ -1125,6 +1126,78 @@ public void testAcquireLockAfterFail() {
         assertThat(f, willCompleteSuccessfully());
     }
 
+    @Test
+    public void testFailWaiter() {
+        UUID older = TestTransactionIds.newTransactionId();
+        UUID newer = TestTransactionIds.newTransactionId();
+
+        CompletableFuture<Lock> fut1 = lockManager.acquire(newer, lockKey(), 
X);
+        assertTrue(fut1.isDone());
+
+        // Currently only S locks are allowed to wait.
+        CompletableFuture<Lock> fut2 = lockManager.acquire(older, lockKey(), 
S);
+        assertFalse(fut2.isDone());
+
+        // Should do nothing.
+        lockManager.failAllWaiters(newer, new Exception());
+        assertFalse(fut2.isDone());
+
+        lockManager.failAllWaiters(older, new Exception("test"));
+        assertThat(fut2, willThrowWithCauseOrSuppressed(Exception.class, 
"test"));
+
+        lockManager.releaseAll(older);
+        lockManager.releaseAll(newer);
+    }
+
+    @Test
+    public void testFailWaiter2() {
+        UUID tx1 = TestTransactionIds.newTransactionId();
+        UUID tx2 = TestTransactionIds.newTransactionId();
+        UUID tx3 = TestTransactionIds.newTransactionId();
+
+        CompletableFuture<Lock> fut1 = lockManager.acquire(tx1, lockKey(), S);
+        assertTrue(fut1.isDone());
+
+        CompletableFuture<Lock> fut2 = lockManager.acquire(tx2, lockKey(), S);
+        assertTrue(fut2.isDone());
+
+        CompletableFuture<Lock> fut3 = lockManager.acquire(tx3, lockKey(), S);
+        assertTrue(fut3.isDone());
+
+        CompletableFuture<Lock> fut4 = lockManager.acquire(tx2, lockKey(), X);
+        assertFalse(fut4.isDone());
+
+        lockManager.releaseAll(tx3);
+
+        lockManager.failAllWaiters(tx2, new Exception());
+
+        lockManager.releaseAll(tx2);

Review Comment:
   The test checks that failing already invalidated waiter does nothing bad.
   Added the comment.



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