Affects Version/s: None
While testing Mesos to see if we could use it at work, I encountered a random bug which I believe happens when a command exits really quickly, when run via the command executor.
See the attached test case, but basically all it does is constantly start "exit 0" tasks.
At some point, a task randomly fails with the error "Failed to get exit status for Command":
I've had a look at the code, and I found something which could potentially explain it - it's the first time I look at the code so apologies if I'm missing something.
We can see the error originates from `reaped`:
Looking at the code, we can see that the `status_` future can be set to `None` in `ReaperProcess::reap`:
So we could have this if the process has already been reaped (`kill -0` will fail).
Now, looking at the code path which spawns the process:
If we look at the bottom of the function we can see the following:
So at this point we've already called `process::reap`.
And after that, the executor also calls `process::reap`:
But if we look at the implementation of `process::reap`:
We can see that `ReaperProcess::reap` is going to get called asynchronously.
Doesn't this mean that it's possible that the first call to `reap` set up by `subprocess` (https://github.com/apache/mesos/blob/master/3rdparty/libprocess/src/subprocess.cpp#L462)
will get executed first, and if the task has already exited by that time, the child will get reaped before the call to `reap` set up by the executor (https://github.com/apache/mesos/blob/master/src/launcher/executor.cpp#L801) gets a chance to run?
In that case, when it runs
would return false, `reap` would set the future to None which would result in this error.