-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Create an end-to-end IT test for WriteLoadConstraintDecider#canAllocate #133500
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
Create an end-to-end IT test for WriteLoadConstraintDecider#canAllocate #133500
Conversation
…t assert non-immutable
Pinging @elastic/es-distributed-coordination (Team:Distributed Coordination) |
|
||
public NodeUsageStatsForThreadPools(StreamInput in) throws IOException { | ||
this(in.readString(), in.readMap(ThreadPoolUsageStats::new)); | ||
this(in.readString(), in.readImmutableMap(ThreadPoolUsageStats::new)); |
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.
I had to change the NodeUsageStatsForThreadPool constructor to read into an immutable map because the ShardMovements*Simulator expects an immutable map.
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.
LGTM, just some nits
protected Collection<Class<? extends Plugin>> getMockPlugins() { | ||
final Collection<Class<? extends Plugin>> plugins = new ArrayList<>(super.getMockPlugins()); | ||
plugins.add(MockTransportService.TestPlugin.class); | ||
return plugins; |
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.
Nit: maybe
return CollectionUtils.appendToCopy(super.nodePlugins(), MockTransportService.TestPlugin.class);
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.
Sure, done 👍 bb30938
indexName, | ||
Settings.builder().put(SETTING_NUMBER_OF_SHARDS, randomNumberOfShards).put(SETTING_NUMBER_OF_REPLICAS, 0).build() | ||
); | ||
index(indexName, Integer.toString(randomInt(10)), Collections.singletonMap("foo", "bar")); |
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.
Nit: maybe
indexRandom(false, indexName, 1);
to make it clear the ID and doc is not important?
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.
In fact is this even necessary? or does createIndex create all the shards?
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.
Shouldn't be necessary, good point. Removed and it works fine 👍
MockTransportService.getInstance(secondDataNodeName) | ||
.addRequestHandlingBehavior(IndicesStatsAction.NAME + "[n]", (handler, request, channel, task) -> { | ||
// Return no stats for the index because none are assigned to this node. | ||
TransportIndicesStatsAction instance = internalCluster().getInstance(TransportIndicesStatsAction.class, firstDataNodeName); |
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.
Should this be
internalCluster().getInstance(TransportIndicesStatsAction.class, secondDataNodeName);
Also below on the third one (maybe copy-paste error)? It probably doesn't matter because it doesn't look like NodeResponse
references anything from the enclosing class when used this way, but it's a bit confusing.
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.
Indeed it should be! Thanks!
*/ | ||
|
||
logger.info("---> Refreshing the cluster info to pull in the dummy thread pool stats with a hot-spotting node"); | ||
final InternalClusterInfoService clusterInfoService = (InternalClusterInfoService) internalCluster().getInstance( |
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.
Nit: maybe
final InternalClusterInfoService clusterInfoService = asInstanceOf(InternalClusterService.class, internalCluster.getInstance(...
Just to make it fail with an assertion error if it's not what we expect
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.
Nice, done 👍
DiscoveryNode discoveryNode, | ||
int totalWriteThreadPoolThreads, | ||
float averageWriteThreadPoolUtilization, | ||
long averageWriteThreadPoolQueueLatencyMillis |
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.
Isn't it max write thread pool queue latency?
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.
Copy-paste takes another victim. Fixed. Thanks!
averageWriteThreadPoolQueueLatencyMillis | ||
); | ||
var threadPoolUsageMap = new HashMap<String, NodeUsageStatsForThreadPools.ThreadPoolUsageStats>(); | ||
threadPoolUsageMap.put(ThreadPool.Names.WRITE, writeThreadPoolUsageStats); |
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.
Nit: maybe this is more succinct (and also results in an immutable singleton map)?
var threadPoolUsageMap = Map.of(ThreadPool.Names.WRITE, new NodeUsageStatsForThreadPools.ThreadPoolUsageStats(
totalWriteThreadPoolThreads,
averageWriteThreadPoolUtilization,
averageWriteThreadPoolQueueLatencyMillis
);
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.
Sure, immutable sounds like a win too 👍
|
||
/** | ||
* Helper to create a dummy {@link ShardStats} for the given index shard with the supplied {@code peekWriteLoad} value. | ||
*/ |
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.
Nit: peak
rather than peek
?
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.
Fixed 👍
.put( | ||
WriteLoadConstraintSettings.WRITE_LOAD_DECIDER_ENABLED_SETTING.getKey(), | ||
WriteLoadConstraintSettings.WriteLoadDeciderStatus.ENABLED | ||
) |
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.
Can we set the write load threshold explicitly (and randomly) and calculate the above/below thresholds based on that below? We're relying on defaults as it stands and they might change.
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.
Sure. IIUC, you're also proposing randomizing the node's reported thread pool utilization to somewhere above the random threshold? Updated as such. 5d3dd54
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.
Fixed up 👍 Thanks for the review Nick.
|
||
/** | ||
* Helper to create a dummy {@link ShardStats} for the given index shard with the supplied {@code peekWriteLoad} value. | ||
*/ |
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.
Fixed 👍
averageWriteThreadPoolQueueLatencyMillis | ||
); | ||
var threadPoolUsageMap = new HashMap<String, NodeUsageStatsForThreadPools.ThreadPoolUsageStats>(); | ||
threadPoolUsageMap.put(ThreadPool.Names.WRITE, writeThreadPoolUsageStats); |
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.
Sure, immutable sounds like a win too 👍
DiscoveryNode discoveryNode, | ||
int totalWriteThreadPoolThreads, | ||
float averageWriteThreadPoolUtilization, | ||
long averageWriteThreadPoolQueueLatencyMillis |
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.
Copy-paste takes another victim. Fixed. Thanks!
*/ | ||
|
||
logger.info("---> Refreshing the cluster info to pull in the dummy thread pool stats with a hot-spotting node"); | ||
final InternalClusterInfoService clusterInfoService = (InternalClusterInfoService) internalCluster().getInstance( |
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.
Nice, done 👍
MockTransportService.getInstance(secondDataNodeName) | ||
.addRequestHandlingBehavior(IndicesStatsAction.NAME + "[n]", (handler, request, channel, task) -> { | ||
// Return no stats for the index because none are assigned to this node. | ||
TransportIndicesStatsAction instance = internalCluster().getInstance(TransportIndicesStatsAction.class, firstDataNodeName); |
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.
Indeed it should be! Thanks!
indexName, | ||
Settings.builder().put(SETTING_NUMBER_OF_SHARDS, randomNumberOfShards).put(SETTING_NUMBER_OF_REPLICAS, 0).build() | ||
); | ||
index(indexName, Integer.toString(randomInt(10)), Collections.singletonMap("foo", "bar")); |
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.
Shouldn't be necessary, good point. Removed and it works fine 👍
protected Collection<Class<? extends Plugin>> getMockPlugins() { | ||
final Collection<Class<? extends Plugin>> plugins = new ArrayList<>(super.getMockPlugins()); | ||
plugins.add(MockTransportService.TestPlugin.class); | ||
return plugins; |
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.
Sure, done 👍 bb30938
.put( | ||
WriteLoadConstraintSettings.WRITE_LOAD_DECIDER_ENABLED_SETTING.getKey(), | ||
WriteLoadConstraintSettings.WriteLoadDeciderStatus.ENABLED | ||
) |
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.
Sure. IIUC, you're also proposing randomizing the node's reported thread pool utilization to somewhere above the random threshold? Updated as such. 5d3dd54
Closes ES-12620