Skip to content

Commit 83c19ae

Browse files
authored
Ensure tasks with banned parents always get cancelled (#90188) (#90248)
The check used to entirely skip parent lookup relies on ConcurrentHashMap#isEmpty() which could return inconsistent results, and potentially skip the cancellation of a task with a banned parent upon registration, and it doesn't seem to have a benefit considering the hash code computation. Closes #88201
1 parent 08aa7c0 commit 83c19ae

File tree

2 files changed

+2
-5
lines changed

2 files changed

+2
-5
lines changed

qa/smoke-test-http/src/javaRestTest/java/org/elasticsearch/http/IndicesSegmentsRestCancellationIT.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@
1111
import org.apache.http.client.methods.HttpGet;
1212
import org.elasticsearch.action.admin.indices.segments.IndicesSegmentsAction;
1313
import org.elasticsearch.client.Request;
14-
import org.elasticsearch.test.junit.annotations.TestLogging;
1514

16-
@TestLogging(value = "org.elasticsearch.tasks.TaskManager:TRACE,org.elasticsearch.test.TaskAssertions:TRACE", reason = "debugging")
1715
public class IndicesSegmentsRestCancellationIT extends BlockedSearcherRestCancellationTestCase {
1816
public void testIndicesSegmentsRestCancellation() throws Exception {
1917
runTest(new Request(HttpGet.METHOD_NAME, "/_segments"), IndicesSegmentsAction.NAME);

server/src/main/java/org/elasticsearch/tasks/TaskManager.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,8 @@ private void registerCancellableTask(Task task) {
148148
CancellableTask cancellableTask = (CancellableTask) task;
149149
CancellableTaskHolder holder = new CancellableTaskHolder(cancellableTask);
150150
cancellableTasks.put(task, holder);
151-
// Check if this task was banned before we start it. The empty check is used to avoid
152-
// computing the hash code of the parent taskId as most of the time bannedParents is empty.
153-
if (task.getParentTaskId().isSet() && bannedParents.isEmpty() == false) {
151+
// Check if this task was banned before we start it.
152+
if (task.getParentTaskId().isSet()) {
154153
final Ban ban = bannedParents.get(task.getParentTaskId());
155154
if (ban != null) {
156155
try {

0 commit comments

Comments
 (0)