# Will I face race condition when performing immediate deleteByQuery and indexing operation?

**URL:** <https://discuss.elastic.co/t/will-i-face-race-condition-when-performing-immediate-deletebyquery-and-indexing-operation/235270>\
**Category:** Elasticsearch\
**Created:** [June 2, 2020, 4:54am UTC](https://discuss.elastic.co/t/will-i-face-race-condition-when-performing-immediate-deletebyquery-and-indexing-operation/235270 "2020-06-02T04:54:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vidhyashankar\_Madhes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vidhyashankar_madhes/32/65695_2.png) [@Vidhyashankar\_Madhes](https://discuss.elastic.co/u/Vidhyashankar_Madhes)\
**Post date:** [June 2, 2020, 4:54am UTC](https://discuss.elastic.co/t/will-i-face-race-condition-when-performing-immediate-deletebyquery-and-indexing-operation/235270/1 "2020-06-02T04:54:13Z")

</div>

Query1 - deleteByquery which includes deletion of doc A

Query2 - index query on doc A (with refresh=true so that change will be immediately available)

ES Doc says that the deleteByQuery will take a snapshot of index and perform deletion on top of it.

I understand that If indexing of A happens after the snapshot has been taken for deleteByQuery, I will have version conflicts in my response.

Is there a possibility that the indexing happens before the snapshot being taken, and it gets deleted as a part for deleteByQuery even though the Query1 request was made before Query2?

i.e When I get a response for deleteByQuery (with refresh=false) can i be sure that the snapshot for deletion is taken and no further changes will be included in the deletion?

---

<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:** [June 30, 2020, 4:54am UTC](https://discuss.elastic.co/t/will-i-face-race-condition-when-performing-immediate-deletebyquery-and-indexing-operation/235270/2 "2020-06-30T04:54:29Z")

</div>

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