Skip to content

Fix ThreadedActionListenerTests#testRejectionHandling#144795

Merged
DaveCTurner merged 11 commits intoelastic:mainfrom
DaveCTurner:2026/03/23/ThreadedActionListenerTests-testRejectionHandling-130129
Mar 26, 2026
Merged

Fix ThreadedActionListenerTests#testRejectionHandling#144795
DaveCTurner merged 11 commits intoelastic:mainfrom
DaveCTurner:2026/03/23/ThreadedActionListenerTests-testRejectionHandling-130129

Conversation

@DaveCTurner
Copy link
Copy Markdown
Member

Closes #130129

@DaveCTurner DaveCTurner requested a review from kingherc March 23, 2026 17:59
@DaveCTurner DaveCTurner added >test Issues or PRs that are addressing/adding tests :Distributed/Distributed A catch all label for anything in the Distributed Area. Please avoid if you can. branch:9.2 branch:8.19 v9.4.0 branch:9.3 labels Mar 23, 2026
@elasticsearchmachine elasticsearchmachine added Team:Distributed Meta label for distributed team. v9.3.3 v8.19.14 labels Mar 23, 2026
@elasticsearchmachine
Copy link
Copy Markdown
Collaborator

Pinging @elastic/es-distributed (Team:Distributed)

Copy link
Copy Markdown
Member Author

@DaveCTurner DaveCTurner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test had weak coverage because it would usually shut the threadpool down before doing anything else. Introduced another latch to delay the shutdown a bit, and also fixed the actual problem.

Comment on lines +80 to +81
if (pool.equals("fixed-bounded-queue") == false || forceExecution) {
assertTrue(esRejectedExecutionException.isExecutorShutdown());
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the key fix, we sometimes reject these tasks on the bounded queue before the executor is shut down.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit David just to understand, would they be rejected on the bounded queue because it's bounded? I.e., it happens that more than 10 listeners are submitted to it before they are actully triggered?

If so, I think a code comment above this fix would be nice as well.

Copy link
Copy Markdown
Contributor

@kingherc kingherc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM @DaveCTurner , just some nits for potentially improve readability, feel free to pick any of them as you see fit.

Comment on lines +80 to +81
if (pool.equals("fixed-bounded-queue") == false || forceExecution) {
assertTrue(esRejectedExecutionException.isExecutorShutdown());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit David just to understand, would they be rejected on the bounded queue because it's bounded? I.e., it happens that more than 10 listeners are submitted to it before they are actully triggered?

If so, I think a code comment above this fix would be nice as well.

public void testRejectionHandling() throws InterruptedException {
final var listenerCount = between(1, 1000);
final var countdownLatch = new CountDownLatch(listenerCount);
final var startLatch = new CountDownLatch(between(1, listenerCount));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit

Suggested change
final var startLatch = new CountDownLatch(between(1, listenerCount));
final var latchMinListenersToStartBeforeShutdown = new CountDownLatch(between(1, listenerCount));

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added a comment describing startLatch but I find such long symbol names to be somewhat hostile to readers so I'd rather keep it as-is.

final var listenerCount = between(1, 1000);
final var countdownLatch = new CountDownLatch(listenerCount);
final var startLatch = new CountDownLatch(between(1, listenerCount));
final var finishLatch = new CountDownLatch(listenerCount);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit

Suggested change
final var finishLatch = new CountDownLatch(listenerCount);
final var latchAllListenersCompleted = new CountDownLatch(listenerCount);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added a comment describing finishLatch but I find such long symbol names to be somewhat hostile to readers so I'd rather keep it as-is.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer the more descriptive version, to be honest.

This test is generally very hard to understand. I wonder if there's a way to reveal the intention of particular sections anyhow... and e.g. separate the "setup" "run" and "verification" parts of the test.

Just a loose idea.

@DaveCTurner DaveCTurner enabled auto-merge (squash) March 24, 2026 09:10
@DaveCTurner DaveCTurner added the auto-backport Automatically create backport pull requests when merged label Mar 24, 2026
@DaveCTurner DaveCTurner merged commit b50a0e6 into elastic:main Mar 26, 2026
36 checks passed
@elasticsearchmachine
Copy link
Copy Markdown
Collaborator

💔 Backport failed

Status Branch Result
9.3 Commit could not be cherrypicked due to conflicts
8.19 Commit could not be cherrypicked due to conflicts
9.2 Commit could not be cherrypicked due to conflicts

You can use sqren/backport to manually backport by running backport --upstream elastic/elasticsearch --pr 144795

szybia added a commit to szybia/elasticsearch that referenced this pull request Mar 26, 2026
* upstream/main: (146 commits)
  Revert "[Native] Gradle-related tweaks to improve handling of the simdvec native library (elastic#144539)"
  Fix ArrayIndexOutOfBoundsException in fetch phase with partial results (elastic#144385)
  ESQL: Correctly manage NULL data type for SUM (elastic#144942)
  [ESQL] Fixes GroupedTopNBenchmark not executing (elastic#144944)
  Fix reader context leak when query response serialization fails (elastic#144708)
  Validate individual offset values in BULK_OFFSETS bounds checks (elastic#144643)
  Merge main21 source set into main in simdvec (elastic#144921)
  [TEST] Unmute TsidExtractingIdFieldMapperTests (elastic#144848)
  [Native] Gradle-related tweaks to improve handling of the simdvec native library (elastic#144539)
  Fix `ThreadedActionListenerTests#testRejectionHandling` (elastic#144795)
  Add new DLM Frozen Tier Transition execution plugin and service (elastic#144595)
  Prometheus: execute query_range via parsed EsqlStatement plan (elastic#144416)
  Investigate `testBulkIndexingRequestSplitting` failure (elastic#144766)
  Add test utility for wrapping directories in FilterDirectory layer (elastic#143563)
  Fix ES|QL decay tests with negative scale (elastic#144657)
  Fix circuit breaker leak in percolator query construction (elastic#144827)
  Use XPerFieldDocValuesFormat in AbstractTSDBSyntheticIdCodec (elastic#144744)
  [DOCS] Document how reindex work in CPS (elastic#144016)
  Fix Int4 vector library tests failing on Java 21 (elastic#144830)
  [DiskBBQ] Fix index sorting on flush (elastic#144938)
  ...
@DaveCTurner DaveCTurner deleted the 2026/03/23/ThreadedActionListenerTests-testRejectionHandling-130129 branch March 26, 2026 12:44
@DaveCTurner
Copy link
Copy Markdown
Member Author

Backports:

seanzatzdev pushed a commit to seanzatzdev/elasticsearch that referenced this pull request Mar 26, 2026
seanzatzdev pushed a commit to seanzatzdev/elasticsearch that referenced this pull request Mar 27, 2026
mamazzol pushed a commit to mamazzol/elasticsearch that referenced this pull request Mar 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-backport Automatically create backport pull requests when merged :Distributed/Distributed A catch all label for anything in the Distributed Area. Please avoid if you can. Team:Distributed Meta label for distributed team. >test Issues or PRs that are addressing/adding tests v8.19.14 v9.2.8 v9.3.3 v9.4.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[CI] ThreadedActionListenerTests testRejectionHandling failing

4 participants