Hello!

Unfortunately this code still doesn't lock for me when I run it on some
non-empty cache with considerable number of entries.

Are you sure there's nothing running in parallel on those caches? Can you
perhaps upload a minimal reproducer on github?

Regards,

-- 
Ilya Kasnacheev

2018-03-01 17:56 GMT+03:00 Teki <t3k1pa...@gmail.com>:

> Hi Ilya,
>
> Sometimes, it does not throw an exception with lesser volume of records (in
> the order of thousands). Please find the complete stack trace and actual
> code.
>
> It does not hang before throwing this error. It happens almost quick after
> partially updating around only thousand records out of the millions of
> records that is supposed to be updated.
>
> *Error Trace*
>
> Feb 28, 2018 4:47:38 PM org.apache.ignite.logger.java.JavaLogger error
> SEVERE: <AccountDailyFact> Unexpected exception during cache update
> class org.apache.ignite.IgniteInterruptedException: Thread got interrupted
> while trying to acquire table lock.
>         at
> org.apache.ignite.internal.processors.query.h2.opt.
> GridH2Table.lock(GridH2Table.java:286)
>         at
> org.apache.ignite.internal.processors.query.h2.opt.GridH2Table.doUpdate(
> GridH2Table.java:462)
>         at
> org.apache.ignite.internal.processors.query.h2.opt.GridH2Table.update(
> GridH2Table.java:423)
>         at
> org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing.store(
> IgniteH2Indexing.java:559)
>         at
> org.apache.ignite.internal.processors.query.GridQueryProcessor.store(
> GridQueryProcessor.java:1747)
>         at
> org.apache.ignite.internal.processors.cache.query.
> GridCacheQueryManager.store(GridCacheQueryManager.java:425)
>         at
> org.apache.ignite.internal.processors.cache.IgniteCacheOffheapManagerImpl$
> CacheDataStoreImpl.finishUpdate(IgniteCacheOffheapManagerImpl.java:1344)
>         at
> org.apache.ignite.internal.processors.cache.IgniteCacheOffheapManagerImpl$
> CacheDataStoreImpl.invoke(IgniteCacheOffheapManagerImpl.java:1209)
>         at
> org.apache.ignite.internal.processors.cache.IgniteCacheOffheapManagerImpl.
> invoke(IgniteCacheOffheapManagerImpl.java:343)
>         at
> org.apache.ignite.internal.processors.cache.GridCacheMapEntry.innerUpdate(
> GridCacheMapEntry.java:1693)
>         at
> org.apache.ignite.internal.processors.cache.distributed.
> dht.atomic.GridDhtAtomicCache.updateSingle(GridDhtAtomicCache.java:2419)
>         at
> org.apache.ignite.internal.processors.cache.distributed.
> dht.atomic.GridDhtAtomicCache.update(GridDhtAtomicCache.java:1882)
>         at
> org.apache.ignite.internal.processors.cache.distributed.
> dht.atomic.GridDhtAtomicCache.updateAllAsyncInternal0(
> GridDhtAtomicCache.java:1735)
>         at
> org.apache.ignite.internal.processors.cache.distributed.
> dht.atomic.GridDhtAtomicCache.updateAllAsyncInternal(
> GridDhtAtomicCache.java:1627)
>         at
> org.apache.ignite.internal.processors.cache.distributed.dht.atomic.
> GridNearAtomicAbstractUpdateFuture.sendSingleRequest(
> GridNearAtomicAbstractUpdateFuture.java:299)
>         at
> org.apache.ignite.internal.processors.cache.distributed.dht.atomic.
> GridNearAtomicSingleUpdateFuture.map(GridNearAtomicSingleUpdateFutu
> re.java:483)
>         at
> org.apache.ignite.internal.processors.cache.distributed.dht.atomic.
> GridNearAtomicSingleUpdateFuture.mapOnTopology(
> GridNearAtomicSingleUpdateFuture.java:443)
>         at
> org.apache.ignite.internal.processors.cache.distributed.dht.atomic.
> GridNearAtomicAbstractUpdateFuture.map(GridNearAtomicAbstractUpdateFu
> ture.java:248)
>         at
> org.apache.ignite.internal.processors.cache.distributed.
> dht.atomic.GridDhtAtomicCache.update0(GridDhtAtomicCache.java:1116)
>         at
> org.apache.ignite.internal.processors.cache.distributed.
> dht.atomic.GridDhtAtomicCache.put0(GridDhtAtomicCache.java:605)
>         at
> org.apache.ignite.internal.processors.cache.GridCacheAdapter.put(
> GridCacheAdapter.java:2321)
>         at
> org.apache.ignite.internal.processors.cache.GridCacheAdapter.put(
> GridCacheAdapter.java:2298)
>         at
> org.apache.ignite.internal.processors.cache.IgniteCacheProxyImpl.put(
> IgniteCacheProxyImpl.java:1005)
>         at
> org.apache.ignite.internal.processors.cache.GatewayProtectedCacheProxy.
> put(GatewayProtectedCacheProxy.java:872)
>         at
> com.amex.fde.cache.job.UpdAcctsWitNoActivity.lambda$
> updAcctsWitNoActvtyAffinityComput$646e2c8c$1(UpdAcctsWitNoActivity.java:
> 126)
>         at
> org.apache.ignite.internal.processors.closure.GridClosureProcessor$C2.
> execute(GridClosureProcessor.java:1855)
>         at
> org.apache.ignite.internal.processors.job.GridJobWorker$
> 2.call(GridJobWorker.java:566)
>         at
> org.apache.ignite.internal.util.IgniteUtils.wrapThreadLoader(IgniteUtils.
> java:6631)
>         at
> org.apache.ignite.internal.processors.job.GridJobWorker.
> execute0(GridJobWorker.java:560)
>         at
> org.apache.ignite.internal.processors.job.GridJobWorker.
> body(GridJobWorker.java:489)
>         at
> org.apache.ignite.internal.util.worker.GridWorker.run(GridWorker.java:110)
>         at
> org.apache.ignite.internal.processors.job.GridJobProcessor.
> processJobExecuteRequest(GridJobProcessor.java:1181)
>         at
> org.apache.ignite.internal.processors.job.GridJobProcessor$
> JobExecutionListener.onMessage(GridJobProcessor.java:1913)
>         at
> org.apache.ignite.internal.managers.communication.
> GridIoManager.invokeListener(GridIoManager.java:1555)
>         at
> org.apache.ignite.internal.managers.communication.GridIoManager.
> processRegularMessage0(GridIoManager.java:1183)
>         at
> org.apache.ignite.internal.managers.communication.
> GridIoManager.access$4200(GridIoManager.java:126)
>         at
> org.apache.ignite.internal.managers.communication.GridIoManager$9.run(
> GridIoManager.java:1090)
>         at
> java.util.concurrent.ThreadPoolExecutor.runWorker(
> ThreadPoolExecutor.java:1149)
>         at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(
> ThreadPoolExecutor.java:624)
>         at java.lang.Thread.run(Thread.java:748)
> Caused by: java.lang.InterruptedException
>         at
> java.util.concurrent.locks.AbstractQueuedSynchronizer.
> acquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1302)
>         at
> java.util.concurrent.locks.ReentrantReadWriteLock$
> ReadLock.lockInterruptibly(ReentrantReadWriteLock.java:772)
>         at
> org.apache.ignite.internal.processors.query.h2.opt.
> GridH2Table.lock(GridH2Table.java:281)
>         ... 39 more
>
>
>
> *Code*
>
>     protected static void updAcctsWitNoActvtyAffinityComput(Ignite ignite,
> String cacheName, String dayKeyID, String subBalType) throws Exception {
>         U.warn((IgniteLogger) null, ">> No. of partitions: " +
> ignite.affinity(cacheName).partitions());
>         List<IgniteFuture&lt;ExecutionTimer>> ts = new ArrayList<>();
>         for (int p = 0; p < ignite.affinity(cacheName).partitions(); p++)
> {
>             final int partition = p;
>
> ts.add(ignite.compute().affinityCallAsync(Arrays.asList(cacheName),
> partition, () -> {
>                 int rsCount = 0;
>                 int totDurn = 0;
>                 ExecutionTimer t = new ExecutionTimer();
>                 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);
> //
> acctDailyFact.getSUB_BAL_TYPE_TX().equals(subBalType) &
>                     }
>                 };
>                 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()) {
>                     rsCount++;
>                     row = iterator.next();
>                     AccDlyFactKey acctDailyFactQueryKey = row.getKey();
>                     AccDlyFactVal accDlyFactValQueryVal = row.getValue();
>                     int days = getDays(dayKeyID) - 1;
>
> accDlyFactValQueryVal.setDAY_KEY_ID(Integer.parseInt(dayKeyID));
>                     BigDecimal intADB =
> accDlyFactValQueryVal.getINTRST_AVG_DAY_BAL_AM();
>                     BigDecimal nonIntADB =
> accDlyFactValQueryVal.getNON_INTRST_AVG_DAY_BAL_AM();
>                     if (intADB.compareTo(BigDecimal.valueOf(0)) >= 1) {
>
> accDlyFactValQueryVal.setINTRST_AVG_DAY_BAL_AM(((
> intADB.multiply(BigDecimal.valueOf(days))).add(
> accDlyFactValQueryVal.getEND_AR_AM())).divide(BigDecimal.valueOf(days
> + 1), 2, BigDecimal.ROUND_HALF_UP));
>                     }
>                     if (nonIntADB.compareTo(BigDecimal.valueOf(0)) >= 1) {
>
> accDlyFactValQueryVal.setNON_INTRST_AVG_DAY_BAL_AM(((
> nonIntADB.multiply(BigDecimal.valueOf(days))).add(
> accDlyFactValQueryVal.getEND_AR_AM())).divide(BigDecimal.valueOf(days
> + 1), 2, BigDecimal.ROUND_HALF_UP));
>                     }
>                     igniteCache.put(acctDailyFactQueryKey,
> accDlyFactValQueryVal);
>                     if (rsCount % 1000000 == 0) {
>                         t.end();
>                         totDurn += t.duration();
>                         U.warn((IgniteLogger) null, ">> Unmatched Update
> inside iterator : " + rsCount + " records.");
>                         t.start();
>                     }
>                 }
>                 U.warn((IgniteLogger) null, ">> Unmatched Update outside
> iterator : " + rsCount + " records.");
>                 return t;
>             }));
>         }
>         ignite.close();
>     }
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>

Reply via email to