[ML] Wait for all shards to be active when creating the ML stats index #108202
+40
−22
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.
Several tests have started failing recently with the dread
no_shard_available_action_exception
when querying the.ml-stats
index. The error occurs when an index is accessed directly after creation before any shards have become active. See #65846 for more details.The recent failures stem from the change to invalidate the model cache in #106988. The cache is invalidated on PUT model which causes the models to be evicted and on eviction they persists stats to the
.ml-stats
index. The failing tests create a model causing the cache eviction and triggering a write to.ml-stats
, immediately after the test clean up kicks in and during the model deletion the.ml-stats
index is queried throwing theno_shard_available_action_exception
.The first part to wait for all shard to become active when creating the index but that isn't sufficient in itself as the writes to
.ml-stats
are async. Creating or deleting a model kicks off the write but it may not have completed so the post test clean up needs to wait for the.ml-stats
to initialise.Closes #106652
Closes #107815
Closes #107777
Closes #107505
Closes #80703