[SERVER-35372] replSetSyncFrom can cause deadlock between ReplicationCoordinator and InitialSyncer Created: 04/Jun/18  Updated: 27/Oct/23  Resolved: 18/Jun/18

Status: Closed
Project: Core Server
Component/s: Replication
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Coverity Collector User Assignee: William Schultz (Inactive)
Resolution: Gone away Votes: 0
Labels: coverity
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-28840 replSetSyncFrom causes InitialSyncer ... Closed
related to SERVER-34758 replSetGetStatus can deadlock with in... Closed
related to SERVER-31487 Replace replSetSyncFrom resync option... Closed
Operating System: ALL
Sprint: Repl 2018-07-02
Participants:

 Description   

The InitialSync::_fcvFetcherCallback function acquires the InitialSync mutex and then acquires the ReplicationCoordinator mutex. This ordering is inconsistent with some functions in ReplicationCoordinator e.g. ReplicationCoordinatorImpl::processReplSetSyncFrom and ReplicationCoordinatorImpl::processReplSetGetStatus. At the time of writing this, the ReplicationCoordinator mutex acquisition was elimiinated in processReplSetGetStatus by SERVER-34758. The potential deadlock with processReplSetSyncFrom is mostly addressed already in SERVER-28840.

-------------------------

Original Coverity Description:

Threads may try to acquire two locks in different orders, potentially causing deadlock

Defect 103597 (STATIC_C)
Checker ORDER_REVERSAL (subcategory none)
File: /src/mongo/db/repl/initial_syncer.cpp
Function mongo::repl::InitialSyncer::_fcvFetcherCallback(const mongo::StatusWith<mongo::Fetcher::QueryResponse> &, std::shared_ptr<mongo::repl::CallbackCompletionGuard<mongo::StatusWith<mongo::repl::OpTimeWith<long long>>>>, const mongo::repl::OpTimeWith<long long> &)



 Comments   
Comment by William Schultz (Inactive) [ 18/Jun/18 ]

Will be fixed by SERVER-31487.

Comment by William Schultz (Inactive) [ 18/Jun/18 ]

Should also be fixed by SERVER-31487.

Comment by William Schultz (Inactive) [ 18/Jun/18 ]

Not going to mark this as a true duplicate of SERVER-28840, but that ticket describes the same basic issue. The only difference is that the lock acquisition order is in InitialSyncer::_fcvFetcherCallback in this ticket, not InitialSyncer::_multiApplierCallback.

Comment by William Schultz (Inactive) [ 18/Jun/18 ]

Claims that InitialSyncer::_fcvFetcherCallback calls DataReplicatorExternalStateImpl::getCurrentConfig() while holding InitialSyncer::_mutex. DataReplicatorExternalStateImpl::getCurrentConfig() will end up calling ReplicationCoordinatorImpl::getConfig() which will take the ReplicationCoordinator mutex. So the initial syncer will acquire ReplicationCoodrinator::_mutex while holding InitialSyncer::_mutex.

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