Search code examples
javacachingignite

Is it possible to loose data or different data is present on different key in Ignite Cache?


I am using Ignite cluster on 3 Ignite nodes. In which, the cache which is operating has CacheAtomicityMode as Atomic and CacheMode as PARTITIONED.

Is it possible to lose data or use different data that is present on a different key?

Note: The data loading happens on the server side. It is possible that the same data with multiple objects will load on all the servers at same time

Cache Config:

CacheConfiguration<String, JsonObject> cacheConfig = new CacheConfiguration<>();
cacheConfig.setName("CACHE");
cacheConfig.setCacheMode(CacheMode.PARTITIONED);
cacheConfig.setAtomicityMode(CacheAtomicityMode.ATOMIC );
cacheConfig.setReadThrough(true);
cacheConfig.setBackups(2);
cacheConfig.setCacheStoreFactory(FactoryBuilder.factoryOf(ObjectLoader.class));
cacheConfig.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_ASYNC);
IgniteCache<String, JsonObject> cache = ignite.getOrCreateCache(cacheConfig);

Solution

  • If two nodes go down before it's finished copying the data to both backups, you might lose some data. You can change that by using the FULL_SYNC Write Synchronisation Mode.

    (Also worth noting: if you want to have all your data on all nodes, you can use the REPLICATED Cache Mode.)