Skip to content

Commit 4d7f289

Browse files
Fail cancelled CS requests without redundant wait for state update (#101905)
Just fail the request right away if it got cancelled. Backports #96869 to 7.17 Closes #100671 Co-authored-by: Armin Braun <[email protected]>
1 parent 8206af4 commit 4d7f289

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
@@ -110,7 +110,10 @@ protected void masterOperation(
110110
? acceptableClusterStatePredicate
111111
: acceptableClusterStatePredicate.or(clusterState -> clusterState.nodes().isLocalNodeElectedMaster() == false);
112112

113-
if (acceptableClusterStatePredicate.test(state) && cancellableTask.isCancelled() == false) {
113+
if (cancellableTask.notifyIfCancelled(listener)) {
114+
return;
115+
}
116+
if (acceptableClusterStatePredicate.test(state)) {
114117
ActionListener.completeWith(listener, () -> buildResponse(request, state));
115118
} else {
116119
assert acceptableClusterStateOrFailedPredicate.test(state) == false;

0 commit comments

Comments
 (0)