# Elasticsearch BulkRequestHandler listener callback execution

**URL:** <https://discuss.elastic.co/t/elasticsearch-bulkrequesthandler-listener-callback-execution/260978>\
**Category:** Elasticsearch\
**Created:** [January 13, 2021, 10:48am UTC](https://discuss.elastic.co/t/elasticsearch-bulkrequesthandler-listener-callback-execution/260978 "2021-01-13T10:48:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Faiz\_Ahmed\_Mushtak\_H](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/faiz_ahmed_mushtak_h/32/47387_2.png) [@Faiz\_Ahmed\_Mushtak\_H](https://discuss.elastic.co/u/Faiz_Ahmed_Mushtak_H)\
**Post date:** [January 13, 2021, 10:48am UTC](https://discuss.elastic.co/t/elasticsearch-bulkrequesthandler-listener-callback-execution/260978/1 "2021-01-13T10:48:55Z")

</div>

In line [https://github.com/elastic/elasticsearch/blob/master/server/src/main/java/org/elasticsearch/action/bulk/BulkRequestHandler.java#L58](https://github.com/elastic/elasticsearch/blob/master/server/src/main/java/org/elasticsearch/action/bulk/BulkRequestHandler.java#L58)

Curious why the semaphore is acquired after the beforeBulk callback? While not a big issue, I was hoping the entire bulk, right from its beginning till the end (inclusive of all the callbacks) be protected by the semaphore. Right now it's possible for N+1 instances of beforeBulk running concurrently where N = concurrency

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [February 10, 2021, 10:49am UTC](https://discuss.elastic.co/t/elasticsearch-bulkrequesthandler-listener-callback-execution/260978/2 "2021-02-10T10:49:20Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
