Skip to content

Commit 8ebe228

Browse files
Fail cancelled CS requests without redundant wait for state update (#96869)
Just fail the request right away if it got cancelled. Seems easier to reason about and fixes #95274 fixes #96071
1 parent 42b6976 commit 8ebe228

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

server/src/main/java/org/elasticsearch/action/admin/cluster/state/TransportClusterStateAction.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,10 @@ protected void masterOperation(
9292
? acceptableClusterStatePredicate
9393
: acceptableClusterStatePredicate.or(clusterState -> clusterState.nodes().isLocalNodeElectedMaster() == false);
9494

95-
if (acceptableClusterStatePredicate.test(state) && cancellableTask.isCancelled() == false) {
95+
if (cancellableTask.notifyIfCancelled(listener)) {
96+
return;
97+
}
98+
if (acceptableClusterStatePredicate.test(state)) {
9699
ActionListener.completeWith(listener, () -> buildResponse(request, state));
97100
} else {
98101
assert acceptableClusterStateOrFailedPredicate.test(state) == false;

0 commit comments

Comments
 (0)