[SERVER-39279] Race between ServiceContext::ClientDeleter and waitForClientsToFinish() Created: 29/Jan/19  Updated: 29/Oct/23  Resolved: 13/Mar/19

Status: Closed
Project: Core Server
Component/s: Internal Code
Affects Version/s: None
Fix Version/s: 4.1.9

Type: Bug Priority: Major - P3
Reporter: Siyuan Zhou Assignee: Louis Williams
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
depends on SERVER-39079 Add parallel IndexBuildsCoordinator c... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Storage NYC 2019-03-25
Participants:
Linked BF Score: 61
Story Points: 2

 Description   

ServiceContext::ClientDeleter::operator()(Client* client) accesses the serviceContext outside the serviceContext's mutex to call the registered observers on onDestroy(), while the serviceContext may have already been destroyed by service_context_test_fixture, since the client vector is empty, checked by waitForClientsToFinish.

void ServiceContext::ClientDeleter::operator()(Client* client) const {
    ServiceContext* const service = client->getServiceContext();
    {
        stdx::lock_guard<stdx::mutex> lk(service->_mutex);
        invariant(service->_clients.erase(client));
        if (service->_clients.empty()) {
            service->_clientsEmptyCondVar.notify_all();
        }
    }
    // The serviceContext may have already been destroyed.
    onDestroy(client, service->_clientObservers);
    delete client;
}



 Comments   
Comment by Githook User [ 13/Mar/19 ]

Author:

{'name': 'Louis Williams', 'email': 'louis.williams@mongodb.com', 'username': 'louiswilliams'}

Message: SERVER-39279 Remove ServiceContext::waitForClientsToFinish
Branch: master
https://github.com/mongodb/mongo/commit/3b699913831031091fbba8a2a91178ef7826cf8b

Comment by Sara Williamson [ 11/Mar/19 ]

The work for this ticket should remove waitForClientsToFinish()

Comment by Siyuan Zhou [ 29/Jan/19 ]

Assigning to Storage team since the waitForClientsToFinish() was introduced in SERVER-37270. Perhaps Platform team can also take this. CC louis.williams.

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