NullPointerException when performing operations on an IgniteCache
- Dominant language
- Java
- Stars
- 5.1k
- Forks
- 1.9k
- Avg merge
- 3d 2h
- Merged PRs (30d)
- 46
Description
Hey guys!
We discovered that a `NullPointerException` is thrown by Ignite when trying to perform operations on `cache1` in the following code snippet.
```
CacheConfiguration cache1Config = new CacheConfiguration<>("cache1");
cache1Config.setGroupName("myCacheGroup");
CacheConfiguration cache2Config = new CacheConfiguration<>("cache2");
cache2Config.setGroupName("myCacheGroup");
IgniteConfiguration cfg = new IgniteConfiguration();
Ignite ignite = Ignition.start(cfg);
IgniteCache cache1 = ignite.getOrCreateCache(cache1Config);
IgniteCache cache2 = ignite.getOrCreateCache(cache2Config);
cache2.registerCacheEntryListener(new CacheEntryListenerConfigImpl());
cache2.destroy();
cache1.put(UUID.randomUUID(), UUID.randomUUID()); // throws NPE
System.out.println("meep moop");
```
`CacheEntryListenerConfigImpl` is a bare minimum implementation, nothing fancy.
```
public class CacheEntryListenerConfigImpl implements CacheEntryListenerConfiguration {
@Override
public Factory> getCacheEntryListenerFactory() {
return () -> (CacheEntryCreatedListener) iterable -> System.out.println("henlo");
}
@Override
public boolean isOldValueRequired() {
return true;
}
@Override
public Factory> getCacheEntryEventFilterFactory() {
return null;
}
@Override
public boolean isSynchronous() {
return true;
}
}
```
The full exception is as follows.
```
Mar 02, 2025 7:01:47 PM org.apache.ignite.logger.java.JavaLogger error
SEVERE: Critical system error detected. Will be handled accordingly to configured handler [hnd=StopNodeOrHaltFailureHandler [tryStop=false, timeout=0, super=AbstractFailureHandler [ignoredFailureTypes=UnmodifiableSet [SYSTEM_WORKER_BLOCKED, SYSTEM_CRITICAL_OPERATION_TIMEOUT]]], failureCtx=FailureContext [type=CRITICAL_ERROR, err=class o.a.i.i.processors.cache.persistence.tree.CorruptedTreeException: B+Tree is corrupted [groupId=502692585, pageIds=[844420635166599], groupName=myCacheGroup, msg=Runtime failure on search row: SearchRow [key=KeyCacheObjectImpl [part=962, val=124117e0-e67c-4f9d-aed3-6e716da44e84, hasValBytes=true], hash=927627400, cacheId=-1368047377]]]]
class org.apache.ignite.internal.processors.cache.persistence.tree.CorruptedTreeException: B+Tree is corrupted [groupId=502692585, pageIds=[844420635166599], groupName=myCacheGroup, msg=Runtime failure on search row: SearchRow [key=KeyCacheObjectImpl [part=962, val=124117e0-e67c-4f9d-aed3-6e716da44e84, hasValBytes=true], hash=927627400, cacheId=-1368047377]]
at org.apache.ignite.internal.processors.cache.persistence.tree.BPlusTree.corruptedTreeException(BPlusTree.java:6046)
at org.apache.ignite.internal.processors.cache.persistence.tree.BPlusTree.invoke(BPlusTree.java:2171)
at org.apache.ignite.internal.processors.cache.IgniteCacheOffheapManagerImpl$CacheDataStoreImpl.invoke0(IgniteCacheOffheapManagerImpl.java:1497)
at org.apache.ignite.internal.processors.cache.IgniteCacheOffheapManagerImpl$CacheDataStoreImpl.invoke(IgniteCacheOffheapManagerImpl.java:1480)
at org.apache.ignite.internal.processors.cache.IgniteCacheOffheapManagerImpl.invoke(IgniteCacheOffheapManagerImpl.java:395)
at org.apache.ignite.internal.processors.cache.GridCacheMapEntry.innerUpdate(GridCacheMapEntry.java:1519)
at org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache.updateSingle(GridDhtAtomicCache.java:2546)
at org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache.update(GridDhtAtomicCache.java:2006)
at org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache.updateAllAsyncInternal0(GridDhtAtomicCache.java:1825)
at org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache.updateAllAsyncInternal(GridDhtAtomicCache.java:1698)
at org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridNearAtomicAbstractUpdateFuture.sendSingleRequest(GridNearAtomicAbstractUpdateFuture.java:294)
at org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridNearAtomicSingleUpdateFuture.map(GridNearAtomicSingleUpdateFuture.java:455)
at org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridNearAtomicSingleUpdateFuture.mapOnTopology(GridNearAtomicSingleUpdateFuture.java:415)
at org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridNearAtomicAbstractUpdateFuture.map(GridNearAtomicAbstractUpdateFuture.java:243)
at org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache.update0(GridDhtAtomicCache.java:1150)
at org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache.put0(GridDhtAtomicCache.java:601)
at org.apache.ignite.internal.processors.cache.GridCacheAdapter.put(GridCacheAdapter.java:1927)
at org.apache.ignite.internal.processors.cache.GridCacheAdapter.put(GridCacheAdapter.java:1906)
at org.apache.ignite.internal.processors.cache.IgniteCacheProxyImpl.put(IgniteCacheProxyImpl.java:1330)
at org.apache.ignite.internal.processors.cache.GatewayProtectedCacheProxy.put(GatewayProtectedCacheProxy.java:836)
at org.example.Main.main(Main.java:28)
Caused by: java.lang.NullPointerException
at org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryHandler.handleEvent(CacheContinuousQueryHandler.java:983)
at org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryHandler$2.skipUpdateCounter(CacheContinuousQueryHandler.java:580)
at org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryManager.skipUpdateCounter(CacheContinuousQueryManager.java:258)
at org.apache.ignite.internal.processors.cache.CacheGroupContext.onPartitionCounterUpdate(CacheGroupContext.java:1016)
at org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtLocalPartition.nextUpdateCounter(GridDhtLocalPartition.java:873)
at org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheEntry.nextPartitionCounter(GridDhtCacheEntry.java:105)
at org.apache.ignite.internal.processors.cache.GridCacheMapEntry$AtomicCacheUpdateClosure.update(GridCacheMapEntry.java:5049)
at org.apache.ignite.internal.processors.cache.GridCacheMapEntry$AtomicCacheUpdateClosure.call(GridCacheMapEntry.java:4785)
at org.apache.ignite.internal.processors.cache.GridCacheMapEntry$AtomicCacheUpdateClosure.call(GridCacheMapEntry.java:4470)
at org.apache.ignite.internal.processors.cache.persistence.tree.BPlusTree$Invoke.invokeClosure(BPlusTree.java:3942)
at org.apache.ignite.internal.processors.cache.persistence.tree.BPlusTree.invokeDown(BPlusTree.java:2248)
at org.apache.ignite.internal.processors.cache.persistence.tree.BPlusTree.invoke(BPlusTree.java:2138)
... 19 more
```
Reproduced with Ignite 2.17.0, OpenLogic OpenJDK 11.0.22.
Contributor guide
Research direction
Reproduce the cache1/cache2 sequence from the issue on Ignite 2.17.0 with OpenJDK 11, then inspect CacheContinuousQueryHandler.java:983 and the surrounding stack-trace calls. Done means the final cache1.put completes without the NullPointerException or reported B+Tree corruption, with regression coverage for this sequence.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- databases, distributed-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100