javacachingignite

Apache Ignite ScanQuery on local node returns empty result


I have one server node and one client node. I create cache on the client node and put some objects there

CacheConfiguration<String, T> cfg = new CacheConfiguration<>();
cfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
cfg.setName("myCacheName");
cfg.setCacheMode(CacheMode.REPLICATED);
cfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
cfg.setRebalanceMode(CacheRebalanceMode.SYNC);

NearCacheConfiguration<String, T> nearCacheCfg = new NearCacheConfiguration<>();
nearCacheCfg.setNearEvictionPolicyFactory(new LruEvictionPolicyFactory<>(100_000));
cfg.setNearConfiguration(nearCacheCfg);
cache = ignite.getOrCreateCache(cfg);

Then I try to get all entries with ScanQuery and setLocal(true) option from the client node, but I get an empty result

try (var cursor = cache.query(new ScanQuery<>(null).setLocal(true))) {
    return cursor.getAll().stream()
        .map(Cache.Entry::getValue)
        .toList();
}

If I do this without setLocal(true) option, it works well, and I get all entiries.

If I use cache.localEntries(ALL).iterator(), I get all enitries too.

What's wrong with ScanQuery?


Solution

  • Therefore, local scan query always returns empty results on client node.

    Local scan query makes sense on server nodes only (e.g. within a Compute task).