TransactionOptimisticException: Failed to prepare transaction, read/write conflict

classic Classic list List threaded Threaded
3 messages Options
prasadbhalerao1983 prasadbhalerao1983
Reply | Threaded
Open this post in threaded view
|

TransactionOptimisticException: Failed to prepare transaction, read/write conflict

Hi,
Ignite version: 2.6.0

I am getting following exception while committing a transaction inside IgniteRunnable task.
Transaction is
try (Transaction tx = transactions.txStart(TransactionConcurrency.OPTIMISTIC, TransactionIsolation.SERIALIZABLE)) {
....
..
}

As per the ignite doc if the transaction isolation level is serializable,
Ignite will fail a transaction at the commit stage if the Ignite engine detects that at least one of the entries used as part of the initiated transaction has been modified.

But inside transaction I am just reading SubscriptionData from Sunsbscription cache, I am not modifying this data inside transaction. Also this SubscriptionData is not being modified in some other request outside the mentioned transaction.

Then what could be the reason for this transaction failure?


Caused by: org.apache.ignite.transactions.TransactionOptimisticException: Failed to prepare transaction, read/write conflict [key=com.xyz.grid.data.key.DefaultDataKey@fe220, keyCls=com.xyz.grid.data.key.DefaultDataKey, val=SubscriptionData{subscriptionId=1040928, companyName='test-cmp', expirationDate=1592092799000, activatedModules={100=1592006400000, 101=1592006400000, 102=1592006400000, 107=1592006400000, 112=1592006400000, 145=1592006400000, 114=1592006400000, 117=1592006400000, 1206=1592006400000, 119=1592006400000, 1207=1592006400000, 121=1592006400000, 1210=1592006400000, 9211=1592006400000}, enforced=false, ipv6Enabled=false}, valCls=com.xyz.grid.data.SubscriptionData, cache=SUBSCRIPTION_CACHE, thread=IgniteThread [compositeRwLockIdx=22, stripe=10, plc=-1, name=sys-stripe-10-#11%springDataNode%]]
        at org.apache.ignite.internal.util.IgniteUtils$14.apply(IgniteUtils.java:905)
        at org.apache.ignite.internal.util.IgniteUtils$14.apply(IgniteUtils.java:903)
        at org.apache.ignite.internal.util.IgniteUtils.convertException(IgniteUtils.java:985)
        at org.apache.ignite.internal.processors.cache.transactions.TransactionProxyImpl.commit(TransactionProxyImpl.java:305)
        at com.xyz.task.ignite.AbstractModuleIpAdderIgniteTask.addIps(AbstractModuleIpAdderIgniteTask.java:148)
        at com.xyz.task.ignite.AbstractModuleIpAdderIgniteTask.run(AbstractModuleIpAdderIgniteTask.java:93)
        at org.apache.ignite.internal.processors.closure.GridClosureProcessor$C4.execute(GridClosureProcessor.java:1944)
        at org.apache.ignite.internal.processors.job.GridJobWorker$2.call(GridJobWorker.java:568)
        at org.apache.ignite.internal.util.IgniteUtils.wrapThreadLoader(IgniteUtils.java:6695)
        at org.apache.ignite.internal.processors.job.GridJobWorker.execute0(GridJobWorker.java:562)
        at org.apache.ignite.internal.processors.job.GridJobWorker.body(GridJobWorker.java:491)
        at org.apache.ignite.internal.util.worker.GridWorker.run(GridWorker.java:110)
        ... 3 common frames omitted
Caused by: org.apache.ignite.internal.transactions.IgniteTxOptimisticCheckedException: Failed to prepare transaction, read/write conflict [key=com.xyz.grid.data.key.DefaultDataKey@fe220, keyCls=com.xyz.grid.data.key.DefaultDataKey, val=SubscriptionData{subscriptionId=1040928, companyName='test-cmp', expirationDate=1592092799000, activatedModules={100=1592006400000, 101=1592006400000, 102=1592006400000, 107=1592006400000, 112=1592006400000, 145=1592006400000, 114=1592006400000, 117=1592006400000, 1206=1592006400000, 119=1592006400000, 1207=1592006400000, 121=1592006400000, 1210=1592006400000, 9211=1592006400000}, enforced=false, ipv6Enabled=false}, valCls=com.xyz.grid.data.SubscriptionData, cache=SUBSCRIPTION_CACHE, thread=IgniteThread [compositeRwLockIdx=22, stripe=10, plc=-1, name=sys-stripe-10-#11%springDataNode%]]
        at org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxPrepareFuture.versionCheckError(GridDhtTxPrepareFuture.java:1190)
        at org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxPrepareFuture.checkReadConflict(GridDhtTxPrepareFuture.java:1138)
        at org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxPrepareFuture.prepare0(GridDhtTxPrepareFuture.java:1205)
        at org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxPrepareFuture.mapIfLocked(GridDhtTxPrepareFuture.java:671)
        at org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxPrepareFuture.prepare(GridDhtTxPrepareFuture.java:1048)
        at org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxLocal.prepareAsync(GridDhtTxLocal.java:397)
        at org.apache.ignite.internal.processors.cache.transactions.IgniteTxHandler.prepareNearTx(IgniteTxHandler.java:516)
        at org.apache.ignite.internal.processors.cache.transactions.IgniteTxHandler.processNearTxPrepareRequest0(IgniteTxHandler.java:157)
        at org.apache.ignite.internal.processors.cache.transactions.IgniteTxHandler.processNearTxPrepareRequest(IgniteTxHandler.java:135)
        at org.apache.ignite.internal.processors.cache.transactions.IgniteTxHandler.access$000(IgniteTxHandler.java:97)
        at org.apache.ignite.internal.processors.cache.transactions.IgniteTxHandler$1.apply(IgniteTxHandler.java:177)
        at org.apache.ignite.internal.processors.cache.transactions.IgniteTxHandler$1.apply(IgniteTxHandler.java:175)
        at org.apache.ignite.internal.processors.cache.GridCacheIoManager.processMessage(GridCacheIoManager.java:1054)
        at org.apache.ignite.internal.processors.cache.GridCacheIoManager.onMessage0(GridCacheIoManager.java:579)
        at org.apache.ignite.internal.processors.cache.GridCacheIoManager.handleMessage(GridCacheIoManager.java:378)
        at org.apache.ignite.internal.processors.cache.GridCacheIoManager.handleMessage(GridCacheIoManager.java:304)
        at org.apache.ignite.internal.processors.cache.GridCacheIoManager.access$100(GridCacheIoManager.java:99)
        at org.apache.ignite.internal.processors.cache.GridCacheIoManager$1.onMessage(GridCacheIoManager.java:293)
        at org.apache.ignite.internal.managers.communication.GridIoManager.invokeListener(GridIoManager.java:1556)
        at org.apache.ignite.internal.managers.communication.GridIoManager.processRegularMessage0(GridIoManager.java:1184)
        at org.apache.ignite.internal.managers.communication.GridIoManager.access$4200(GridIoManager.java:125)
        at org.apache.ignite.internal.managers.communication.GridIoManager$9.run(GridIoManager.java:1091)
        at org.apache.ignite.internal.util.StripedExecutor$Stripe.run(StripedExecutor.java:511)
        ... 1 common frames omitted

Thanks,
Prasad
prasadbhalerao1983 prasadbhalerao1983
Reply | Threaded
Open this post in threaded view
|

Re: TransactionOptimisticException: Failed to prepare transaction, read/write conflict

Can someone from community advise?

On Wed, Oct 30, 2019 at 7:28 PM Prasad Bhalerao <[hidden email]> wrote:
Hi,
Ignite version: 2.6.0

I am getting following exception while committing a transaction inside IgniteRunnable task.
Transaction is
try (Transaction tx = transactions.txStart(TransactionConcurrency.OPTIMISTIC, TransactionIsolation.SERIALIZABLE)) {
....
..
}

As per the ignite doc if the transaction isolation level is serializable,
Ignite will fail a transaction at the commit stage if the Ignite engine detects that at least one of the entries used as part of the initiated transaction has been modified.

But inside transaction I am just reading SubscriptionData from Sunsbscription cache, I am not modifying this data inside transaction. Also this SubscriptionData is not being modified in some other request outside the mentioned transaction.

Then what could be the reason for this transaction failure?


Caused by: org.apache.ignite.transactions.TransactionOptimisticException: Failed to prepare transaction, read/write conflict [key=com.xyz.grid.data.key.DefaultDataKey@fe220, keyCls=com.xyz.grid.data.key.DefaultDataKey, val=SubscriptionData{subscriptionId=1040928, companyName='test-cmp', expirationDate=1592092799000, activatedModules={100=1592006400000, 101=1592006400000, 102=1592006400000, 107=1592006400000, 112=1592006400000, 145=1592006400000, 114=1592006400000, 117=1592006400000, 1206=1592006400000, 119=1592006400000, 1207=1592006400000, 121=1592006400000, 1210=1592006400000, 9211=1592006400000}, enforced=false, ipv6Enabled=false}, valCls=com.xyz.grid.data.SubscriptionData, cache=SUBSCRIPTION_CACHE, thread=IgniteThread [compositeRwLockIdx=22, stripe=10, plc=-1, name=sys-stripe-10-#11%springDataNode%]]
        at org.apache.ignite.internal.util.IgniteUtils$14.apply(IgniteUtils.java:905)
        at org.apache.ignite.internal.util.IgniteUtils$14.apply(IgniteUtils.java:903)
        at org.apache.ignite.internal.util.IgniteUtils.convertException(IgniteUtils.java:985)
        at org.apache.ignite.internal.processors.cache.transactions.TransactionProxyImpl.commit(TransactionProxyImpl.java:305)
        at com.xyz.task.ignite.AbstractModuleIpAdderIgniteTask.addIps(AbstractModuleIpAdderIgniteTask.java:148)
        at com.xyz.task.ignite.AbstractModuleIpAdderIgniteTask.run(AbstractModuleIpAdderIgniteTask.java:93)
        at org.apache.ignite.internal.processors.closure.GridClosureProcessor$C4.execute(GridClosureProcessor.java:1944)
        at org.apache.ignite.internal.processors.job.GridJobWorker$2.call(GridJobWorker.java:568)
        at org.apache.ignite.internal.util.IgniteUtils.wrapThreadLoader(IgniteUtils.java:6695)
        at org.apache.ignite.internal.processors.job.GridJobWorker.execute0(GridJobWorker.java:562)
        at org.apache.ignite.internal.processors.job.GridJobWorker.body(GridJobWorker.java:491)
        at org.apache.ignite.internal.util.worker.GridWorker.run(GridWorker.java:110)
        ... 3 common frames omitted
Caused by: org.apache.ignite.internal.transactions.IgniteTxOptimisticCheckedException: Failed to prepare transaction, read/write conflict [key=com.xyz.grid.data.key.DefaultDataKey@fe220, keyCls=com.xyz.grid.data.key.DefaultDataKey, val=SubscriptionData{subscriptionId=1040928, companyName='test-cmp', expirationDate=1592092799000, activatedModules={100=1592006400000, 101=1592006400000, 102=1592006400000, 107=1592006400000, 112=1592006400000, 145=1592006400000, 114=1592006400000, 117=1592006400000, 1206=1592006400000, 119=1592006400000, 1207=1592006400000, 121=1592006400000, 1210=1592006400000, 9211=1592006400000}, enforced=false, ipv6Enabled=false}, valCls=com.xyz.grid.data.SubscriptionData, cache=SUBSCRIPTION_CACHE, thread=IgniteThread [compositeRwLockIdx=22, stripe=10, plc=-1, name=sys-stripe-10-#11%springDataNode%]]
        at org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxPrepareFuture.versionCheckError(GridDhtTxPrepareFuture.java:1190)
        at org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxPrepareFuture.checkReadConflict(GridDhtTxPrepareFuture.java:1138)
        at org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxPrepareFuture.prepare0(GridDhtTxPrepareFuture.java:1205)
        at org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxPrepareFuture.mapIfLocked(GridDhtTxPrepareFuture.java:671)
        at org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxPrepareFuture.prepare(GridDhtTxPrepareFuture.java:1048)
        at org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxLocal.prepareAsync(GridDhtTxLocal.java:397)
        at org.apache.ignite.internal.processors.cache.transactions.IgniteTxHandler.prepareNearTx(IgniteTxHandler.java:516)
        at org.apache.ignite.internal.processors.cache.transactions.IgniteTxHandler.processNearTxPrepareRequest0(IgniteTxHandler.java:157)
        at org.apache.ignite.internal.processors.cache.transactions.IgniteTxHandler.processNearTxPrepareRequest(IgniteTxHandler.java:135)
        at org.apache.ignite.internal.processors.cache.transactions.IgniteTxHandler.access$000(IgniteTxHandler.java:97)
        at org.apache.ignite.internal.processors.cache.transactions.IgniteTxHandler$1.apply(IgniteTxHandler.java:177)
        at org.apache.ignite.internal.processors.cache.transactions.IgniteTxHandler$1.apply(IgniteTxHandler.java:175)
        at org.apache.ignite.internal.processors.cache.GridCacheIoManager.processMessage(GridCacheIoManager.java:1054)
        at org.apache.ignite.internal.processors.cache.GridCacheIoManager.onMessage0(GridCacheIoManager.java:579)
        at org.apache.ignite.internal.processors.cache.GridCacheIoManager.handleMessage(GridCacheIoManager.java:378)
        at org.apache.ignite.internal.processors.cache.GridCacheIoManager.handleMessage(GridCacheIoManager.java:304)
        at org.apache.ignite.internal.processors.cache.GridCacheIoManager.access$100(GridCacheIoManager.java:99)
        at org.apache.ignite.internal.processors.cache.GridCacheIoManager$1.onMessage(GridCacheIoManager.java:293)
        at org.apache.ignite.internal.managers.communication.GridIoManager.invokeListener(GridIoManager.java:1556)
        at org.apache.ignite.internal.managers.communication.GridIoManager.processRegularMessage0(GridIoManager.java:1184)
        at org.apache.ignite.internal.managers.communication.GridIoManager.access$4200(GridIoManager.java:125)
        at org.apache.ignite.internal.managers.communication.GridIoManager$9.run(GridIoManager.java:1091)
        at org.apache.ignite.internal.util.StripedExecutor$Stripe.run(StripedExecutor.java:511)
        ... 1 common frames omitted

Thanks,
Prasad
dmagda dmagda
Reply | Threaded
Open this post in threaded view
|

Re: TransactionOptimisticException: Failed to prepare transaction, read/write conflict

This is not supposed to happen if a record is not updated in parallel. Could you prepare a reproducer?

In general, an optimistic transaction fails if any of the records within a transaction gets modified concurrently.

-
Denis


On Thu, Oct 31, 2019 at 8:46 AM Prasad Bhalerao <[hidden email]> wrote:
Can someone from community advise?

On Wed, Oct 30, 2019 at 7:28 PM Prasad Bhalerao <[hidden email]> wrote:
Hi,
Ignite version: 2.6.0

I am getting following exception while committing a transaction inside IgniteRunnable task.
Transaction is
try (Transaction tx = transactions.txStart(TransactionConcurrency.OPTIMISTIC, TransactionIsolation.SERIALIZABLE)) {
....
..
}

As per the ignite doc if the transaction isolation level is serializable,
Ignite will fail a transaction at the commit stage if the Ignite engine detects that at least one of the entries used as part of the initiated transaction has been modified.

But inside transaction I am just reading SubscriptionData from Sunsbscription cache, I am not modifying this data inside transaction. Also this SubscriptionData is not being modified in some other request outside the mentioned transaction.

Then what could be the reason for this transaction failure?


Caused by: org.apache.ignite.transactions.TransactionOptimisticException: Failed to prepare transaction, read/write conflict [key=com.xyz.grid.data.key.DefaultDataKey@fe220, keyCls=com.xyz.grid.data.key.DefaultDataKey, val=SubscriptionData{subscriptionId=1040928, companyName='test-cmp', expirationDate=1592092799000, activatedModules={100=1592006400000, 101=1592006400000, 102=1592006400000, 107=1592006400000, 112=1592006400000, 145=1592006400000, 114=1592006400000, 117=1592006400000, 1206=1592006400000, 119=1592006400000, 1207=1592006400000, 121=1592006400000, 1210=1592006400000, 9211=1592006400000}, enforced=false, ipv6Enabled=false}, valCls=com.xyz.grid.data.SubscriptionData, cache=SUBSCRIPTION_CACHE, thread=IgniteThread [compositeRwLockIdx=22, stripe=10, plc=-1, name=sys-stripe-10-#11%springDataNode%]]
        at org.apache.ignite.internal.util.IgniteUtils$14.apply(IgniteUtils.java:905)
        at org.apache.ignite.internal.util.IgniteUtils$14.apply(IgniteUtils.java:903)
        at org.apache.ignite.internal.util.IgniteUtils.convertException(IgniteUtils.java:985)
        at org.apache.ignite.internal.processors.cache.transactions.TransactionProxyImpl.commit(TransactionProxyImpl.java:305)
        at com.xyz.task.ignite.AbstractModuleIpAdderIgniteTask.addIps(AbstractModuleIpAdderIgniteTask.java:148)
        at com.xyz.task.ignite.AbstractModuleIpAdderIgniteTask.run(AbstractModuleIpAdderIgniteTask.java:93)
        at org.apache.ignite.internal.processors.closure.GridClosureProcessor$C4.execute(GridClosureProcessor.java:1944)
        at org.apache.ignite.internal.processors.job.GridJobWorker$2.call(GridJobWorker.java:568)
        at org.apache.ignite.internal.util.IgniteUtils.wrapThreadLoader(IgniteUtils.java:6695)
        at org.apache.ignite.internal.processors.job.GridJobWorker.execute0(GridJobWorker.java:562)
        at org.apache.ignite.internal.processors.job.GridJobWorker.body(GridJobWorker.java:491)
        at org.apache.ignite.internal.util.worker.GridWorker.run(GridWorker.java:110)
        ... 3 common frames omitted
Caused by: org.apache.ignite.internal.transactions.IgniteTxOptimisticCheckedException: Failed to prepare transaction, read/write conflict [key=com.xyz.grid.data.key.DefaultDataKey@fe220, keyCls=com.xyz.grid.data.key.DefaultDataKey, val=SubscriptionData{subscriptionId=1040928, companyName='test-cmp', expirationDate=1592092799000, activatedModules={100=1592006400000, 101=1592006400000, 102=1592006400000, 107=1592006400000, 112=1592006400000, 145=1592006400000, 114=1592006400000, 117=1592006400000, 1206=1592006400000, 119=1592006400000, 1207=1592006400000, 121=1592006400000, 1210=1592006400000, 9211=1592006400000}, enforced=false, ipv6Enabled=false}, valCls=com.xyz.grid.data.SubscriptionData, cache=SUBSCRIPTION_CACHE, thread=IgniteThread [compositeRwLockIdx=22, stripe=10, plc=-1, name=sys-stripe-10-#11%springDataNode%]]
        at org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxPrepareFuture.versionCheckError(GridDhtTxPrepareFuture.java:1190)
        at org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxPrepareFuture.checkReadConflict(GridDhtTxPrepareFuture.java:1138)
        at org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxPrepareFuture.prepare0(GridDhtTxPrepareFuture.java:1205)
        at org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxPrepareFuture.mapIfLocked(GridDhtTxPrepareFuture.java:671)
        at org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxPrepareFuture.prepare(GridDhtTxPrepareFuture.java:1048)
        at org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTxLocal.prepareAsync(GridDhtTxLocal.java:397)
        at org.apache.ignite.internal.processors.cache.transactions.IgniteTxHandler.prepareNearTx(IgniteTxHandler.java:516)
        at org.apache.ignite.internal.processors.cache.transactions.IgniteTxHandler.processNearTxPrepareRequest0(IgniteTxHandler.java:157)
        at org.apache.ignite.internal.processors.cache.transactions.IgniteTxHandler.processNearTxPrepareRequest(IgniteTxHandler.java:135)
        at org.apache.ignite.internal.processors.cache.transactions.IgniteTxHandler.access$000(IgniteTxHandler.java:97)
        at org.apache.ignite.internal.processors.cache.transactions.IgniteTxHandler$1.apply(IgniteTxHandler.java:177)
        at org.apache.ignite.internal.processors.cache.transactions.IgniteTxHandler$1.apply(IgniteTxHandler.java:175)
        at org.apache.ignite.internal.processors.cache.GridCacheIoManager.processMessage(GridCacheIoManager.java:1054)
        at org.apache.ignite.internal.processors.cache.GridCacheIoManager.onMessage0(GridCacheIoManager.java:579)
        at org.apache.ignite.internal.processors.cache.GridCacheIoManager.handleMessage(GridCacheIoManager.java:378)
        at org.apache.ignite.internal.processors.cache.GridCacheIoManager.handleMessage(GridCacheIoManager.java:304)
        at org.apache.ignite.internal.processors.cache.GridCacheIoManager.access$100(GridCacheIoManager.java:99)
        at org.apache.ignite.internal.processors.cache.GridCacheIoManager$1.onMessage(GridCacheIoManager.java:293)
        at org.apache.ignite.internal.managers.communication.GridIoManager.invokeListener(GridIoManager.java:1556)
        at org.apache.ignite.internal.managers.communication.GridIoManager.processRegularMessage0(GridIoManager.java:1184)
        at org.apache.ignite.internal.managers.communication.GridIoManager.access$4200(GridIoManager.java:125)
        at org.apache.ignite.internal.managers.communication.GridIoManager$9.run(GridIoManager.java:1091)
        at org.apache.ignite.internal.util.StripedExecutor$Stripe.run(StripedExecutor.java:511)
        ... 1 common frames omitted

Thanks,
Prasad