-
Notifications
You must be signed in to change notification settings - Fork 171
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix a deadlock with simultaneous sync and nonsync commit notification…
…s while tearing down RealmCoordinator The scenario which deadlocked is the following: Sync worker thread: Reporting a sync commit made to object store 1. SessionWrapper::report_sync_transact() 2. SyncSession::create_sync_session() wrapped_callback lambda holding strong reference to self and acquires SyncSession::m_state_mutex 3. RealmCoordinator::init_external_helpers() sync callback lambda Acquires strong refence to self, does some work, then releases it, triggering destructor 4. ~RealmCoordinator() 5. ~ExternalCommitHelper() 6. ExternalCommitHelper::m_thread::join() Waiting for the ECH thread to complete, while holding SyncSession::m_state_mutex Notifier thread: Trying to report a non-sync commit to sync 1. ExternalCommitHelper::listen() 2. void RealmCoordinator::on_change() 3. SyncSession::nonsync_transact_notify() Trying to acquire SyncSession::m_state_mutex To fix this, don't hold SyncSession::m_state_mutex while making the SyncSession -> RealmCoordinator call.
- Loading branch information
Showing
3 changed files
with
10 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters