[SERVER-36225] Do not hold replication mutex when calling getMinValid Created: 20/Jul/18  Updated: 29/Oct/23  Resolved: 07/Aug/18

Status: Closed
Project: Core Server
Component/s: Replication
Affects Version/s: None
Fix Version/s: 3.6.7, 4.0.2, 4.1.2

Type: Bug Priority: Major - P3
Reporter: Matthew Russotto Assignee: Tess Avitabile (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Depends
Related
is related to SERVER-36407 Use AutoCollection instead of AutoCol... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v4.0, v3.6
Sprint: Repl 2018-08-13
Participants:
Linked BF Score: 63

 Description   

It is not valid to read collections while holding the replication mutex. The reason is that reading a collection takes the global lock, which may be held by another thread, and that thread may be waiting on the replication mutex (e.g. by calling getMyLastAppliedOpTime).

Thus, _replicationProcess->getConsistencyMarkers->getMinValid must not be called with the replication mutex held, as it is in _finishLoadLocalConfig.

I believe we may simply release the repl mutex before checking !lastOpTime.isNull()

https://github.com/mongodb/mongo/blob/960fca37a78040d75d87f8049ef4c4a6227506cc/src/mongo/db/repl/replication_coordinator_impl.cpp#L598

Then re-acquire after calling getMinValid() (and remove the else clause).



 Comments   
Comment by Githook User [ 08/Aug/18 ]

Author:

{'username': 'tessavitabile', 'name': 'Tess Avitabile', 'email': 'tess.avitabile@mongodb.com'}

Message: SERVER-36225 Do not hold replication mutex when calling getMinValid

(cherry picked from commit 2c553eadb3b07fd324a7c4d5e8e02f21815d282e)
Branch: v3.6
https://github.com/mongodb/mongo/commit/d700ec58536c3191fd052a4f23cc694363911989

Comment by Githook User [ 08/Aug/18 ]

Author:

{'name': 'Tess Avitabile', 'email': 'tess.avitabile@mongodb.com', 'username': 'tessavitabile'}

Message: SERVER-36225 Do not hold replication mutex when calling getMinValid

(cherry picked from commit 2c553eadb3b07fd324a7c4d5e8e02f21815d282e)
Branch: v4.0
https://github.com/mongodb/mongo/commit/c3d9dfcaf0ba26fed34bb542a1eace9219e31664

Comment by Githook User [ 07/Aug/18 ]

Author:

{'username': 'tessavitabile', 'name': 'Tess Avitabile', 'email': 'tess.avitabile@mongodb.com'}

Message: SERVER-36225 Do not hold replication mutex when calling getMinValid
Branch: master
https://github.com/mongodb/mongo/commit/2c553eadb3b07fd324a7c4d5e8e02f21815d282e

Comment by Gregory McKeon (Inactive) [ 06/Aug/18 ]

When we close this, we should close SERVER-36407 as won't fix.

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