-
Notifications
You must be signed in to change notification settings - Fork 417
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(rcm): fix stuck child processes when a gevent application creates forks #5088
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
juanjux
changed the title
fix(rcm): stuck child processes when application creates forks
fix(rcm): fix stuck child processes when a gevent application creates forks
Feb 9, 2023
Signed-off-by: Juanjo Alvarez <juanjo.alvarezmartinez@datadoghq.com>
Signed-off-by: Juanjo Alvarez <juanjo.alvarezmartinez@datadoghq.com>
P403n1x87
reviewed
Feb 9, 2023
gnufede
reviewed
Feb 9, 2023
Signed-off-by: Juanjo Alvarez <juanjo.alvarezmartinez@datadoghq.com>
Signed-off-by: Juanjo Alvarez <juanjo.alvarezmartinez@datadoghq.com>
…error' into avara1986/APPSEC-8131-rcm-forks-error
emmettbutler
approved these changes
Feb 14, 2023
juanjux
previously approved these changes
Feb 15, 2023
gnufede
previously approved these changes
Feb 15, 2023
emmettbutler
previously approved these changes
Feb 17, 2023
avara1986
dismissed stale reviews from emmettbutler, gnufede, and juanjux
via
February 28, 2023 09:04
f73fc22
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Workaround (II) for remote config to work properly with gevent. We found that Remote Config create stuck/zombie child processes if an application with
gevent
usesos.fork
.What we do?
worker
hasPeriodicService
as parent andPeriodicService
use a worker too._stop_service
,stop
... using the same structure asTelemetryWriter
andSpanWriter
enable()
behavior. One of the previous fix (chore(iast): remote config thread workaround for gevent #4749) ensures that the Remote config worker thread is launched at the very end, not interrupting the gevent patching mechanism. Withforksafe.register(cls._restart)
we were calling twice toremoteconfig.enable()
: one at fork time (and it raises the same error of the previous fix) and once again at register the products in the child process (this call is ok)Caveat: this fix requires with env variable
DD_GEVENT_PATCH_ALL=true
but that's documented to be required on the gevent integration docs (we also added a reference to possible stuck processes if not set to ease the googleability of it).How to reproduce the error
Another way to check is run apachebenchmark (
ab
) like:And running the script in another console. Eventually, the Flask app will stop responding (usually with 7 processes running on my machine).
You could check the gevent infinite lock with:
or
Checklist
Reviewer Checklist