@Override public void run() { IgniteCache<Integer, Integer> cache = node.cache(DEFAULT_CACHE_NAME); try { try (Transaction tx = node.transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { cache.put(key, key); info(">>> Locked key, waiting for latch: " + key); commitLatch.await(); tx.commit(); } } catch (CacheException e) { info("Failed to run tx for key [key=" + key + ", e=" + e + ']'); } catch (InterruptedException ignored) { Thread.currentThread().interrupt(); info("Got interrupted while waiting for commit latch: " + key); } } }, 1));
@Override public void run() { IgniteCache<Integer, Integer> cache = node.cache(DEFAULT_CACHE_NAME); try { try (Transaction tx = node.transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { cache.put(key, key); commitLatch.await(); tx.commit(); } } catch (CacheException e) { info("Failed to run tx for key [key=" + key + ", e=" + e + ']'); } catch (InterruptedException ignored) { Thread.currentThread().interrupt(); info("Got interrupted while waiting for commit latch: " + key); } } }, 1));
Transaction tx = g.transactions().txStart(PESSIMISTIC, REPEATABLE_READ); tx = g.transactions().txStart(PESSIMISTIC, REPEATABLE_READ);
/** * @throws Exception If failed. */ @Test public void testSystemTxInsideUserTx() throws Exception { Assume.assumeFalse("https://issues.apache.org/jira/browse/IGNITE-10473", MvccFeatureChecker.forcedMvcc()); IgniteKernal ignite = (IgniteKernal)grid(0); IgniteCache<Object, Object> jcache = ignite.cache(DEFAULT_CACHE_NAME); try (Transaction tx = ignite.transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { jcache.get("1"); jcache.put("1", "11"); IgniteInternalCache<Object, Object> utilityCache = ignite.context().cache().utilityCache(); utilityCache.getAndPutIfAbsent("2", "2"); try (GridNearTxLocal itx = utilityCache.txStartEx(PESSIMISTIC, REPEATABLE_READ)) { assertEquals(null, utilityCache.get("1")); assertEquals("2", utilityCache.get("2")); assertEquals(null, utilityCache.get("3")); utilityCache.getAndPut("3", "3"); itx.commit(); } jcache.put("2", "22"); tx.commit(); } checkTransactionsCommitted(); checkEntries(DEFAULT_CACHE_NAME, "1", "11", "2", "22", "3", null); checkEntries(CU.UTILITY_CACHE_NAME, "1", null, "2", "2", "3", "3"); }