sergey-chugunov-1985 commented on code in PR #12259:
URL: https://github.com/apache/ignite/pull/12259#discussion_r2262890098


##########
modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTransactionalAbstractMetricsSelfTest.java:
##########
@@ -393,6 +462,62 @@ private void testRollbacks(TransactionConcurrency 
concurrency, TransactionIsolat
         }
     }
 
+    /**
+     * @param concurrency Concurrency control.
+     * @param isolation Isolation level.
+     * @param useClient Use client node as transaction coordinator.
+     * @throws Exception If failed.
+     */
+    private void testDeadlocks(
+        TransactionConcurrency concurrency,
+        TransactionIsolation isolation,
+        boolean useClient
+    ) throws Exception {
+        Ignite ignite = useClient ? client : grid(0);
+
+        IgniteCache<Integer, Integer> cache = ignite.cache(DEFAULT_CACHE_NAME);
+        long txTimeout = 500;
+
+        CountDownLatch key0locked = new CountDownLatch(1);
+        CountDownLatch key1locked = new CountDownLatch(1);
+
+        IgniteInternalFuture<?> fut0 = GridTestUtils.runAsync(() -> {
+            Transaction tx = ignite.transactions().txStart(concurrency, 
isolation, txTimeout, 0);
+
+            cache.put(0, 0);
+
+            key0locked.countDown();
+            key1locked.await();
+
+            cache.put(1, 1);
+        });
+
+        IgniteInternalFuture<?> fut1 = GridTestUtils.runAsync(() -> {
+            Transaction tx = ignite.transactions().txStart(concurrency, 
isolation, txTimeout * 2, 0);
+
+            cache.put(1, 0);
+
+            key1locked.countDown();
+            key0locked.await();
+
+            cache.put(0, 1);
+
+            tx.commit();
+        });
+
+        try {
+            fut0.get();
+        }
+        catch (Exception ignore) {
+            // Expected.
+        }
+
+        fut1.get();
+
+        for (Ignite g : G.allGrids())
+            assertEquals(g == ignite ? 1 : 0, 
g.transactions().metrics().txRollbacks());

Review Comment:
   Do I understand correctly that we assert `txRollbacks` metrics here because 
we expect a transaction to rollback by a timeout?
   
   If so do we want to add an assertion for `txDeadlocks` metric as well?



-- 
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-unsubscr...@ignite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to