-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Log NOT_PREFERRED shard movements #138069
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
nicktindall
merged 10 commits into
elastic:main
from
nicktindall:log_not_preferred_movements
Nov 15, 2025
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
d41aaea
Log NOT_PREFERRED shard movements
nicktindall 7a0455f
Log NOT_PREFERRED shard movements
nicktindall 9a1135b
Merge branch 'main' into log_not_preferred_movements
nicktindall 6bf362b
Add tests/finish implementation
nicktindall 7dfedbe
Log target node when making NOT_PREFERRED move
nicktindall ce79281
Merge remote-tracking branch 'origin/main' into log_not_preferred_mov…
nicktindall 3ba31a0
Remove rate-limiting
nicktindall c593950
Reduce change
nicktindall 848be0a
Fix test to fit new pattern
nicktindall aad4dfa
Merge branch 'main' into log_not_preferred_movements
nicktindall File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,6 +20,7 @@ | |
| import org.elasticsearch.cluster.routing.allocation.WriteLoadConstraintSettings; | ||
| import org.elasticsearch.common.FrequencyCappedAction; | ||
| import org.elasticsearch.common.settings.ClusterSettings; | ||
| import org.elasticsearch.core.Nullable; | ||
| import org.elasticsearch.core.Strings; | ||
| import org.elasticsearch.core.TimeValue; | ||
| import org.elasticsearch.threadpool.ThreadPool; | ||
|
|
@@ -154,14 +155,16 @@ public Decision canRemain(IndexMetadata indexMetadata, ShardRouting shardRouting | |
| var nodeWriteThreadPoolQueueLatencyThreshold = writeLoadConstraintSettings.getQueueLatencyThreshold(); | ||
| if (nodeWriteThreadPoolStats.maxThreadPoolQueueLatencyMillis() >= nodeWriteThreadPoolQueueLatencyThreshold.millis()) { | ||
| if (logger.isDebugEnabled() || allocation.debugDecision()) { | ||
| final Double shardWriteLoad = getShardWriteLoad(allocation, shardRouting); | ||
| final String explain = Strings.format( | ||
| """ | ||
| Node [%s] has a queue latency of [%d] millis that exceeds the queue latency threshold of [%s]. This node is \ | ||
| hot-spotting. Current thread pool utilization [%f]. Moving shard(s) away.""", | ||
| hot-spotting. Current thread pool utilization [%f]. Shard write load [%s]. Moving shard(s) away.""", | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add shard write load into explanation, so we can see it when we log the movement |
||
| node.nodeId(), | ||
| nodeWriteThreadPoolStats.maxThreadPoolQueueLatencyMillis(), | ||
| nodeWriteThreadPoolQueueLatencyThreshold.toHumanReadableString(2), | ||
| nodeWriteThreadPoolStats.averageThreadPoolUtilization() | ||
| nodeWriteThreadPoolStats.averageThreadPoolUtilization(), | ||
| shardWriteLoad == null ? "unknown" : shardWriteLoad | ||
| ); | ||
| if (logger.isDebugEnabled()) { | ||
| logCanRemainMessage.maybeExecute(() -> logger.debug(explain)); | ||
|
|
@@ -182,6 +185,11 @@ public Decision canRemain(IndexMetadata indexMetadata, ShardRouting shardRouting | |
| ); | ||
| } | ||
|
|
||
| @Nullable | ||
| private Double getShardWriteLoad(RoutingAllocation allocation, ShardRouting shardRouting) { | ||
| return allocation.clusterInfo().getShardWriteLoads().get(shardRouting.shardId()); | ||
| } | ||
|
|
||
| /** | ||
| * Calculates the change to the node's write thread pool utilization percentage if the shard is added to the node. | ||
| * Returns the percent thread pool utilization change. | ||
|
|
||
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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we have debug logging turned on for the
WriteLoadConstraintDeciderthe explanation will include the shard write load and the node utilisation.