Uploaded image for project: 'Realm Core'
  1. Realm Core
  2. RCORE-2123

Deadlock involving async transactions and realm_open

    • Type: Icon: Bug Bug
    • Resolution: Won't Fix
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None

      Stack trace from the deadlock reported here: https://github.com/realm/realm-dart/issues/1675

      This issue do not occur with realm-dart 1.9.0 which is based on realm-core 13.26.0-13-gd12c3.

      One thread needs to update the schema, and hence tries to acquire the write lock, which is already held.

      Thread: io.futter.ui

      __psynch_cvwait (@__psynch_cvwait:5)
      _pthread_cond_wait (@_pthread_cond_wait:310)
      std::__1::condition_variable::wait(std::__1::unique_lock<std::__1::mutex>&) (@std::__1::condition_variable::wait(std::__1::unique_lock<std::__1::mutex>&):10)
      realm::DB::AsyncCommitHelper::blocking_begin_write() (@realm::DB::AsyncCommitHelper::blocking_begin_write():48)
      realm::Transaction::acquire_write_lock() (@realm::Transaction::acquire_write_lock():45)
      bool realm::Transaction::promote_to_write<realm::_impl::NullInstructionObserver>(realm::_impl::NullInstructionObserver*, bool) (@bool realm::Transaction::promote_to_write<realm::_impl::NullInstructionObserver>(realm::_impl::NullInstructionObserver*, bool):124)
      realm::Realm::update_schema(realm::Schema, unsigned long long, std::__1::function<void (std::__1::shared_ptr<realm::Realm>, std::__1::shared_ptr<realm::Realm>, realm::Schema&)>, std::__1::function<void (std::__1::shared_ptr<realm::Realm>)>, bool) (@realm::Realm::update_schema(realm::Schema, unsigned long long, std::__1::function<void (std::__1::shared_ptr<realm::Realm>, std::__1::shared_ptr<realm::Realm>, realm::Schema&)>, std::__1::function<void (std::__1::shared_ptr<realm::Realm>)>, bool):189)
      realm::_impl::RealmCoordinator::do_get_realm(realm::RealmConfig&&, std::__1::shared_ptr<realm::Realm>&, std::__1::optional<realm::VersionID>, realm::util::CheckedUniqueLock&, bool) (@realm::_impl::RealmCoordinator::do_get_realm(realm::RealmConfig&&, std::__1::shared_ptr<realm::Realm>&, std::__1::optional<realm::VersionID>, realm::util::CheckedUniqueLock&, bool):410)
      realm::_impl::RealmCoordinator::get_realm(realm::RealmConfig, std::__1::optional<realm::VersionID>) (@realm::_impl::RealmCoordinator::get_realm(realm::RealmConfig, std::__1::optional<realm::VersionID>):118)
      realm::Realm::get_shared_realm(realm::RealmConfig) (@realm::Realm::get_shared_realm(realm::RealmConfig):33)
      realm_open (@realm_open:22)
      ...
      

      Some other thread stacks at the time.

      Thread: Realm notification listener:

      kevent (@kevent:5)
      realm::_impl::ExternalCommitHelper::listen() (@realm::_impl::ExternalCommitHelper::listen():42)
      void* std::__1::__thread_proxy[abi:v160006]<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct>>, realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&, realm::RealmConfig const&)::$_0>>(void*) (@void* std::__1::__thread_proxy[abi:v160006]<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct>>, realm::_impl::ExternalCommitHelper::ExternalCommitHelper(realm::_impl::RealmCoordinator&, realm::RealmConfig const&)::$_0>>(void*):17)
      _pthread_start (@_pthread_start:37)
      

      Thread:

      __psynch_cvwait (@__psynch_cvwait:5)
      _pthread_cond_wait (@_pthread_cond_wait:310)
      std::__1::condition_variable::wait(std::__1::unique_lock<std::__1::mutex>&) (@std::__1::condition_variable::wait(std::__1::unique_lock<std::__1::mutex>&):10)
      realm::DB::AsyncCommitHelper::main() (@realm::DB::AsyncCommitHelper::main():32)
      void* std::__1::__thread_proxy[abi:v160006]<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct>>, realm::DB::AsyncCommitHelper::start_thread()::'lambda'()>>(void*) (@void* std::__1::__thread_proxy[abi:v160006]<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct>>, realm::DB::AsyncCommitHelper::start_thread()::'lambda'()>>(void*):16)
      _pthread_start (@_pthread_start:37)
      

            Assignee:
            jorgen.edelbo@mongodb.com Jørgen Edelbo
            Reporter:
            unitosyncbot Unito Sync Bot
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: