# Deadlock in Bulk Ingester using Elastic 8.15.3 in Java

**URL:** <https://discuss.elastic.co/t/deadlock-in-bulk-ingester-using-elastic-8-15-3-in-java/370398>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [November 12, 2024, 12:56pm UTC](https://discuss.elastic.co/t/deadlock-in-bulk-ingester-using-elastic-8-15-3-in-java/370398 "2024-11-12T12:56:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Daniel\_Abadi](https://avatars.discourse-cdn.com/v4/letter/d/57b2e6/32.png) [@Daniel\_Abadi](https://discuss.elastic.co/u/Daniel_Abadi)\
**Post date:** [November 12, 2024, 12:56pm UTC](https://discuss.elastic.co/t/deadlock-in-bulk-ingester-using-elastic-8-15-3-in-java/370398/1 "2024-11-12T12:56:08Z")

</div>

Hello,

I'm experiencing a deadlock while using the bulk ingester, specifically during the flush operation. Several threads are blocked, each waiting with the following stack trace:

```auto
java.base/jdk.internal.misc.Unsafe.park(Native Method)
java.base/java.util.concurrent.locks.LockSupport.park(LockSupport.java:371)
java.base/java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionNode.block(AbstractQueuedSynchronizer.java:519)
java.base/java.util.concurrent.ForkJoinPool.unmanagedBlock(ForkJoinPool.java:3780)
java.base/java.util.concurrent.ForkJoinPool.managedBlock(ForkJoinPool.java:3725)
java.base/java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitUninterruptibly(AbstractQueuedSynchronizer.java:1660)
co.elastic.clients.elasticsearch._helpers.bulk.FnCondition.whenReadyIf(FnCondition.java:82)
co.elastic.clients.elasticsearch._helpers.bulk.BulkIngester.flush(BulkIngester.java:276)

```

Could you please assist in identifying what might be causing this issue and suggest any potential workarounds?

More info about the problem: maxConcurrentRequests equals to 1 and about 30 threads got stuck.

Thanks for your help!

---

<div class="post-metadata">

**Author:** ![ltrotta](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ltrotta/32/124003_2.png) [@ltrotta](https://discuss.elastic.co/u/ltrotta)\
**Post date:** [November 12, 2024, 2:16pm UTC](https://discuss.elastic.co/t/deadlock-in-bulk-ingester-using-elastic-8-15-3-in-java/370398/2 "2024-11-12T14:16:41Z")

</div>

Hello and welcome!

The BulkIngester had a known deadlock problem, until it was mostly solved in 8.15.2; "mostly" because there is still a user that is experiencing the issue even after the updates, but we couldn't reproduce it using the exact same code, so we concluded that it probably is something machine/OS related that we don't have control over.

You can read the [original issue on our github](https://github.com/elastic/elasticsearch-java/issues/651), in particular reading the comments to understand whether your problem could be solved by tweaking the BulkIngester configuration or changing the Listener implementation.

---

<div class="post-metadata">

**Author:** ![ltrotta](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ltrotta/32/124003_2.png) [@ltrotta](https://discuss.elastic.co/u/ltrotta)\
**Post date:** [November 12, 2024, 2:34pm UTC](https://discuss.elastic.co/t/deadlock-in-bulk-ingester-using-elastic-8-15-3-in-java/370398/3 "2024-11-12T14:34:19Z")

</div>

I just saw the edit with the additional information, so `maxConcurrentRequests` is a parameter that indicated how many requests will be sent in parallel to the elasticsearch server, and having just 1 request going out at a time with 30 adding threads will surely bottleneck the BulkIngester. Since even smaller deployments of the elasticsearch server can easily handle multiple requests at once, I suggest trying to increase `maxConcurrentRequests` to 10 and trying again.

---

<div class="post-metadata">

**Author:** ![Daniel\_Abadi](https://avatars.discourse-cdn.com/v4/letter/d/57b2e6/32.png) [@Daniel\_Abadi](https://discuss.elastic.co/u/Daniel_Abadi)\
**Post date:** [November 12, 2024, 3:22pm UTC](https://discuss.elastic.co/t/deadlock-in-bulk-ingester-using-elastic-8-15-3-in-java/370398/4 "2024-11-12T15:22:57Z")

</div>

Thanks! I upgraded the Elastic image from 8.12.1 to 8.15.3, and it resolved the issue.
