[SERVER-35909] Create SessionLocker that checks for active transactions automatically Created: 29/Jun/18 Updated: 01/Nov/18 Resolved: 01/Nov/18 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Replication, Sharding |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Task | Priority: | Major - P3 |
| Reporter: | Judah Schvimer | Assignee: | Judah Schvimer |
| Resolution: | Duplicate | Votes: | 0 |
| Labels: | prepare_optional | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Participants: | |||||||||
| Description |
|
The pattern comes up a bunch of “lock the session mutex and then check if there is an active transaction” https://github.com/mongodb/mongo/blob/4e8b282809ba28eb2da14435a91981a3821343e1/src/mongo/db/session.cpp#L710-L715. Sometimes we call checkValid too. It’s not clear to me when we call one vs. the other. Making this clearer and providing a mechanism to lock the mutex and automatically make all of the required checks would prevent bugs and make the concurrency story clearer. |
| Comments |
| Comment by Judah Schvimer [ 29/Jun/18 ] |
|
My initial idea for this would be to create an RAII type SessionLock that wraps unique_lock. Whenever you call SessionLock::lock() it makes all the required checks and then locks the internal mutex. |