[SERVER-44906] Rollback should take global write lock while truncating oplog Created: 02/Dec/19 Updated: 06/Dec/22 |
|
| Status: | Backlog |
| Project: | Core Server |
| Component/s: | Replication |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | A. Jesse Jiryu Davis | Assignee: | Backlog - Replication Team |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||
| Assigned Teams: |
Replication
|
||||||||||||||||
| Participants: | |||||||||||||||||
| Description |
|
In ReplicationRecoveryImpl::_truncateOplogTo we lock the oplog's database and collection; however, we have a general principle that we can read from the oplog with a global IS lock, write to it without locking the database and collection. For example the oplog cap maintainer thread only takes the global IX lock to truncate old entries in OplogCapMaintainerThread::_deleteExcessDocuments. Let's change ReplicationRecoveryImpl to take the global X or IX lock (I'm not sure which) instead of locking the oplog's db and collection. |
| Comments |
| Comment by A. Jesse Jiryu Davis [ 30/Jan/20 ] | |||||||||||||||||||
|
Perhaps a new RAII type named like "AugutGetOplogForRead" could enforce the locking rules. It may also have a different default read timestamp from AutoGetCollection(ForRead), which could help prevent bugs like | |||||||||||||||||||
| Comment by A. Jesse Jiryu Davis [ 03/Dec/19 ] | |||||||||||||||||||
|
Same for StorageInterfaceImpl::waitForAllEarlierOplogWritesToBeVisible, which takes an IS lock on the oplog. It includes a comment:
| |||||||||||||||||||
| Comment by Eric Milkie [ 02/Dec/19 ] | |||||||||||||||||||
|
True. It won't hurt to clean this up then. I would use a Global IX lock for this. | |||||||||||||||||||
| Comment by A. Jesse Jiryu Davis [ 02/Dec/19 ] | |||||||||||||||||||
|
For consistency with the locking used in other parts of the code where we touch the oplog. In cases where we might write new code that touches the oplog (I'm working on this in | |||||||||||||||||||
| Comment by Eric Milkie [ 02/Dec/19 ] | |||||||||||||||||||
|
For what reason do you want to do this? |