Denis, the txn timeout works in the code as long as it happens before commit
is called.
I am thinking if its in committing state, it does not honor timeout.
When the framework calls the checkValid() method in IgniteTxLocalAdapter, it
makes a call to the below
if (remainingTime() == -1 && setRollbackOnly())
throw new IgniteTxTimeoutCheckedException("Cache transaction
timed out " +
"(was rolled back automatically): " + this);
setRollbackOnly() calls state(MARKED_ROLLBACK)
and here I see that it will only return true if it was in one of the below
states
case MARKED_ROLLBACK: {
valid = prev == ACTIVE || prev == PREPARING || prev ==
PREPARED;
break;
}
So if it was in COMMITTING, we would not throw a Txn Timeout exception. Is
this correct?
here is the sample code from our project, we maintain an
orderUpdateLossPrevention cache in case of node failures when primary node
fails before it write behinds the entry to the DB Store. if the write behind
finishes, we remove the entry.
First TXN that updates a transaction cache
(orderUpdateLossPrevention.put(order.getOrderKey(), order)) along with other
caches (all transactional)
Transaction tx = null;
try {
if (txns == null)
txns = ignite.transactions();
tx=ignite.transactions().txStart(TransactionConcurrency.OPTIMISTIC,
TransactionIsolation.SERIALIZABLE);
tx.timeout(10*1000);
for (OrderHolder oh : orderHolderList) {
Order order = oh.getOrder();
if(order!=null){
OrderHelper.saveOrder(order);
orderUpdateLossPrevention.put(order.getOrderKey(), order);
}
}
// more code
tx.commit(); // the thread hangs here forever, because some other thread on
some other node is doing the below...stuck on write behind.
Second Transaction where the same entry is removed when the writebehind is
finished. its a part of the method call from CacheStore writeAll().
IgniteTransactions txns = null;
Transaction tx = null;
Ignite ignite = Ignition.ignite(Global.DATA_GRID_NAME);
try {
if (txns == null)
txns = ignite.transactions();
tx=ignite.transactions().txStart(TransactionConcurrency.OPTIMISTIC,
TransactionIsolation.SERIALIZABLE);
tx.timeout(2*1000);
orderUpdateLossPreventionCache.remove(entry.getKey());
tx.commit();
} catch (IgniteException e) {
logger.error("Received IgniteException - rolling back transaction", e);
tx.rollback();
throw e;
}
--
View this message in context:
http://apache-ignite-users.70518.x6.nabble.com/transaction-not-timing-out-tp5540p5725.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.