[SERVER-28737] Have ephemeralForTest use std::mutex for protecting its internal data structures Created: 11/Apr/17  Updated: 06/Dec/17  Resolved: 25/Apr/17

Status: Closed
Project: Core Server
Component/s: Storage
Affects Version/s: None
Fix Version/s: 3.4.7, 3.5.7

Type: Task Priority: Major - P3
Reporter: Daniel Gottlieb (Inactive) Assignee: Daniel Gottlieb (Inactive)
Resolution: Done Votes: 0
Labels: bkp
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Depends
Backwards Compatibility: Fully Compatible
Backport Requested:
v3.4
Sprint: Storage 2017-04-17, Storage 2017-05-08
Participants:
Linked BF Score: 0

 Description   

The LockManager was used for ephemeralForTest reader/writer locks, but the LockManager has a limitation on the number of locks that can be taken by one thread at a time. Exceeding that limit now causes an exception to be thrown. Exceptions cannot safely escape catch blocks. `rollback` methods are called from within catch blocks and thus in no circumstances can throw. By implication, rollback methods cannot acquire locks managed by the LockManager.

The simple fix here is to replace the RW lock with a std[x]::mutex. This will prevent concurrent readers when using ephemeralForTest. However, because the critical section is fast and using a std::mutex is likely to be faster than managing RW locks, there may be no performance loss at all.



 Comments   
Comment by Githook User [ 05/Jul/17 ]

Author:

{u'username': u'dgottlieb', u'name': u'Daniel Gottlieb', u'email': u'daniel.gottlieb@mongodb.com'}

Message: SERVER-27831 SERVER-28737: Push threadsafety responsibility inside of KVCatalog's RecordStore

RecordStores that don't implement document level locking are typically
protected from concurrent reads and writes. However one exception is the
RecordStore passed into KVCatalog. Previously, if
StorageEngine::supportsDocLocking was false, the KVCatalog would use
an additional lock that participated in two phase locking to ensure
reader-writer protection to the underlying record store (and more
specifically, delay releasing until any potential rollbacks were
processed). However, access to the catalog can happen anywhere and this
lock did not have a formally assigned acquisition time relative to other
locks resulting in potential deadlocks.

This patch forces the thread-safety requirement into the RecordStore.
Specifically, EphemeralForTest was changed to acquire a finer grained
mutex (i.e: does not participate in two-phase locking) to protect its
internal state. Now that the lock exists inside EphemeralForTest, it is
also able to grab the mutex when needed for the onCommit/onRollback
callbacks.

(cherry picked from commit 71a149b45c8bb019cbc8179f4a411be66bda2062)
(cherry picked from commit 99d1ad9e6ef9bd270f9f668966a71596a71f7f72)
Branch: v3.4
https://github.com/mongodb/mongo/commit/b188121303e27761b34bfb67be0732c346999168

Comment by Githook User [ 25/Apr/17 ]

Author:

{u'username': u'dgottlieb', u'name': u'Daniel Gottlieb', u'email': u'daniel.gottlieb@10gen.com'}

Message: SERVER-28737: Have ephemeralForTest use std::mutex to not consume LockManager resources
Branch: master
https://github.com/mongodb/mongo/commit/99d1ad9e6ef9bd270f9f668966a71596a71f7f72

Generated at Thu Feb 08 04:18:55 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.