-
-
Notifications
You must be signed in to change notification settings - Fork 30.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Instead of attempting to acquire and release them all across fork which was leading to deadlocks in some applications that had chained their own handlers while holding multiple locks.
- Loading branch information
Showing
3 changed files
with
58 additions
and
40 deletions.
There are no files selected for viewing
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
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
6 changes: 6 additions & 0 deletions
6
Misc/NEWS.d/next/Library/2019-04-06-00-55-09.bpo-36533.kzMyRH.rst
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Reinitialize logging.Handler locks in forked child processes instead of | ||
attempting to acquire them all in the parent before forking only to be | ||
released in the child process. The acquire/release pattern was leading to | ||
deadlocks in code that has implemented any form of chained logging handlers | ||
that depend upon one another as the lock acquision order cannot be | ||
guaranteed. |
I'm not sure how it happened as it's veeery rare but MainThread from parent process somehow started
fork()
execution in situation when it already had_lock
. In the resultbefore=_acquireLock
caused counter incrementation 1->2 andafter_in_child=_after_at_fork_child_reinit_locks
caused only counter decrementation but MainThread still kept_lock
and never released it. Any another thread that wanted to log hung.Here is a child process that have exactly one thread so if no other thread is waiting here why not re-create global
_lock
object?