You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by bintisepaha <bi...@tudor.com> on 2016/06/08 20:01:10 UTC
transaction not timing out
Hi,
We are using txns as below in code
tx=ignite.transactions().txStart(TransactionConcurrency.OPTIMISTIC,
TransactionIsolation.SERIALIZABLE);
tx.timeout(10*1000);
The timeout is set to 10 seconds. However, we can see that one of the
threads is stuck acquiring locks for over an hour stalling some nodes in the
grid for a long time. See stack trace below. Why does it not timeout? This
is ignite 1.6.0. We tested timeout with simple code by using a 5 second
timeout and thread.sleep for 1 seconds and it times out. is the behavior any
different if it is stuck in acquiring locks?
Name: pub-#10%DataGridServer-Staging%
State: WAITING on
org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxFinishFuture@3a3bec80
Total blocked: 14 Total waited: 211
Stack trace:
sun.misc.Unsafe.park(Native Method)
java.util.concurrent.locks.LockSupport.park(Unknown Source)
java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(Unknown
Source)
java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireShared(Unknown
Source)
java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireShared(Unknown
Source)
org.apache.ignite.internal.util.future.GridFutureAdapter.get0(GridFutureAdapter.java:157)
org.apache.ignite.internal.util.future.GridFutureAdapter.get(GridFutureAdapter.java:117)
org.apache.ignite.internal.processors.cache.transactions.TransactionProxyImpl.commit(TransactionProxyImpl.java:261)
com.tudor.datagridI.server.tradegen.OrderHolderSaveRunnable.run(OrderHolderSaveRunnable.java:135)
org.apache.ignite.internal.processors.closure.GridClosureProcessor$C4V2.execute(GridClosureProcessor.java:2206)
org.apache.ignite.internal.processors.job.GridJobWorker$2.call(GridJobWorker.java:509)
org.apache.ignite.internal.util.IgniteUtils.wrapThreadLoader(IgniteUtils.java:6459)
org.apache.ignite.internal.processors.job.GridJobWorker.execute0(GridJobWorker.java:503)
org.apache.ignite.internal.processors.job.GridJobWorker.body(GridJobWorker.java:456)
org.apache.ignite.internal.util.worker.GridWorker.run(GridWorker.java:110)
org.apache.ignite.internal.processors.job.GridJobProcessor.processJobExecuteRequest(GridJobProcessor.java:1161)
org.apache.ignite.internal.processors.job.GridJobProcessor$JobExecutionListener.onMessage(GridJobProcessor.java:1766)
org.apache.ignite.internal.managers.communication.GridIoManager.invokeListener(GridIoManager.java:1219)
org.apache.ignite.internal.managers.communication.GridIoManager.processRegularMessage0(GridIoManager.java:847)
org.apache.ignite.internal.managers.communication.GridIoManager.access$1700(GridIoManager.java:105)
org.apache.ignite.internal.managers.communication.GridIoManager$5.run(GridIoManager.java:810)
java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
java.lang.Thread.run(Unknown Source)
--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/transaction-not-timing-out-tp5540.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.
Re: transaction not timing out
Posted by Denis Magda <dm...@gridgain.com>.
Hi Binti,
I’ll take a look and reply soon, sorry for delay.
—
Denis
> On Jun 22, 2016, at 8:28 PM, bintisepaha <bi...@tudor.com> wrote:
>
> Denis, did you get a chance to look at this?
> any help will be greatly appreciated.
>
> Thanks,
> Binti
>
>
>
> --
> View this message in context: http://apache-ignite-users.70518.x6.nabble.com/transaction-not-timing-out-tp5540p5805.html
> Sent from the Apache Ignite Users mailing list archive at Nabble.com.
Re: transaction not timing out
Posted by bintisepaha <bi...@tudor.com>.
Denis, did you get a chance to look at this?
any help will be greatly appreciated.
Thanks,
Binti
--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/transaction-not-timing-out-tp5540p5805.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.
Re: transaction not timing out
Posted by bintisepaha <bi...@tudor.com>.
Update - we started using pessimistic txns now and it looks much better. so
we can close this thread now.
raised another issue here
http://apache-ignite-users.70518.x6.nabble.com/IgniteCompute-broadcast-stuck-td7255.html
Thanks,
Binti
--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/transaction-not-timing-out-tp5540p7256.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.
Re: transaction not timing out
Posted by bintisepaha <bi...@tudor.com>.
Val, we are still seeing this issue from time to time.
Transactions are hung during commit() . we do not use write-through so DB
will not cause slowness for us. I understand that prior to commit, locks
were acquired in prepare phase, so if prepare is successful, then why would
commit hang? I am assuming within the commit() call, the first phase of
prepare won't even complete if locks were not acquired, in that case we have
seen transaction optimistic exception various times and on retry the txn
completes successfully.
in the case where it hangs on commit(), we are unable to figure out what
resource it is blocked on?
Also, to free up the resource and see how the cluster behaves, if we kill
any of the offending nodes then the entire cluster hangs.
we use full_sync mode for caches, is there any setting that we need to use
with that? most of our distributed caches have a config similar to below
Any help is very much appreciated.
<bean id="tradeOrderCache"
class="org.apache.ignite.configuration.CacheConfiguration">
<property name="name" value="TradeOrder" />
<property name="readThrough" value="True" />
<property name="writeThrough" value="True" />
<property name="writeBehindEnabled" value="True" />
<property name="writeBehindFlushFrequency" value="#{5 * 1000}" />
<property name="writeBehindFlushSize" value="0" />
<property name="cacheMode" value="PARTITIONED" />
<property name="atomicityMode" value="TRANSACTIONAL" />
<property name="backups" value="1" />
<property name="startSize" value="#{1 * 1024 * 1024}" />
<property name="rebalanceBatchSize" value="#{2 * 1024 * 1024}"/>
<property name="rebalanceThrottle" value="100"/>
<property name="memoryMode" value="OFFHEAP_TIERED" />
<property name="offHeapMaxMemory" value="#{10 * 1024L * 1024L * 1024L}" />
<property name="cacheStoreFactory">
<bean class="javax.cache.configuration.FactoryBuilder$SingletonFactory">
<constructor-arg>
<ref bean="tradeOrderCacheStore" />
</constructor-arg>
</bean>
</property>
<property name="writeSynchronizationMode" value="FULL_SYNC" />
<property name="statisticsEnabled" value="true" />
<property name="queryEntities">
<list>
<bean id="tradeOrderQueryEntity"
class="org.apache.ignite.cache.QueryEntity">
<property name="keyType"
value="com.tudor.datagridI.client.data.trading.OrderKey" />
<property name="valueType"
value="com.tudor.datagridI.client.data.trading.TradeOrder" />
<property name="fields">
<map>
<entry key="traderId" value="java.lang.Integer" />
<entry key="orderId" value="java.lang.Integer" />
<entry key="insIid" value="java.lang.Integer" />
<entry key="settlement" value="java.util.Date" />
<entry key="clearAgent" value="java.lang.String" />
<entry key="strategy" value="java.lang.String" />
<entry key="pvId" value="java.lang.Integer" />
<entry key="pvDate" value="java.util.Date" />
<entry key="linkId" value="java.lang.Integer" />
</map>
</property>
<property name="indexes">
<list>
<bean class="org.apache.ignite.cache.QueryIndex">
<constructor-arg>
<list>
<value>traderId</value>
<value>orderId</value>
</list>
</constructor-arg>
<constructor-arg>
<value>SORTED</value>
</constructor-arg>
<property name="name" value="tradeOrder_key_index" />
</bean>
</list>
</property>
</bean>
</list>
</property>
<property name="affinity">
<bean
class="org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction">
<property name="excludeNeighbors" value="true" />
</bean>
</property>
</bean>
--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/transaction-not-timing-out-tp5540p7187.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.
Re: transaction not timing out
Posted by vkulichenko <va...@gmail.com>.
Yes, prepare phase happens within the commit() and the commit phase start
only after prepare is finished.
The commit phase updates the data which includes write-through to the
database. So if commit takes a lot of time due to issues with the database,
we can't rollback without causing data inconsistency.
-Val
--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/transaction-not-timing-out-tp5540p6685.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.
Re: transaction not timing out
Posted by bintisepaha <bi...@tudor.com>.
Does prepare happen as part of commit() call?
As a user we only call commit(). so the txn should get to commit only if
prepare succeeded - right?
once in prepare mode, locks are acquired, no other txn should be able to
update these entries. then the txn goes to goes to commit() once locks are
acquired - what is holding it from updating the entries?
--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/transaction-not-timing-out-tp5540p6638.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.
Re: transaction not timing out
Posted by vkulichenko <va...@gmail.com>.
Binti,
Locks are acquired on prepare phase, not on commit phase. In case of
optimistic transaction both phases happen one after another in a single
'tx.commit()' call.
Prepare phase is not a problem, because it's easy to detect collisions and
throw optimistic exception when all locks are not acquired yet. But on the
commit phase you actually update the data, so, as was mentioned before,
there is no reliable way to rollback. Basically, if you update one node,
then throw exception on the second and release locks, you get inconsistent
data.
-Val
--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/transaction-not-timing-out-tp5540p6579.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.
Re: transaction not timing out
Posted by bintisepaha <bi...@tudor.com>.
What I mean is why would commit() hang? we use write behind, so cache store
updates are asynchronous (I doubt it would be an issue in our case)
during the commit() phase, if locks were not acquired on txn entries, we
would receive txn optimistic exception, we do receive that sometimes, but in
some other cases, what could be the possible reason for commit() to hang?
thread dump below for the hanging thread
Name: pub-#2%DataGridServer-Staging%
State: WAITING on
org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxFinishFuture@6120e8e8
Total blocked: 11 Total waited: 584
Stack trace:
sun.misc.Unsafe.park(Native Method)
java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:836)
java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireShared(AbstractQueuedSynchronizer.java:967)
java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireShared(AbstractQueuedSynchronizer.java:1283)
org.apache.ignite.internal.util.future.GridFutureAdapter.get0(GridFutureAdapter.java:155)
org.apache.ignite.internal.util.future.GridFutureAdapter.get(GridFutureAdapter.java:115)
org.apache.ignite.internal.processors.cache.transactions.TransactionProxyImpl.commit(TransactionProxyImpl.java:261)
com.tudor.datagridI.server.tradegen.OrderHolderSaveRunnable.run(OrderHolderSaveRunnable.java:268)
org.apache.ignite.internal.processors.closure.GridClosureProcessor$C4.execute(GridClosureProcessor.java:1879)
org.apache.ignite.internal.processors.job.GridJobWorker$2.call(GridJobWorker.java:509)
org.apache.ignite.internal.util.IgniteUtils.wrapThreadLoader(IgniteUtils.java:6397)
org.apache.ignite.internal.processors.job.GridJobWorker.execute0(GridJobWorker.java:503)
org.apache.ignite.internal.processors.job.GridJobWorker.body(GridJobWorker.java:456)
org.apache.ignite.internal.util.worker.GridWorker.run(GridWorker.java:110)
org.apache.ignite.internal.processors.job.GridJobProcessor.processJobExecuteRequest(GridJobProcessor.java:1166)
org.apache.ignite.internal.processors.job.GridJobProcessor$JobExecutionListener.onMessage(GridJobProcessor.java:1770)
org.apache.ignite.internal.managers.communication.GridIoManager.processRegularMessage0(GridIoManager.java:821)
org.apache.ignite.internal.managers.communication.GridIoManager.access$1600(GridIoManager.java:103)
org.apache.ignite.internal.managers.communication.GridIoManager$5.run(GridIoManager.java:784)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java)
java.lang.Thread.run(Thread.java)
--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/transaction-not-timing-out-tp5540p6576.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.
Re: transaction not timing out
Posted by vkulichenko <va...@gmail.com>.
Hi Binti,
bintisepaha wrote
> I do not understand why commit() is unable to finish. In an
> optimistic/serializable transaction, it should not even reach the commit
> phase using the 2 phase protocol. If the txn reached he commit() phase and
> then it was successful in acquiring all the locks it needs and it should
> not stall.
I'm not sure why the hang itself happens in your case but can you clarify
what you mean by "it should not even reach the commit phase using the 2
phase protocol"? Commit phase is the second one, that's when actual updates
happen, including CacheStore updates. You will very likely reach this phase
and any exceptions after can lead to inconsistent data, that's why Ignite
avoids them.
bintisepaha wrote
> Another related question, is it not recommended to start an ignite
> transaction from the client? what happens if the client crashes in the
> middle of the transaction? With pessimistic txn on client side, and if I
> kill the client in the middle of the txn, those keys that it had locks on
> are never released. now that same entry n cache cannot be updated by any
> process. how do I get out of such a situation.
This is the most common use case. If a node (can be either client or server,
doesn't matter) that executes the transaction fails, all locks acquired by
this transaction are released. If you observe different behavior, please
provide the reproducer.
-Val
--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/transaction-not-timing-out-tp5540p6574.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.
Re: transaction not timing out
Posted by bintisepaha <bi...@tudor.com>.
Hi,
Trying to find an answer to the above.
I do not understand why commit() is unable to finish. In an
optimistic/serializable transaction, it should not even reach the commit
phase using the 2 phase protocol. If the txn reached he commit() phase and
then it was successful in acquiring all the locks it needs and it should not
stall.
Another related question, is it not recommended to start an ignite
transaction from the client? what happens if the client crashes in the
middle of the transaction? With pessimistic txn on client side, and if I
kill the client in the middle of the txn, those keys that it had locks on
are never released. now that same entry n cache cannot be updated by any
process. how do I get out of such a situation.
However, in optimistic locking this does not happen until commit, so it
behaves differently. But what if the client crashes during commit phase? i
also cannot use optimistic in this scenario.
Thanks,
Binti
--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/transaction-not-timing-out-tp5540p6557.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.
Re: transaction not timing out
Posted by bintisepaha <bi...@tudor.com>.
If in any case commit() is unable to finish, how can we catch that? in an
optimistic transaction, it should not even reach the commit phase using the
2 phase protocol.
--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/transaction-not-timing-out-tp5540p6241.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.
Re: transaction not timing out
Posted by Alexey Goncharuk <al...@gmail.com>.
Hi,
As Dmitriy pointed out, there is no a reliable way to timeout a transaction
once the commit phase has begun.
If there is a chance that your cache store may stall for unpredictable
amount of time, this should be handled within the store and possibly throw
an exception, but this will result in heuristic exception and possibly
inconsistent data.
Re: transaction not timing out
Posted by Denis Magda <dm...@gridgain.com>.
Hi Binti,
In case of writeAll the locks for keys are acquired sequentially. To avoid deadlocks you need to use an ordered data structure like TreeSet the will hold the keys.
Alex G. can you join the thread and provide your thoughts on why the timeout is not honored for the discussed transactional mode.
—
Denis
> On Jun 28, 2016, at 1:14 AM, bintisepaha <bi...@tudor.com> wrote:
>
> Denis, We will reproduce with pessismistic/repeatable read next week and
> update you.
> How is writeAll handled by the framework - in a txn?
>
> Was someone able to look at the timeout not being honored while committing?
> What would cause this issue?
>
>
>
> --
> View this message in context: http://apache-ignite-users.70518.x6.nabble.com/transaction-not-timing-out-tp5540p5934.html
> Sent from the Apache Ignite Users mailing list archive at Nabble.com.
Re: transaction not timing out
Posted by bintisepaha <bi...@tudor.com>.
Denis, We will reproduce with pessismistic/repeatable read next week and
update you.
How is writeAll handled by the framework - in a txn?
Was someone able to look at the timeout not being honored while committing?
What would cause this issue?
--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/transaction-not-timing-out-tp5540p5934.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.
Re: transaction not timing out
Posted by Dmitriy Setrakyan <ds...@apache.org>.
On Thu, Jun 23, 2016 at 10:39 PM, Denis Magda <dm...@gridgain.com> wrote:
> Hi Binti,
>
> Probably the issue is related to the fact that you’re working with the
> cache inside of CacheStore.writeAll method. Have you tried to use
> PESSIMISTIC/REPEATABLE_READ mode? Is the situation the same? Please attach
> thread dumps from all the nodes after the hang is reproduced one more time.
>
> In the meanwhile, *Alex G*. or *Sam* as I see in the code of
> IgniteTxManager.commitTx we remove timeout object after a transaction is
> moved into a COMMITTING state
>
> if (tx.timeout() > 0) {
> cctx.time().removeTimeoutObject(tx);
>
> if (log.isDebugEnabled())
> log.debug("Unregistered transaction with timeout processor: " + tx);
> }
>
>
> What is the reason of that behavior? Am I missing something?
>
I think that the main reason must be to prevent failures (even timeout
failures) during the commit phase. Failures during commits may cause data
consistency issues.
>
> —
> Denis
>
> On Jun 17, 2016, at 6:24 PM, bintisepaha <bi...@tudor.com> wrote:
>
> 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
> <http://nabble.com>.
>
>
>
Re: transaction not timing out
Posted by Denis Magda <dm...@gridgain.com>.
Hi Binti,
Probably the issue is related to the fact that you’re working with the cache inside of CacheStore.writeAll method. Have you tried to use PESSIMISTIC/REPEATABLE_READ mode? Is the situation the same? Please attach thread dumps from all the nodes after the hang is reproduced one more time.
In the meanwhile, Alex G. or Sam as I see in the code of IgniteTxManager.commitTx we remove timeout object after a transaction is moved into a COMMITTING state
if (tx.timeout() > 0) {
cctx.time().removeTimeoutObject(tx);
if (log.isDebugEnabled())
log.debug("Unregistered transaction with timeout processor: " + tx);
}
What is the reason of that behavior? Am I missing something?
—
Denis
> On Jun 17, 2016, at 6:24 PM, bintisepaha <bi...@tudor.com> wrote:
>
> 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.
Re: transaction not timing out
Posted by bintisepaha <bi...@tudor.com>.
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.
Re: transaction not timing out
Posted by Denis Magda <dm...@gridgain.com>.
Hi Binti,
Could you share with me a snippet of this code and cache configuration for validation?
Do you set timeout before any operation inside of the transaction is executed? Please try to use the following method setting the timeout - IgniteTransaction.txStart(TransactionConcurrency concurrency, TransactionIsolation isolation, long timeout, int txSize)
—
Denis
> On Jun 16, 2016, at 6:21 PM, bintisepaha <bi...@tudor.com> wrote:
>
> Thanks Denis, did not realize I was creating a new cache with that name with
> default settings. However, this was a test case, I fixed it and I can it
> timing out. The real issue we see in our UAT enivornment is as follows.
>
> All caches are defined as TRANSACTIONAL in the config file.
> But we see one thread on the client side that invokes a compute on the
> server node, stuck on the below.
> Its at commit and it never times out. In my test case, I cannot reproduce it
> because I see exactly what you are describing, a deadlock free scenario.
>
> When this thread is hung, its hung forever, causing the client to come a
> complete halt. I cannot reproduce this with test code to share with you, but
> this is easily reproducible in our Environment.
>
> It seems like if the txn is in its commit phase, timeout is not honored.
>
> Any help or pointers are greatly appreciated.
>
> Thanks,
> Binti
>
> Name: pub-#8%DataGridServer-Staging%
> State: WAITING on
> org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxFinishFuture@199a76e0
> Total blocked: 2 Total waited: 77
>
> Stack trace:
> sun.misc.Unsafe.park(Native Method)
> java.util.concurrent.locks.LockSupport.park(Unknown Source)
> java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(Unknown
> Source)
> java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireShared(Unknown
> Source)
> java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireShared(Unknown
> Source)
> org.apache.ignite.internal.util.future.GridFutureAdapter.get0(GridFutureAdapter.java:157)
> org.apache.ignite.internal.util.future.GridFutureAdapter.get(GridFutureAdapter.java:117)
> org.apache.ignite.internal.processors.cache.transactions.TransactionProxyImpl.commit(TransactionProxyImpl.java:261)
> com.tudor.datagridI.server.tradegen.OrderHolderSaveRunnable.run(OrderHolderSaveRunnable.java:135)
> org.apache.ignite.internal.processors.closure.GridClosureProcessor$C4V2.execute(GridClosureProcessor.java:2206)
> org.apache.ignite.internal.processors.job.GridJobWorker$2.call(GridJobWorker.java:509)
> org.apache.ignite.internal.util.IgniteUtils.wrapThreadLoader(IgniteUtils.java:6459)
> org.apache.ignite.internal.processors.job.GridJobWorker.execute0(GridJobWorker.java:503)
> org.apache.ignite.internal.processors.job.GridJobWorker.body(GridJobWorker.java:456)
> org.apache.ignite.internal.util.worker.GridWorker.run(GridWorker.java:110)
> org.apache.ignite.internal.processors.job.GridJobProcessor.processJobExecuteRequest(GridJobProcessor.java:1161)
> org.apache.ignite.internal.processors.job.GridJobProcessor$JobExecutionListener.onMessage(GridJobProcessor.java:1766)
> org.apache.ignite.internal.managers.communication.GridIoManager.invokeListener(GridIoManager.java:1219)
> org.apache.ignite.internal.managers.communication.GridIoManager.processRegularMessage0(GridIoManager.java:847)
> org.apache.ignite.internal.managers.communication.GridIoManager.access$1700(GridIoManager.java:105)
> org.apache.ignite.internal.managers.communication.GridIoManager$5.run(GridIoManager.java:810)
> java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
> java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
> java.lang.Thread.run(Unknown Source)
>
>
>
>
> --
> View this message in context: http://apache-ignite-users.70518.x6.nabble.com/transaction-not-timing-out-tp5540p5681.html
> Sent from the Apache Ignite Users mailing list archive at Nabble.com.
Re: transaction not timing out
Posted by bintisepaha <bi...@tudor.com>.
Thanks Denis, did not realize I was creating a new cache with that name with
default settings. However, this was a test case, I fixed it and I can it
timing out. The real issue we see in our UAT enivornment is as follows.
All caches are defined as TRANSACTIONAL in the config file.
But we see one thread on the client side that invokes a compute on the
server node, stuck on the below.
Its at commit and it never times out. In my test case, I cannot reproduce it
because I see exactly what you are describing, a deadlock free scenario.
When this thread is hung, its hung forever, causing the client to come a
complete halt. I cannot reproduce this with test code to share with you, but
this is easily reproducible in our Environment.
It seems like if the txn is in its commit phase, timeout is not honored.
Any help or pointers are greatly appreciated.
Thanks,
Binti
Name: pub-#8%DataGridServer-Staging%
State: WAITING on
org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxFinishFuture@199a76e0
Total blocked: 2 Total waited: 77
Stack trace:
sun.misc.Unsafe.park(Native Method)
java.util.concurrent.locks.LockSupport.park(Unknown Source)
java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(Unknown
Source)
java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireShared(Unknown
Source)
java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireShared(Unknown
Source)
org.apache.ignite.internal.util.future.GridFutureAdapter.get0(GridFutureAdapter.java:157)
org.apache.ignite.internal.util.future.GridFutureAdapter.get(GridFutureAdapter.java:117)
org.apache.ignite.internal.processors.cache.transactions.TransactionProxyImpl.commit(TransactionProxyImpl.java:261)
com.tudor.datagridI.server.tradegen.OrderHolderSaveRunnable.run(OrderHolderSaveRunnable.java:135)
org.apache.ignite.internal.processors.closure.GridClosureProcessor$C4V2.execute(GridClosureProcessor.java:2206)
org.apache.ignite.internal.processors.job.GridJobWorker$2.call(GridJobWorker.java:509)
org.apache.ignite.internal.util.IgniteUtils.wrapThreadLoader(IgniteUtils.java:6459)
org.apache.ignite.internal.processors.job.GridJobWorker.execute0(GridJobWorker.java:503)
org.apache.ignite.internal.processors.job.GridJobWorker.body(GridJobWorker.java:456)
org.apache.ignite.internal.util.worker.GridWorker.run(GridWorker.java:110)
org.apache.ignite.internal.processors.job.GridJobProcessor.processJobExecuteRequest(GridJobProcessor.java:1161)
org.apache.ignite.internal.processors.job.GridJobProcessor$JobExecutionListener.onMessage(GridJobProcessor.java:1766)
org.apache.ignite.internal.managers.communication.GridIoManager.invokeListener(GridIoManager.java:1219)
org.apache.ignite.internal.managers.communication.GridIoManager.processRegularMessage0(GridIoManager.java:847)
org.apache.ignite.internal.managers.communication.GridIoManager.access$1700(GridIoManager.java:105)
org.apache.ignite.internal.managers.communication.GridIoManager$5.run(GridIoManager.java:810)
java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
java.lang.Thread.run(Unknown Source)
--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/transaction-not-timing-out-tp5540p5681.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.
Re: transaction not timing out
Posted by Denis Magda <dm...@gridgain.com>.
Hi Binti,
There is an issue in your code. The cache that is used for transaction operations is not transaction, it’s atomic.
The following code below will properly create the transaction cache for you and you will get the timeout exception
this.ignite = Ignition.start("examples/config/example-ignite.xml");
CacheConfiguration<String, String> cc = new CacheConfiguration<String, String>();
cc.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
cc.setName("CacheA");
cacheA = ignite.getOrCreateCache(cc);
In addition I have a couple of more comments in advance:
1) You don’t need to rollback a transaction if it fails. This will be done automatically.
2) There is no big sense to use the timeout for OPTIMISTIC/SERIALIZABLE transactions because they are deadlock free.
https://apacheignite.readme.io/v1.6/docs/transactions#deadlock-free-transactions <https://apacheignite.readme.io/v1.6/docs/transactions#deadlock-free-transactions>
With this kind of transactions you should to process TransactionOptimisticException. Refer to example that is at the end of this paragraph
https://apacheignite.readme.io/v1.6/docs/transactions#optimistic-transactions <https://apacheignite.readme.io/v1.6/docs/transactions#optimistic-transactions>
—
Denis
> On Jun 15, 2016, at 11:59 PM, bintisepaha <bi...@tudor.com> wrote:
>
> TestTxnTimout.java
> <http://apache-ignite-users.70518.x6.nabble.com/file/n5656/TestTxnTimout.java>
>
> I have attached the test case. Instead of my cache-local file, you can use
> the default cache config file, since I am declaring the cache in java code.
>
> Thread A never times out. I have even tried to put Thread.sleep() in it. why
> does it not timeout?
> The issue we saw in our UAT environment was the thread not timing out at
> commit() but here i can see that no matter which point the thread is - it
> never times out.
>
> Appreciate your help,
> Binti
>
>
>
> --
> View this message in context: http://apache-ignite-users.70518.x6.nabble.com/transaction-not-timing-out-tp5540p5656.html
> Sent from the Apache Ignite Users mailing list archive at Nabble.com.
Re: transaction not timing out
Posted by bintisepaha <bi...@tudor.com>.
TestTxnTimout.java
<http://apache-ignite-users.70518.x6.nabble.com/file/n5656/TestTxnTimout.java>
I have attached the test case. Instead of my cache-local file, you can use
the default cache config file, since I am declaring the cache in java code.
Thread A never times out. I have even tried to put Thread.sleep() in it. why
does it not timeout?
The issue we saw in our UAT environment was the thread not timing out at
commit() but here i can see that no matter which point the thread is - it
never times out.
Appreciate your help,
Binti
--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/transaction-not-timing-out-tp5540p5656.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.
Re: transaction not timing out
Posted by Denis Magda <dm...@gridgain.com>.
It shouldn’t block. In fact a transaction should have been failed when the timeout expires.
Probably you faced with some issue.
Also try to apply deadlock detection mechanism [1]. It may help you in your investigations.
[1] https://apacheignite.readme.io/v1.6/docs/transactions#deadlock-detection <https://apacheignite.readme.io/v1.6/docs/transactions#deadlock-detection>
<https://apacheignite.readme.io/v1.6/docs/transactions#deadlock-detection> <https://apacheignite.readme.io/v1.6/docs/transactions#deadlock-detection>—
Denis
> On Jun 13, 2016, at 8:48 PM, bintisepaha <bi...@tudor.com> wrote:
>
> I will get this out to you shortly. In the meantime could you please explain
> how transaction timeout works? Why does commit block forever?
>
>
>
> --
> View this message in context: http://apache-ignite-users.70518.x6.nabble.com/transaction-not-timing-out-tp5540p5617.html
> Sent from the Apache Ignite Users mailing list archive at Nabble.com.
Re: transaction not timing out
Posted by bintisepaha <bi...@tudor.com>.
I will get this out to you shortly. In the meantime could you please explain
how transaction timeout works? Why does commit block forever?
--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/transaction-not-timing-out-tp5540p5617.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.
Re: transaction not timing out
Posted by Denis Magda <dm...@gridgain.com>.
Hi Binti,
Could you share the source code of the test that reproduces that issue? This will help us to get to the bottom of the issue.
You can use Gist [1] or other code sharing tool for that.
[1] https://gist.github.com <https://gist.github.com/>
—
Denis
> On Jun 10, 2016, at 9:39 PM, bintisepaha <bi...@tudor.com> wrote:
>
> Hi Ignite Community,
>
> We can easily reproduce this by locking resources, but what we do not
> understand is why the txn does not time out if it is in commit state? Why
> doe sit block forever?
>
> Thanks,
> Binti
>
>
>
> --
> View this message in context: http://apache-ignite-users.70518.x6.nabble.com/transaction-not-timing-out-tp5540p5583.html
> Sent from the Apache Ignite Users mailing list archive at Nabble.com.
Re: transaction not timing out
Posted by bintisepaha <bi...@tudor.com>.
Hi Ignite Community,
We can easily reproduce this by locking resources, but what we do not
understand is why the txn does not time out if it is in commit state? Why
doe sit block forever?
Thanks,
Binti
--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/transaction-not-timing-out-tp5540p5583.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.