**Build scan:**
https://gradle-enterprise.elastic.co/s/ud4ggnomaa7p6/tests/:x-pack:plugin:ml:test/org.elasticsearch.xpack.ml.job.process.ProcessWorkerExecutorServiceTests/testAutodetectWorkerExecutorServiceDoesNotSwallowErrors
**Reproduction line:**
```
./gradlew ':x-pack:plugin:ml:test' --tests "org.elasticsearch.xpack.ml.job.process.ProcessWorkerExecutorServiceTests.testAutodetectWorkerExecutorServiceDoesNotSwallowErrors" -Dtests.seed=FCF6267296BD3EED -Dtests.locale=pl -Dtests.timezone=CST6CDT -Druntime.java=21
```

**Applicable branches:**
main

**Reproduces locally?:**
Yes

**Failure history:**
https://gradle-enterprise.elastic.co/scans/tests?tests.container=org.elasticsearch.xpack.ml.job.process.ProcessWorkerExecutorServiceTests&tests.test=testAutodetectWorkerExecutorServiceDoesNotSwallowErrors
**Failure excerpt:**
```
java.lang.Exception: Test abandoned because suite timeout was reached.

  at __randomizedtesting.SeedInfo.seed([FCF6267296BD3EED]:0)

```
x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/process/AbstractProcessWorkerExecutorService.java
}
    /**
     * Drains the queue of runnables and notifies each as either
     * a rejected execution or failure.
     *
     * Although public this method should be used with caution.
     * It should only be called _after_ the worker has shutdown.
     *
     * The method is synchronised to protect concurrent calls.
     */
    public synchronized void notifyQueueRunnables() {
        assert isShutdown() : "Queue runnables should only be drained and notified after the worker is shutdown";
        if (queue.isEmpty() == false) {
            List<Runnable> notExecuted = new ArrayList<>();
            queue.drainTo(notExecuted);
            String msg = "unable to process as " + processName + " worker service has shutdown";
            Exception ex = error.get();
            for (Runnable runnable : notExecuted) {
                if (runnable instanceof AbstractRunnable ar) {
                    if (ex != null) {
                        ar.onFailure(ex);
                    } else {
                        ar.onRejection(new EsRejectedExecutionException(msg, true));
                    }
                }
            }
        }
    }
}