ignite icon indicating copy to clipboard operation
ignite copied to clipboard

NullPointerException when performing operations on an IgniteCache

Open coolkarniomkar opened this issue 9 months ago • 1 comments

Hey guys!

We discovered that a NullPointerException is thrown by Ignite when trying to perform operations on cache1 in the following code snippet.

CacheConfiguration<UUID, UUID> cache1Config = new CacheConfiguration<>("cache1");
cache1Config.setGroupName("myCacheGroup");

CacheConfiguration<UUID, UUID> cache2Config = new CacheConfiguration<>("cache2");
cache2Config.setGroupName("myCacheGroup");

IgniteConfiguration cfg = new IgniteConfiguration();
Ignite ignite = Ignition.start(cfg);

IgniteCache<UUID, UUID> cache1 = ignite.getOrCreateCache(cache1Config);

IgniteCache<UUID, UUID> 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<UUID, UUID> {
    @Override
    public Factory<CacheEntryListener<? super UUID, ? super UUID>> getCacheEntryListenerFactory() {
        return () -> (CacheEntryCreatedListener<UUID, UUID>) iterable -> System.out.println("henlo");
    }

    @Override
    public boolean isOldValueRequired() {
        return true;
    }

    @Override
    public Factory<CacheEntryEventFilter<? super UUID, ? super UUID>> 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.

coolkarniomkar avatar Mar 02 '25 13:03 coolkarniomkar

Hello @coolkarniomkar , Please note that cache2.destroy(); will also destroy cache1 as per the internal referencing due to CacheEntryListener Registration, either destroy the cache later or recreate the cache1 after you destroy the cache2. - Thanks!

mokshit03 avatar Jul 01 '25 19:07 mokshit03