I am getting the below mentioned exception when I use the below snippet to
read records in cache and update.

How to avoid interruption? The atomicity mode has to be transactional. 

I read the below links related to this.

https://apacheignite.readme.io/docs/thread-pools
https://apacheignite.readme.io/docs/distributed-locks

*Exception*

SEVERE: <AccountDailyFact> Unexpected exception during cache update
class org.apache.ignite.IgniteInterruptedException: Thread got interrupted
while trying to acquire table lock.

class org.apache.ignite.IgniteException: class
org.apache.ignite.IgniteInterruptedException: Got interrupted while waiting
for future to complete.

*Code:*
for (int p = 0; p < ignite.affinity(cacheName).partitions(); p++) {
            final int partition = p;
           
ts.add(ignite.compute().affinityCallAsync(Arrays.asList(cacheName),
partition, () -> {
                final IgniteCache<AccDlyFactKey, AccDlyFactVal> igniteCache
= ignite.cache(cacheName);
                IgniteBiPredicate<AccDlyFactKey, AccDlyFactVal>
igniteBiPredicate = new IgniteBiPredicate<AccDlyFactKey, AccDlyFactVal>() {
                    @Override
                    public boolean apply(AccDlyFactKey acctDailyFactKey,
AccDlyFactVal acctDailyFact) {
                        return acctDailyFact.getDAY_KEY_ID() <
Integer.parseInt(dayKeyID);
                    }
                };
                ScanQuery<AccDlyFactKey, AccDlyFactVal> scanQuery = new
ScanQuery<AccDlyFactKey, AccDlyFactVal>(igniteBiPredicate);
                scanQuery.setPartition(partition);
                Iterator<Cache.Entry&lt;AccDlyFactKey, AccDlyFactVal>>
iterator = igniteCache.query(scanQuery).iterator();
                Cache.Entry<AccDlyFactKey, AccDlyFactVal> row = null;
                while (iterator.hasNext()) {
                    row = iterator.next();
                    AccDlyFactKey acctDailyFactQueryKey = row.getKey();
                    AccDlyFactVal accDlyFactValQueryVal = row.getValue();
                   
accDlyFactValQueryVal.setDAY_KEY_ID(Integer.parseInt(dayKeyID));
                    igniteCache.put(acctDailyFactQueryKey,
accDlyFactValQueryVal);
                }
                return t;
            }));



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

Reply via email to