You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by arunkjn <ar...@gmail.com> on 2017/11/03 09:43:07 UTC

Transactions and IgniteQueue

Hi,

I am using an optimistic transaction with serializable isolation level on a
transactional cache as follows-

while (true){
                try(Transaction tx =
ignite.transactions().txStart(TransactionConcurrency.OPTIMISTIC,
TransactionIsolation.SERIALIZABLE)){

                    // update all keys of workflow run state corresponding
to this event
                    flowRunStateIds.stream().forEach(flowRunStateId -> {
                        FlowRunState state =
workflowRunStateIgniteCache.get(flowRunStateId);
                        try {
                            state.getFlowRunEvents().put(event);
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                        workflowRunStateIgniteCache.put(flowRunStateId,
state);
                    });

                    updatedFlows.stream().forEach(workflowFlow ->
updatedFlowsIgniteQueue.put(workflowFlow));

                    tx.commit();
                    break;
                }
                catch (TransactionOptimisticException e){
                    // todo: emit a monitoring metric TRANSACTIONS_FAILED
here
                    System.out.println("Transaction failed. Retrying...");
                }
            }

Inside the transaction I am updating the cache values and also updating an
IgniteQueue updatedFlowsIgniteQueue. If the transaction fails at the time of
commit, the transactional cache will not be updated. Is the same also true
for IgniteQueue? Also, will my queue be locked during the duration of the
transaction?

Thanks,
Arun



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Re: Transactions and IgniteQueue

Posted by Evgenii Zhuravlev <e....@gmail.com>.
/**
 * Commits this transaction by initiating {@code two-phase-commit} process.
 *
 * @throws IgniteException If commit failed.
 * @throws TransactionTimeoutException If transaction is timed out.
 * @throws TransactionRollbackException If transaction is
automatically rolled back.
 * @throws TransactionOptimisticException If transaction concurrency
is {@link TransactionConcurrency#OPTIMISTIC}
 * and commit is optimistically failed.
 * @throws TransactionHeuristicException If transaction has entered an
unknown state.
 */
@IgniteAsyncSupported
public void commit() throws IgniteException;


2017-11-03 17:36 GMT+03:00 Evgenii Zhuravlev <e....@gmail.com>:

> Yes, you could see it in the javadoc for Transaction class:
>
>
> 2017-11-03 14:43 GMT+03:00 arunkjn <ar...@gmail.com>:
>
>> Thanks Evgenii.
>>
>> If I get a TransactionOptimisticException during the transaction will it
>> be
>> thrown at the time of tx.commit() ?
>>
>>
>>
>> --
>> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>>
>
>

Re: Transactions and IgniteQueue

Posted by Evgenii Zhuravlev <e....@gmail.com>.
Yes, you could see it in the javadoc for Transaction class:


2017-11-03 14:43 GMT+03:00 arunkjn <ar...@gmail.com>:

> Thanks Evgenii.
>
> If I get a TransactionOptimisticException during the transaction will it be
> thrown at the time of tx.commit() ?
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>

Re: Transactions and IgniteQueue

Posted by arunkjn <ar...@gmail.com>.
Thanks Evgenii.

If I get a TransactionOptimisticException during the transaction will it be
thrown at the time of tx.commit() ?



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Re: Transactions and IgniteQueue

Posted by Evgenii Zhuravlev <e....@gmail.com>.
Hi Arun,

As for now, IgniteTransaction works only for caches. You can find
information about it in documentation:
https://apacheignite.readme.io/docs/transactions#section-ignitetransactions

Evgenii

2017-11-03 12:43 GMT+03:00 arunkjn <ar...@gmail.com>:

> Hi,
>
> I am using an optimistic transaction with serializable isolation level on a
> transactional cache as follows-
>
> while (true){
>                 try(Transaction tx =
> ignite.transactions().txStart(TransactionConcurrency.OPTIMISTIC,
> TransactionIsolation.SERIALIZABLE)){
>
>                     // update all keys of workflow run state corresponding
> to this event
>                     flowRunStateIds.stream().forEach(flowRunStateId -> {
>                         FlowRunState state =
> workflowRunStateIgniteCache.get(flowRunStateId);
>                         try {
>                             state.getFlowRunEvents().put(event);
>                         } catch (InterruptedException e) {
>                             e.printStackTrace();
>                         }
>                         workflowRunStateIgniteCache.put(flowRunStateId,
> state);
>                     });
>
>                     updatedFlows.stream().forEach(workflowFlow ->
> updatedFlowsIgniteQueue.put(workflowFlow));
>
>                     tx.commit();
>                     break;
>                 }
>                 catch (TransactionOptimisticException e){
>                     // todo: emit a monitoring metric TRANSACTIONS_FAILED
> here
>                     System.out.println("Transaction failed. Retrying...");
>                 }
>             }
>
> Inside the transaction I am updating the cache values and also updating an
> IgniteQueue updatedFlowsIgniteQueue. If the transaction fails at the time
> of
> commit, the transactional cache will not be updated. Is the same also true
> for IgniteQueue? Also, will my queue be locked during the duration of the
> transaction?
>
> Thanks,
> Arun
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>