Re: Condition variable live lock
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Thomas Munro <thomas.munro@enterprisedb.com>
Cc: Andres Freund <andres@anarazel.de>, Robert Haas <robertmhaas@gmail.com>,
Pg Hackers <pgsql-hackers@postgresql.org>
Date: 2018-01-05T17:33:13Z
Lists: pgsql-hackers
Attachments
- remove-live-lock-in-CV-broadcast-2.patch (text/x-diff) patch
I wrote: > It's a question of how complicated you're willing to make this > logic, and whether you trust that we'll be able to test all the > code paths. Attached is a patch incorporating all the ideas mentioned in this thread, except that I think in HEAD we should change both ConditionVariableSignal and ConditionVariableBroadcast to return void rather than a possibly misleading wakeup count. This could be back-patched as is, though. As I feared, the existing regression tests are not really adequate for this: gcov testing shows that the sentinel-inserting code path is never entered, meaning ConditionVariableBroadcast never sees more than one waiter. What's more, it's now also apparent that no outside caller of ConditionVariableSignal ever actually awakens anything. So I think it'd be a good idea to expand the regression tests if we can do so cheaply. Anybody have ideas about that? Perhaps a new module under src/test/modules would be the best way? Alternatively, we could drop some of the optimization ideas. BTW, at least on gaur, this does nothing for the runtime of the join test, meaning I'd still like to see some effort put into reducing that. regards, tom lane
Commits
-
Add WL_EXIT_ON_PM_DEATH pseudo-event.
- cfdf4dc4fc96 12.0 landed
-
While waiting for a condition variable, detect postmaster death.
- 80259d4dbf47 11.0 landed
- d56a5f994c21 10.2 landed
-
Fix race condition during replication origin drop.
- 8a906204aec4 11.0 landed
- 1f5adbd799cf 10.2 landed
-
Allow ConditionVariable[PrepareTo]Sleep to auto-switch between CVs.
- 4af2190eb04b 10.2 landed
- 13db3b936359 11.0 landed
-
Cosmetic improvements in condition_variable.[hc].
- e35dba475a44 11.0 landed
-
Improve error detection capability in proclists.
- ea8e1bbc5384 11.0 landed
-
Remove return values of ConditionVariableSignal/Broadcast.
- ccf312a4488a 11.0 landed
-
Reorder steps in ConditionVariablePrepareToSleep for more safety.
- 83fe2708d668 10.2 landed
- 3cac0ec85992 11.0 landed
-
Rewrite ConditionVariableBroadcast() to avoid live-lock.
- aced5a92bf46 11.0 landed
- 1c77e990833a 10.2 landed
-
Add parallel-aware hash joins.
- 1804284042e6 11.0 cited