I have implemented a Custom CacheStore for Ignite to communicate with Elastic Search. Now, if ElasticSearch server is down for some time, will the data in the cache be uploaded to Elastic Search once the ES server is up?
4 Answers
Does Custom CacheStore for Ignite automatically do write-behind?
No. It is disabled by default: https://apacheignite.readme.io/docs/3rd-party-store#section-configuration
setWriteBehindEnabled(boolean) | Sets flag indicating whether write-behind is enabled. | false
Now, if ElasticSearch server is down for some time, will the data in the cache be uploaded to Elastic Search once the ES server is up?
No. Ignite will not send that data again. It is also specified in documentation:
Performance vs. Consistency
Enabling write-behind caching increases performance by performing
asynchronous updates, but this can lead to a potential drop in consistency as
some updates could be lost due to node failures or crashes.

- 4,500
- 1
- 17
- 27
-
This is not correct. Write-behind will lose data due to complete node failure, but *not* due to transient error in underlying DB. Such errors *will* be retried. – alamar Sep 16 '19 at 10:27
There is a write-behind mode, that doesn't write entries to the cache store once they are written to Ignite, but postpones them for some time, and then writes accumulated entries in a batch. When the write behind queue size reaches CacheConfiguration#writeBehindFlushSize, further operations are blocked until the queue is flushed. If the underlying database is unavailable for some time, then write operations will be retried until they succeed.
Write-behind documentation: https://apacheignite.readme.io/docs/3rd-party-store#section-write-behind-caching
As opposed to this mode, there is a write-through mode, that makes all operations go to the cache store once they are performed. If cache store fails to save the entry, the operation itself is rolled back.
Write-through documentation: https://apacheignite.readme.io/docs/3rd-party-store#section-read-through-and-write-through

- 3,573
- 8
- 13
If you enable writeBehind
in your CacheConfiguration
, Ignite will automatically add writeBehind functionality to your Cache Store. It will wrap your Cache Store with GridCacheWriteBehindStore
which implements all the delaying and batching functionality.
So yes, Ignite will automatically do write-behind if you enable it in config.

- 18,729
- 4
- 64
- 97
I think that since you are implementing a custom CacheStore, then you need to handle it on your own.
At the same time you may take a look at Apache Ignite write-behind mechanism that will accumulate updates in a queue and send them when required. In theory if you have enough memory for a large queue then it can help you to survive ElasticSearch server downtime. But bear in mind that with write-behind Ignite won't provide consistency guaranties.

- 2,350
- 1
- 6
- 10