Potential deadlock in batch span processor and periodic metric reader after puma fork child processes #1920
xuan-cao-swi
started this conversation in
General
Replies: 0 comments
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
BatchSpanProcessor
andPeriodicMetricReader
can restart their threads after forking, thanks to mechanisms likeafter_fork
andreset_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