/** * @param cache Cache. * @param startKey Transformer Start key. * @throws Exception If failed. */ private void doTestDeadlocks(IgniteCache cache, Object startKey) throws Exception { try { awaitPartitionMapExchange(); doTestDeadlock(3, true, true, startKey); doTestDeadlock(3, false, false, startKey); doTestDeadlock(3, false, true, startKey); doTestDeadlock(4, true, true, startKey); doTestDeadlock(4, false, false, startKey); doTestDeadlock(4, false, true, startKey); } catch (Throwable e) { U.error(log, "Unexpected exception: ", e); fail(); } finally { if (cache != null) cache.destroy(); } }
/** * @throws Exception If failed. */ @Test public void testDeadlocksPartitionedNear() throws Exception { for (CacheWriteSynchronizationMode syncMode : CacheWriteSynchronizationMode.values()) { doTestDeadlocks(createCache(PARTITIONED, syncMode, true), ORDINAL_START_KEY); doTestDeadlocks(createCache(PARTITIONED, syncMode, true), CUSTOM_START_KEY); } }
/** * @throws Exception If failed. */ @Test public void testDeadlocksPartitionedNearTxOnPrimary() throws Exception { for (CacheWriteSynchronizationMode syncMode : CacheWriteSynchronizationMode.values()) { doTestDeadlocksTxOnPrimary(createCache(PARTITIONED, syncMode, true), ORDINAL_START_KEY); doTestDeadlocksTxOnPrimary(createCache(PARTITIONED, syncMode, true), CUSTOM_START_KEY); } }
final List<List<Object>> keySets = generateKeys(txCnt, startKey, !lockPrimaryFirst, txOnPrimary); U.error(null, "Unexpected exception", e); fail(); assertNotNull("Failed to detect deadlock", deadlockE); checkAllTransactionsCompleted(involvedKeys, NODES_CNT * 2, CACHE_NAME); assertTrue(msg.contains( "[txId=" + tx.xidVersion() + ", nodeId=" + tx.nodeId() + ", threadId=" + tx.threadId() + ']')); assertTrue(msg.contains("[key=" + key + ", cache=" + CACHE_NAME + ']')); else assertFalse(msg.contains("[key=" + key));
/** * @param cacheMode Cache mode. * @param syncMode Write sync mode. * @param near Near. * @return Created cache. */ @SuppressWarnings("unchecked") private IgniteCache createCache(CacheMode cacheMode, CacheWriteSynchronizationMode syncMode, boolean near) throws IgniteInterruptedCheckedException, InterruptedException { awaitPartitionMapExchange(); int minorTopVer = grid(0).context().discovery().topologyVersionEx().minorTopologyVersion(); CacheConfiguration ccfg = defaultCacheConfiguration(); ccfg.setName(CACHE_NAME); ccfg.setCacheMode(cacheMode); ccfg.setBackups(1); ccfg.setNearConfiguration(near ? new NearCacheConfiguration() : null); ccfg.setWriteSynchronizationMode(syncMode); IgniteCache cache = ignite(0).createCache(ccfg); if (near) { for (int i = 0; i < NODES_CNT; i++) { Ignite client = ignite(i + NODES_CNT); assertTrue(client.configuration().isClientMode()); client.createNearCache(ccfg.getName(), new NearCacheConfiguration<>()); } } waitForLateAffinityAssignment(minorTopVer); return cache; }
/** * @param cache Cache. * @param startKey Start key. */ private void doTestDeadlocksTxOnPrimary(IgniteCache cache, Object startKey) { try { awaitPartitionMapExchange(); doTestDeadlock(3, false, false, startKey, true); doTestDeadlock(4, false, false, startKey, true); } catch (Throwable e) { U.error(log, "Unexpected exception: ", e); //TODO "if" statement will be removed after fixing https://issues.apache.org/jira/browse/IGNITE-6445 if (!e.getMessage().equals("Failed to detect deadlock")) fail(); } finally { if (cache != null) cache.destroy(); } }
/** * @throws Exception If failed. */ @Test public void testDeadlocksPartitioned() throws Exception { for (CacheWriteSynchronizationMode syncMode : CacheWriteSynchronizationMode.values()) { doTestDeadlocks(createCache(PARTITIONED, syncMode, false), ORDINAL_START_KEY); doTestDeadlocks(createCache(PARTITIONED, syncMode, false), CUSTOM_START_KEY); } }
/** * @throws Exception If failed. */ @Test public void testDeadlocksReplicated() throws Exception { for (CacheWriteSynchronizationMode syncMode : CacheWriteSynchronizationMode.values()) { doTestDeadlocks(createCache(REPLICATED, syncMode, false), ORDINAL_START_KEY); doTestDeadlocks(createCache(REPLICATED, syncMode, false), CUSTOM_START_KEY); } }