The way the LauncherServer acceptConnections thread schedules client timeouts causes (non-deterministically) the thread to die with the following exception if the machine is under very high load:
The issue is related to the ordering of actions that the acceptConnections thread uses to handle a client connection:
- create timeout action
- create client thread
- start client thread
- schedule timeout action
Under normal conditions the scheduling of the timeout action happen before the client thread has a chance to start, however if the machine is under very high load the client thread can receive CPU time before the timeout action gets scheduled.
If this condition happen, the client thread cancel the timeout action (which is not yet been scheduled) and goes on, but as soon as the acceptConnections thread gets the CPU back, it will try to schedule the timeout action (which has already been canceled) thus raising the exception.
Changing the order in which the client thread gets started and the timeout gets scheduled seems to be sufficient to fix this issue.
As stated above the issue is non-deterministic, I faced the issue multiple times on a single-node machine submitting a high number of short jobs sequentially, but I couldn't easily create a test reproducing the issue.