forked from mongodb/mongo
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix remap private view memory leak and formalize w->X ugprade process.
Makes the upgrade R_to_W() block until it succeeds. Replaces "runExclusively" with a new "X" state, which is equivalent to "W", but can only be reached from "w". Client code in "w" calls "w_to_X()", which blocks until all other threads in "w" call w_to_X() or call unlock_w(). At that point, exactly one thread returns from w_to_X() with return value "true". This thread is the "exclusive writer", and may behave like it's in "W" state. When that thread calls "X_to_w()", it reverts to "w" state, and releases all the other threads that called w_to_X() back into "w" state. Because X_to_w() is effectively a barrier, we use generation counters to make sure that fast racers don't cause deadlocks or race through the barrier. The generation counters are generationX and generationXExit. Use of w_to_X() is wrapped in the Lock::DBWrite::UpgradeToExclusive() guard object, which has a "gotUpgrade()" method to check if a particular thread was the exclusive worker for the upgrade period. Decision making about which condition variables to notify is more fully delegated to the notifyWeUnlocked() method of QLock, to eliminate some inadvertent deadlocks due that surfaced when R_to_W() was made to wait until success. May help SERVER-5533, because it fixes a greediness logic bug exercised by fsync-and-lock. This patch also introduces a directed test of the w->X functionality, though it could use the addition of of extra "noise" work.
- Loading branch information
Andy Schwerin
committed
May 9, 2012
1 parent
a0d04bc
commit 15770de
Showing
5 changed files
with
489 additions
and
174 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
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
Oops, something went wrong.