Hi,

I observed one more behavior. I am using executor service to execute the
tasks.
When I submit a task to remove entries from cache, I get transaction
optimistic exception.
But instead of submitting the task, if I just call task.run() method it
works fine.


Thanks,
Prasad

On Tue, Jun 5, 2018 at 7:07 PM, Andrey Mashenkov <andrey.mashen...@gmail.com
> wrote:

> Hi,
>
> We'll check this case.
> Please, share a reproducer if possible.
>
> On Tue, Jun 5, 2018 at 3:53 PM, Prasad Bhalerao <
> prasadbhalerao1...@gmail.com> wrote:
>
>> Hi,
>>
>> In my case only one transaction is in progress. In this transaction I
>> update few entries in cache and then re-read these entries and updates it
>> again in some other method.
>> When I read the entry after first update operations, transaction entry
>> read version(IgniteTxEntry-entryReadVersion) changes. This version is
>> validated in GridDhtTxPrepareFuture::checkReadConflict method.
>>
>> But I don't understand why transaction fails if the entry is modified
>> after read operation in same transaction?
>>
>> Thanks,
>> Prasad
>>
>> On Tue, Jun 5, 2018 at 6:07 PM, Andrey Mashenkov <
>> andrey.mashen...@gmail.com> wrote:
>>
>>> Hi,
>>>
>>> It is ok, Optimistic transaction failed on commit
>>> with TransactionOptimisticException due to write\read conflict.
>>> See javadoc [1] and documentation [2] for details.
>>>
>>> Javadoc says:
>>> *  However, in {@link TransactionConcurrency#OPTIMISTIC} mode, if some
>>> transactions cannot be serially isolated
>>>  *  from each other, then one winner will be picked and the other
>>> transactions in conflict will result in
>>>  * {@link TransactionOptimisticException} being thrown.
>>>
>>> [1] https://github.com/apache/ignite/blob/master/modules/cor
>>> e/src/main/java/org/apache/ignite/transactions/Transaction.java
>>> [2] https://apacheignite.readme.io/docs/transactions#section
>>> -optimistic-transactions
>>>
>>> On Tue, Jun 5, 2018 at 3:19 PM, Prasad Bhalerao <
>>> prasadbhalerao1...@gmail.com> wrote:
>>>
>>>> Hi,
>>>> I tried this with simple code and it works fine.
>>>> But in my application when I do similar thing I get following exception
>>>> when I do commit. I am getting transaction as follows.
>>>>
>>>>     IgniteTransactions igniteTx = getServiceContext().getGridSer
>>>> vice().getTransaction();
>>>>     try (Transaction transaction = igniteTx
>>>>         .txStart(TransactionConcurrency.OPTIMISTIC,
>>>> TransactionIsolation.SERIALIZABLE)) {
>>>>
>>>> Can you please advise?
>>>>
>>>> Caused by: org.apache.ignite.transactions.TransactionOptimisticException:
>>>> Failed to prepare transaction, read/write conflict
>>>> [key=DefaultDataAffinityKey{id=1556524, affinityId=1},
>>>> keyCls=com.qls.agms.grid.data.key.DefaultDataAffinityKey, val=null,
>>>> cache=IPV4_ASSET_GROUP_DETAIL_CACHE, thread=IgniteThread
>>>> [compositeRwLockIdx=7, stripe=-1, plc=0, name=pub-#53%springDataNode%]]
>>>>             at org.apache.ignite.internal.uti
>>>> l.IgniteUtils$14.apply(IgniteUtils.java:895)
>>>>             at org.apache.ignite.internal.uti
>>>> l.IgniteUtils$14.apply(IgniteUtils.java:893)
>>>>             at org.apache.ignite.internal.uti
>>>> l.IgniteUtils.convertException(IgniteUtils.java:975)
>>>>             at org.apache.ignite.internal.pro
>>>> cessors.cache.transactions.TransactionProxyImpl.commit(Trans
>>>> actionProxyImpl.java:296)
>>>>             at com.qls.agms.task.ignite.EditA
>>>> ssetGroupIgniteTask.run(EditAssetGroupIgniteTask.java:44)
>>>>             at org.apache.ignite.internal.pro
>>>> cessors.closure.GridClosureProcessor$C4.execute(GridClosureP
>>>> rocessor.java:1944)
>>>>             at org.apache.ignite.internal.processors.job.GridJobWorker$
>>>> 2.call(GridJobWorker.java:566)
>>>>             at org.apache.ignite.internal.uti
>>>> l.IgniteUtils.wrapThreadLoader(IgniteUtils.java:6623)
>>>>             at org.apache.ignite.internal.pro
>>>> cessors.job.GridJobWorker.execute0(GridJobWorker.java:560)
>>>>             ... 5 common frames omitted
>>>> Caused by: 
>>>> org.apache.ignite.internal.transactions.IgniteTxOptimisticCheckedException:
>>>> Failed to prepare transaction, read/write conflict
>>>> [key=DefaultDataAffinityKey{id=1556524, affinityId=1},
>>>> keyCls=com.qls.agms.grid.data.key.DefaultDataAffinityKey, val=null,
>>>> cache=IPV4_ASSET_GROUP_DETAIL_CACHE, thread=IgniteThread
>>>> [compositeRwLockIdx=7, stripe=-1, plc=0, name=pub-#53%springDataNode%]]
>>>>             at org.apache.ignite.internal.pro
>>>> cessors.cache.distributed.dht.GridDhtTxPrepareFuture.version
>>>> CheckError(GridDhtTxPrepareFuture.java:1190)
>>>>             at org.apache.ignite.internal.pro
>>>> cessors.cache.distributed.dht.GridDhtTxPrepareFuture.checkRe
>>>> adConflict(GridDhtTxPrepareFuture.java:1138)
>>>>             at org.apache.ignite.internal.pro
>>>> cessors.cache.distributed.dht.GridDhtTxPrepareFuture.prepare
>>>> 0(GridDhtTxPrepareFuture.java:1205)
>>>>             at org.apache.ignite.internal.pro
>>>> cessors.cache.distributed.dht.GridDhtTxPrepareFuture.mapIfLo
>>>> cked(GridDhtTxPrepareFuture.java:671)
>>>>             at org.apache.ignite.internal.pro
>>>> cessors.cache.distributed.dht.GridDhtTxPrepareFuture.prepare
>>>> (GridDhtTxPrepareFuture.java:1048)
>>>>             at org.apache.ignite.internal.pro
>>>> cessors.cache.distributed.near.GridNearTxLocal.prepareAsyncL
>>>> ocal(GridNearTxLocal.java:3452)
>>>>             at org.apache.ignite.internal.pro
>>>> cessors.cache.transactions.IgniteTxHandler.prepareColocatedT
>>>> x(IgniteTxHandler.java:257)
>>>>             at org.apache.ignite.internal.pro
>>>> cessors.cache.distributed.near.GridNearOptimisticSerializabl
>>>> eTxPrepareFuture.prepareLocal(GridNearOptimisticSerializable
>>>> TxPrepareFuture.java:580)
>>>>             at org.apache.ignite.internal.pro
>>>> cessors.cache.distributed.near.GridNearOptimisticSerializabl
>>>> eTxPrepareFuture.prepare(GridNearOptimisticSerializableTxPre
>>>> pareFuture.java:494)
>>>>             at org.apache.ignite.internal.pro
>>>> cessors.cache.distributed.near.GridNearOptimisticSerializabl
>>>> eTxPrepareFuture.prepare(GridNearOptimisticSerializableTxPre
>>>> pareFuture.java:408)
>>>>             at org.apache.ignite.internal.pro
>>>> cessors.cache.distributed.near.GridNearOptimisticSerializabl
>>>> eTxPrepareFuture.prepare0(GridNearOptimisticSerializableTxPr
>>>> epareFuture.java:315)
>>>>             at org.apache.ignite.internal.pro
>>>> cessors.cache.distributed.near.GridNearOptimisticTxPrepareFu
>>>> tureAdapter.prepareOnTopology(GridNearOptimisticTxPrepareFut
>>>> ureAdapter.java:137)
>>>>             at org.apache.ignite.internal.pro
>>>> cessors.cache.distributed.near.GridNearOptimisticTxPrepareFu
>>>> tureAdapter.prepare(GridNearOptimisticTxPrepareFutureAdapter.java:74)
>>>>             at org.apache.ignite.internal.pro
>>>> cessors.cache.distributed.near.GridNearTxLocal.prepareNearTx
>>>> Local(GridNearTxLocal.java:3161)
>>>>             at org.apache.ignite.internal.pro
>>>> cessors.cache.distributed.near.GridNearTxLocal.commitNearTxL
>>>> ocalAsync(GridNearTxLocal.java:3221)
>>>>             at org.apache.ignite.internal.pro
>>>> cessors.cache.GridCacheAdapter.commitTxAsync(GridCacheAdapte
>>>> r.java:4019)
>>>>             at org.apache.ignite.internal.pro
>>>> cessors.cache.GridCacheSharedContext.commitTxAsync(GridCache
>>>> SharedContext.java:975)
>>>>             at org.apache.ignite.internal.pro
>>>> cessors.cache.transactions.TransactionProxyImpl.commit(Trans
>>>> actionProxyImpl.java:288)
>>>>             ... 10 common frames omitted
>>>>
>>>> Thanks,
>>>> Prasad
>>>>
>>>> On Tue, Jun 5, 2018 at 2:18 PM, Andrey Mashenkov <
>>>> andrey.mashen...@gmail.com> wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> Sure, multiple actions with same query within same transaction should
>>>>> work.
>>>>>
>>>>> Please, let us know if you observe unexpected behavior.
>>>>> Any reproducer will be appreciated.
>>>>>
>>>>>
>>>>> On Tue, Jun 5, 2018 at 10:36 AM, Prasad Bhalerao <
>>>>> prasadbhalerao1...@gmail.com> wrote:
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> Can I update the same entry multiple time inside ignite transaction?
>>>>>> Or
>>>>>> Can I update an entry and then remove the same entry in ignite
>>>>>> transaction?
>>>>>>
>>>>>> Thanks,
>>>>>> Prasad
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Best regards,
>>>>> Andrey V. Mashenkov
>>>>>
>>>>
>>>>
>>>
>>>
>>> --
>>> Best regards,
>>> Andrey V. Mashenkov
>>>
>>
>>
>
>
> --
> Best regards,
> Andrey V. Mashenkov
>

Reply via email to