Skip to content

Commit 778f099

Browse files
authored
Improve incomplete tasks message in MasterService (#95321)
We assert that every `ClusterStateTaskExecutor` completes all the tasks in each batch, but today the assertion message is phrased using the internal terminology of the `MasterService` which makes no sense to most folks. This commit fixes the wording to make it easier to understand the problem.
1 parent 228fe1f commit 778f099

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

server/src/main/java/org/elasticsearch/cluster/service/MasterService.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -990,7 +990,7 @@ ContextPreservingAckListener getContextPreservingAckListener() {
990990

991991
@Override
992992
public String toString() {
993-
return "ExecutionResult[" + task + "]";
993+
return "TaskContext[" + task + "]";
994994
}
995995
}
996996

@@ -1007,14 +1007,20 @@ private static <T extends ClusterStateTaskListener> ClusterState executeTasks(
10071007
&& (resultingState.nodes().isLocalNodeElectedMaster() == false)) {
10081008
throw new AssertionError("update task submitted to MasterService cannot remove master");
10091009
}
1010-
assert assertAllTasksComplete(executionResults);
1010+
assert assertAllTasksComplete(executor, executionResults);
10111011
return resultingState;
10121012
}
10131013

1014-
private static <T extends ClusterStateTaskListener> boolean assertAllTasksComplete(List<ExecutionResult<T>> executionResults) {
1015-
for (final var executionResult : executionResults) {
1016-
assert executionResult.incomplete() == false : "missing result for " + executionResult;
1017-
}
1014+
private static <T extends ClusterStateTaskListener> boolean assertAllTasksComplete(
1015+
ClusterStateTaskExecutor<T> executor,
1016+
List<ExecutionResult<T>> executionResults
1017+
) {
1018+
final var incompleteTaskContexts = executionResults.stream().filter(ExecutionResult::incomplete).toList();
1019+
assert incompleteTaskContexts.isEmpty()
1020+
: "cluster state task executors must mark all tasks as successful or failed, but ["
1021+
+ executor
1022+
+ "] left the following tasks incomplete: "
1023+
+ incompleteTaskContexts;
10181024
return true;
10191025
}
10201026

0 commit comments

Comments
 (0)