Search code examples
elasticsearchelasticsearch-java-apielasticsearch-bulk-api

Is BulkIngester (replacement of 'Bulk Processor') in elasticsearch java api thread safe?


Use case: I have multiple kafka listeners for various topics. Each topic Listener will run in multiple threads (using spring's 'ConcurrentKafkaListenerContainer'). Listeners will be performing Update/Insert operations on Elasticsearch via its Java client (newer low-level client). I realized that performing bulk operations is very performant and hence will be doing that. Also found that the client library provides a very good utility called 'BulkIngester'(replacement of 'Bulk Processor' in previous versions) which is exactly what I needed.

Query: Since multiple thread will be adding update/insert operations to 'BulkIngester', I would like to understand if it is thread safe? As its user, do I need to take care of any synchronization?

Also, I did go through the 'BulkIngester' code and functionally understood how it is working. It also has code to perform synchronization but couldn't fully wrap my head around it.


Solution

  • Was it meant to be thread-safe? Yes. Is it truly thread-safe? That's a bit more difficult to answer. There are definitely some versions that are known to have thread safety issues and there are some indications that there are still some issues that need to be resolved.