# Reindex job failing with search phase execution exception

**URL:** <https://forum.opensearch.org/t/reindex-job-failing-with-search-phase-execution-exception/15839>\
**Category:** OpenSearch\
**Created:** [September 11, 2023, 9:13am UTC](https://forum.opensearch.org/t/reindex-job-failing-with-search-phase-execution-exception/15839 "2023-09-11T09:13:12Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![makam.sreekanth](https://avatars.discourse-cdn.com/v4/letter/m/8dc957/32.png) [@makam.sreekanth](https://forum.opensearch.org/u/makam.sreekanth)\
**Post date:** [September 11, 2023, 9:13am UTC](https://forum.opensearch.org/t/reindex-job-failing-with-search-phase-execution-exception/15839/1 "2023-09-11T09:13:12Z")

</div>

**Versions** (relevant - OpenSearch/Dashboard/Server OS/Browser):  
Opensearch 1.0

**Describe the issue** :

Reindex job failing with search\_phase\_execution\_exception. We tried decreasing the batch size from default 1000 to 100 and still see the same issue. Any other options to try with?

**Configuration** :

**Relevant Logs or Screenshots** :

---

<div class="post-metadata">

**Author:** ![gaobinlong](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.opensearch.org/gaobinlong/32/5242_2.png) [@gaobinlong](https://forum.opensearch.org/u/gaobinlong)\
**Post date:** [September 12, 2023, 5:17am UTC](https://forum.opensearch.org/t/reindex-job-failing-with-search-phase-execution-exception/15839/2 "2023-09-12T05:17:58Z")

</div>

Can you show more information about your problem? Such as the full log of the `search_phase_execution_exception` and the reindex parameters.

---

<div class="post-metadata">

**Author:** ![makam.sreekanth](https://avatars.discourse-cdn.com/v4/letter/m/8dc957/32.png) [@makam.sreekanth](https://forum.opensearch.org/u/makam.sreekanth)\
**Post date:** [September 13, 2023, 9:13am UTC](https://forum.opensearch.org/t/reindex-job-failing-with-search-phase-execution-exception/15839/3 "2023-09-13T09:13:06Z")

</div>

API is very simple as below. We are running 10 parallel reindex jobs and under load we hit this

```auto
POST /_reindex
{
   "source":{
      "index":"sourceIndex",
     "size": 100
   },
   "dest":{
      "index":"destIndex"
   }
}

```

Below is the response from task api of that reindex operation

```auto
{
"completed": true,
"task": {
"node": "abc",
"id": 182462425,
"type": "transport",
"action": "indices:data/write/reindex",
"status": {
"total": 1629142,
"updated": 0,
"created": 128300,
"deleted": 0,
"batches": 1283,
"version_conflicts": 0,
"noops": 0,
"retries":

{ "bulk": 0, "search": 0 }

,
"throttled_millis": 0,
"requests_per_second": -1.0,
"throttled_until_millis": 0
},
"description": "reindex from [sourceIndex] to [destIndex1][_doc]",
"start_time_in_millis": 1694273514552,
"running_time_in_nanos": 1339667737279,
"cancellable": true,
"headers": {}
},
"error": {
"type": "search_phase_execution_exception",
"reason": "all shards failed",
"phase": "query",
"grouped": true,
"failed_shards": [
{
"shard": -1,
"index": null,
"reason":

{ "type": "search_context_missing_exception", "reason": "No search context found for id [61314384]" }

}
],
"caused_by":

{ "type": "search_context_missing_exception", "reason": "No search context found for id [61314384]" }

}
}

```

---

<div class="post-metadata">

**Author:** ![radu.gheorghe](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.opensearch.org/radu.gheorghe/32/3516_2.png) [@radu.gheorghe](https://forum.opensearch.org/u/radu.gheorghe)\
**Post date:** [September 15, 2023, 8:14am UTC](https://forum.opensearch.org/t/reindex-job-failing-with-search-phase-execution-exception/15839/4 "2023-09-15T08:14:21Z")

</div>

This likely means that the underlying [scroll](https://opensearch.org/docs/latest/api-reference/scroll/) expired. You could increase the timeout (which is really for processing each page), but the default `scroll` should be `5m`. So I’m assuming your OpenSearch cluster can’t keep up with the load, that it can’t process a page in 5 minutes…

Maybe you can run less reindexing jobs in parallel?

---

<div class="post-metadata">

**Author:** ![yeonghyeonKo](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.opensearch.org/yeonghyeonko/32/8202_2.png) [@yeonghyeonKo](https://forum.opensearch.org/u/yeonghyeonKo)\
**Post date:** [August 19, 2024, 5:49am UTC](https://forum.opensearch.org/t/reindex-job-failing-with-search-phase-execution-exception/15839/5 "2024-08-19T05:49:09Z")

</div>

@makam.sreekanth

As @radu.gheorghe said,

when you create heavy \_tasks for reindexing like:

```auto
POST _reindex?wait_for_completion=false
{
  "conflicts": "proceed",
  "source": {
    "index": ["abc.prd.reindex_2020"],
    "size": 100
  },
  "dest": {
    "index": "search.abc.prd",
    "version_type": "external"
  },
  "script": {
    "source": """
      ctx._source.DELETE_YN= 'N';
    """,
    "lang": "painless"
  }
}

```

you should insert **scroll** query parameter.  
Please increase from the default interval(`5m`) to the larger one(`1d`) or decrease **size** of \_source.

- [Reindex API | Elasticsearch Guide [8.15] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html)
- [Reindex document - OpenSearch Documentation](https://opensearch.org/docs/latest/api-reference/document-apis/reindex/)
