# Deletions failing until index is refreshed

**URL:** <https://discuss.elastic.co/t/deletions-failing-until-index-is-refreshed/373290>\
**Category:** Elasticsearch\
**Created:** [January 16, 2025, 6:19pm UTC](https://discuss.elastic.co/t/deletions-failing-until-index-is-refreshed/373290 "2025-01-16T18:19:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![buitcj](https://avatars.discourse-cdn.com/v4/letter/b/a587f6/32.png) [@buitcj](https://discuss.elastic.co/u/buitcj)\
**Post date:** [January 16, 2025, 6:19pm UTC](https://discuss.elastic.co/t/deletions-failing-until-index-is-refreshed/373290/1 "2025-01-16T18:19:18Z")

</div>

For a very small number of my elasticsearch instances, deletions are failing due to timeout and not succeeding until a refresh is performed. Might this be expected? Do refreshes trigger merges or something that will improve the execution time of a deletion? What should be the course of action? always perform a refresh before a deletion?

I am using `DeleteByQueryRequest` with `setAbortOnVersionConflict(false)` but it has been failing due to a timeout after 30s. Then when I try to perform the same query via curl (both GET and DELETE) command it complains about version conflict (\* and for another elasticsearch server instance there are no version conflicts detected and we're still hitting this problem)

```auto
curl -X GET "localhost:9200/my_index/_search" -H "Content-Type: application/json" -d'
{
  "query": {
    "range": {
      "timestamp": {
        "lt": "now-30d/d"
      }
    }
  }
}'

```

produces a long list of errors:

```auto
{"took":199,"timed_out":false,"total":6533538,"deleted":0,"batches":1,"version_conflicts":1000,"noops":0,"retries":{"bulk":0,"search":0},"throttled_millis":0,"requests_per_second":-1.0,"throttled_until_millis":0,"failures":[{"index":"my_index","id":"81df2426799e4f8cb0d4e31a75c3a110370283","cause":{"type":"version_conflict_engine_exception","reason":"[81df2426799e4f8cb0d4e31a75c3a110370283]: version conflict, required seqNo [44894562], primary term [4]. but no document was found","index_uuid":"zNhIQMVPTZ6CiC5lIWsujw","shard":"0","index":"my_index"},"status":409}...

```

Only after I refresh the index via `curl -X POST localhost:9200/my_index/_refresh`, does the deletion start working.
