elasticsearch/test
Moritz Mack dd4a892608
[8.16] Prevent work starvation bug if using scaling EsThreadPoolExecutor with core pool size = 0 (#124732) (#125069)
* Prevent work starvation bug if using scaling EsThreadPoolExecutor with core pool size = 0  (#124732)

When `ExecutorScalingQueue` rejects work to make the worker pool scale up while already being at max pool size (and a new worker consequently cannot be added), available workers might timeout just about at the same time as the task is then force queued by `ForceQueuePolicy`. This has caused starvation of work as observed for `masterService#updateTask` in #124667 where max pool size 1 is used. This configuration is most likely to expose the bug.

This PR changes `EsExecutors.newScaling` to not use `ExecutorScalingQueue` if max pool size is 1 (and core pool size is 0). A regular `LinkedTransferQueue` works perfectly fine in this case.

If max pool size > 1, a probing approach is used to ensure the worker pool is adequately scaled to at least 1 worker after force queueing work in `ForceQueuePolicy`.

Fixes #124667
Relates to #18613

(cherry picked from commit 36874e8663)

# Conflicts:
#	server/src/main/java/org/elasticsearch/threadpool/ScalingExecutorBuilder.java
#	test/framework/src/main/java/org/elasticsearch/test/transport/MockTransportService.java

* remove timeout

* [CI] Auto commit changes from spotless

---------

Co-authored-by: elasticsearchmachine <infra-root+elasticsearchmachine@elastic.co>
2025-03-18 21:02:43 +11:00
..
external-modules [8.16] Update Gradle wrapper to 8.13 (#122421) (#123876) 2025-03-06 02:08:55 +11:00
fixtures [Build] Update krb5kdc test fixture base image and krb5 library (#119403) (#119490) 2025-01-03 16:18:08 +01:00
framework [8.16] Prevent work starvation bug if using scaling EsThreadPoolExecutor with core pool size = 0 (#124732) (#125069) 2025-03-18 21:02:43 +11:00
immutable-collections-patch [8.16] [Gradle] Remove static use of BuildParams (#115122) (#117434) 2024-11-27 12:34:32 +01:00
logger-usage Add AGPLv3 as a supported license 2024-09-13 14:30:33 -07:00
metadata-extractor Include test features in feature name generation (#116078) (#116089) 2024-11-02 01:47:59 +11:00
test-clusters [Tests] Limit IOUtilTests on Windows (#124716) (#124729) 2025-03-13 23:04:17 +11:00
x-content Add AGPLv3 as a supported license 2024-09-13 14:30:33 -07:00
yaml-rest-runner Add AGPLv3 as a supported license 2024-09-13 14:30:33 -07:00
build.gradle Add AGPLv3 as a supported license 2024-09-13 14:30:33 -07:00