Skip to content

Add shard write-load to cluster info#131496

Merged
nicktindall merged 13 commits intoelastic:mainfrom
nicktindall:add_shard_write_load_to_cluster_info
Jul 21, 2025
Merged

Add shard write-load to cluster info#131496
nicktindall merged 13 commits intoelastic:mainfrom
nicktindall:add_shard_write_load_to_cluster_info

Conversation

@nicktindall
Copy link
Copy Markdown
Contributor

@nicktindall nicktindall commented Jul 18, 2025

We already use TransportIndicesStatsAction to retrieve size on disk for the disk threshold decider.

This PR just adds the Indexing stats to that request when the write load decider is enabled, and adds the returned shard write loads to the ClusterInfo.

We should be able to feed these into the simulator to properly account for shard movement.

Relates: ES-12419 & ES-12420

@nicktindall nicktindall added >non-issue :Distributed/Allocation All issues relating to the decision making around placing a shard (both master logic & on the nodes) labels Jul 18, 2025
@nicktindall nicktindall removed the request for review from DiannaHohensee July 18, 2025 03:30
@elasticsearchmachine
Copy link
Copy Markdown
Collaborator

Pinging @elastic/es-distributed-coordination (Team:Distributed Coordination)

@elasticsearchmachine elasticsearchmachine added Team:Distributed Coordination (obsolete) Meta label for Distributed Coordination team. Obsolete. Please do not use. v9.2.0 labels Jul 18, 2025
}
});
final Map<String, NodeUsageStatsForThreadPools> nodeThreadPoolUsageStats = new HashMap<>();
nodeThreadPoolUsageStatsPerNode.forEach((nodeId, nodeWriteLoad) -> { nodeThreadPoolUsageStats.put(nodeId, nodeWriteLoad); });
Copy link
Copy Markdown
Contributor Author

@nicktindall nicktindall Jul 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This appeared to be just a copy, which already happens in the ClusterInfo constructor, I assume remnants of something that was since refactored away.

Copy link
Copy Markdown
Contributor

@mhl-b mhl-b left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, nice

Copy link
Copy Markdown
Contributor

@DiannaHohensee DiannaHohensee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think all my comments are straightforward to address, so I'll go ahead and approve now 👍

ImmutableOpenMap.of(),
ImmutableOpenMap.of(),
ImmutableOpenMap.of()
);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like I missed a handful of these in the builder conversion 😏 Oops..

InternalClusterInfoService.buildShardLevelInfo(stats, shardSizes, shardDataSetSizes, routingToPath, new HashMap<>());
InternalClusterInfoService.buildShardLevelInfo(
stats,
shardWriteLoads,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Below there are checks on the results. Are there some checks that can be added for shardWriteLoads results?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added in c5ceb92

@@ -59,9 +59,10 @@ public class ClusterInfo implements ChunkedToXContent, Writeable {
final Map<NodeAndPath, ReservedSpace> reservedSpace;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The class comment further up ^ could use an update at this point.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in cfe5759

estimatedHeapUsages,
nodeThreadPoolUsageStats
nodeThreadPoolUsageStats,
allocation.clusterInfo().getShardWriteLoads()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be saved as a private variable initialized in the ClusterInfoSimulator constructor? Similar to estimatedHeapUsages and nodeThreadPoolUsageStats

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No we won't use it at this level in the ClusterInfoSimulator and I don't think we'll modify it as part of the simulation either so I think it's fine to pass it through.

public Map<ShardId, Double> getShardWriteLoads() {
return shardWriteLoads;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update the #equals, #hashCode methods below.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like that we add equals and hashCode just for testing, but I updated them in cd3169f

);

try {
// Force a ClusterInfo refresh to run collection of the node thread pool usage stats.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

copy-paste failed you here :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 7886659

}
}
// And that at least one is greater than zero
assertThat(maximumLoadRecorded, greaterThan(0.0));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this assert be per index? Since all the indices received writes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No we insert between 1 and 500 documents in indices with between 1 and 3 shards, so it's possible some shards will not be written to. This is just a sanity check anyhow.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think I follow. Some shards won't receive writes, I agree. But all indices will have writes (to at least one shard), and thus maximumLoadRecorded would have a value per index.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh sorry, you're right. For some reason I read that as per shard. Indeed it could be tightened up to be per index. I'll put up a small PR to do that.

@nicktindall nicktindall merged commit b371590 into elastic:main Jul 21, 2025
33 checks passed
@nicktindall nicktindall deleted the add_shard_write_load_to_cluster_info branch July 21, 2025 06:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Distributed/Allocation All issues relating to the decision making around placing a shard (both master logic & on the nodes) >non-issue Team:Distributed Coordination (obsolete) Meta label for Distributed Coordination team. Obsolete. Please do not use. v9.2.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants