Repository navigation
[Transform] Honor cluster health wait timeout when ensuring system index shards are active - #149462
Merged
prwhelan merged 10 commits intoJun 15, 2026
Merged
Conversation
`waitForLatestVersionedIndexShardsActive` issues a `ClusterHealth` request that waits up to 30s for at least one active shard of the transform internal index. The listener previously dispatched any non-exceptional response straight to `onResponse(null)`, including responses where `isTimedOut() == true`. As a result a PUT transform call could proceed to write its config even when the system index shards were not actually ready, surfacing later as obscure failures. Treat `isTimedOut() == true` as a failure and complete the listener with an `ElasticsearchStatusException(SERVICE_UNAVAILABLE)` so the client gets an actionable 503 and can retry. Closes elastic#149400
Collaborator
|
Pinging @elastic/ml-core (Team:ML) |
prwhelan
approved these changes
Jun 3, 2026
prwhelan
left a comment
Member
There was a problem hiding this comment.
Looks good - thank you for the contribution
prwhelan
enabled auto-merge (squash)
June 4, 2026 19:15
Member
|
In queue, will merge Monday June 15th |
This was referenced Jun 15, 2026
Collaborator
elasticsearchmachine
pushed a commit
that referenced
this pull request
Jun 15, 2026
…dex shards are active (#149462) (#151226) `waitForLatestVersionedIndexShardsActive` issues a `ClusterHealth` request that waits up to 30s for at least one active shard of the transform internal index. The listener previously dispatched any non-exceptional response straight to `onResponse(null)`, including responses where `isTimedOut() == true`. As a result a PUT transform call could proceed to write its config even when the system index shards were not actually ready, surfacing later as obscure failures. Treat `isTimedOut() == true` as a failure and complete the listener with an `ElasticsearchStatusException(SERVICE_UNAVAILABLE)` so the client gets an actionable 503 and can retry. Closes #149400 Co-authored-by: Tron Wang <59386838+rnb-tron@users.noreply.github.com>
elasticsearchmachine
pushed a commit
that referenced
this pull request
Jun 15, 2026
…dex shards are active (#149462) (#151228) `waitForLatestVersionedIndexShardsActive` issues a `ClusterHealth` request that waits up to 30s for at least one active shard of the transform internal index. The listener previously dispatched any non-exceptional response straight to `onResponse(null)`, including responses where `isTimedOut() == true`. As a result a PUT transform call could proceed to write its config even when the system index shards were not actually ready, surfacing later as obscure failures. Treat `isTimedOut() == true` as a failure and complete the listener with an `ElasticsearchStatusException(SERVICE_UNAVAILABLE)` so the client gets an actionable 503 and can retry. Closes #149400 Co-authored-by: Tron Wang <59386838+rnb-tron@users.noreply.github.com>
elasticsearchmachine
pushed a commit
that referenced
this pull request
Jun 15, 2026
…dex shards are active (#149462) (#151227) `waitForLatestVersionedIndexShardsActive` issues a `ClusterHealth` request that waits up to 30s for at least one active shard of the transform internal index. The listener previously dispatched any non-exceptional response straight to `onResponse(null)`, including responses where `isTimedOut() == true`. As a result a PUT transform call could proceed to write its config even when the system index shards were not actually ready, surfacing later as obscure failures. Treat `isTimedOut() == true` as a failure and complete the listener with an `ElasticsearchStatusException(SERVICE_UNAVAILABLE)` so the client gets an actionable 503 and can retry. Closes #149400 Co-authored-by: Tron Wang <59386838+rnb-tron@users.noreply.github.com>
valeriy42
pushed a commit
to valeriy42/elasticsearch
that referenced
this pull request
Jun 18, 2026
…dex shards are active (elastic#149462) `waitForLatestVersionedIndexShardsActive` issues a `ClusterHealth` request that waits up to 30s for at least one active shard of the transform internal index. The listener previously dispatched any non-exceptional response straight to `onResponse(null)`, including responses where `isTimedOut() == true`. As a result a PUT transform call could proceed to write its config even when the system index shards were not actually ready, surfacing later as obscure failures. Treat `isTimedOut() == true` as a failure and complete the listener with an `ElasticsearchStatusException(SERVICE_UNAVAILABLE)` so the client gets an actionable 503 and can retry. Closes elastic#149400 Co-authored-by: Pat Whelan <pat.whelan@elastic.co>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix
TransformInternalIndex#waitForLatestVersionedIndexShardsActivetotreat a
ClusterHealthtimeout as a failure instead of silentlycompleting the listener with success.
Closes #149400
Background
When a transform is created via
PUT _transform/{id}, the action callsTransformInternalIndex#createLatestVersionedIndexIfRequired. If theversioned internal index already exists but its shards are not yet
active, the code falls back to
waitForLatestVersionedIndexShardsActive,which issues a
ClusterHealthrequest that waits up to 30 seconds forat least one active shard.
The previous implementation handled the response like this:
Any non-exceptional response — including timeouts where
ClusterHealthResponse#isTimedOut()returnstrue— was forwardedstraight to
onResponse(null). As a result the caller assumed thesystem index was ready and proceeded to write the transform config,
which would later surface as confusing downstream failures.
What changed
In
TransformInternalIndex#waitForLatestVersionedIndexShardsActive:response.isTimedOut()before completing the listener.ElasticsearchStatusException(SERVICE_UNAVAILABLE)carrying adedicated message constant so the REST layer returns an actionable
503and the client can retry.listener.delegateFailureAndWrapstyle (consistent with
IndexBasedTransformConfigManagerand manyother call sites in the module).
In
TransformMessages:TRANSFORM_WAIT_FOR_INDEX_SHARDS_ACTIVE_TIMEOUT = "Timed out waiting for transform system index shards to become active".Tests
Added
TransformInternalIndexTests#testCreateLatestVersionedIndexIfRequired_GivenClusterHealthTimeoutwhich:
are not active, forcing the code into the
waitFor…branch.ClusterHealthResponsewith
setTimedOut(true).ElasticsearchStatusException, thatstatus() == RestStatus.SERVICE_UNAVAILABLE, and that the messagematches
TransformMessages.TRANSFORM_WAIT_FOR_INDEX_SHARDS_ACTIVE_TIMEOUT.Behavior change
onFailurepropagatedonFailurepropagated (unchanged)onResponse(null)onFailure(503 SERVICE_UNAVAILABLE)This is a user-visible behavior change: callers that previously
appeared to succeed (and then failed later in a confusing way) will now
receive a clear
503they can retry. No transport version orserialization changes are required.