Potential deadlock in batch span processor and periodic metric reader after puma fork child processes #1920
Closed
xuan-cao-swi
started this conversation in
General
Replies: 1 comment 1 reply
-
|
After did more research about thread.c from ruby, it seems like ruby interpreter will intentionally unlock all mutex after fork; so the problem probably is well-handled by ruby. Reference: |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
In Rails applications using Puma, Puma forks child processes when running in clustered mode. Components like
BatchSpanProcessorandPeriodicMetricReadercan restart their threads after forking, thanks to mechanisms likeafter_forkandreset_on_fork. However, I’ve noticed that the mutexes in these classes are not properly cleaned up (e.g., unlocked or reinitialized) after a fork. Since mutex objects and their states are copied to the child process, a locked mutex in the parent remains locked in the child. Attempting to lock it again in the child can cause a deadlock.Although I haven’t seen reports of this issue occurring in practice, it’s something developers should be aware of when working with Puma and mutexes
Beta Was this translation helpful? Give feedback.
All reactions