On AWS Lambda, node process become zombie process #337
+1
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello.
The current code calls terminate on the return value wait_thread of Open3.popen3. wait_thread represents the management thread for calling wait/waitpid. When terminate is called, wait/waitpid will no longer be invoked.
On some AWS Lambda and Docker containers, the process with process id 1 does not clean up the process table. As a result, the node.js process becomes a zombie process.
Referring to the Open3.popen3 call to set block arguments, it seems correct to call join for wait_thread.
https://github.com/ruby/open3/blob/b8909222051b4103a19eba19506727faece252e7/lib/open3.rb#L533-L547
I have created a file to check the behavior in a local Docker container, which is attached.
reproduction.zip
Builds a container image of the current code with build-arg APPLY_PATCH as an empty string. When executed, the node process becomes a zombie.
If build-arg APPLY_PATCH is set to a value, it builds a container image with patch applied. The node process will not become a zombie when executed.