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

Freeze or disable autorefresh for old_realm inside a migration

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None

      The old_realm instance that Core hands to SDK during a migration callback should be frozen or have autorefresh turned off since there's no expectation that notifications from old_realm will be useful, especially when the schema is modified. We ran into a crash in dart (which is a GC language and we don't have mechanics in place to destroy objects created during a migration) by creating a results sorted on a property that will be renamed as part of the migration. When the migration completes, Core tries to refresh the collection and crashes with:

      terminating with uncaught exception of type realm::LogicError: Column does not exist
      Exception backtrace:
      0   librealm_dart.dylib                 0x0000000117715554 _ZN5realm10LogicErrorC1ENS0_9ErrorKindE + 52
      1   librealm_dart.dylib                 0x000000011771fa74 _ZNK5realm5Table12check_columnENS_6ColKeyE + 92
      2   librealm_dart.dylib                 0x00000001179ba87c _ZNK5realm3Obj7get_anyENS_6ColKeyE + 60
      3   librealm_dart.dylib                 0x0000000117a2233c _ZN5realm14BaseDescriptor6Sorter18cache_first_columnERNS0_10IndexPairsE + 176
      4   librealm_dart.dylib                 0x0000000117a4a788 _ZN5realm9TableView7do_sortERKNS_18DescriptorOrderingE + 600
      5   librealm_dart.dylib                 0x0000000117a49e20 _ZN5realm9TableView7do_syncEv + 528
      6   librealm_dart.dylib                 0x0000000117765dd8 _ZN5realm5_impl15ResultsNotifier3runEv + 660
      7   librealm_dart.dylib                 0x000000011775f3d8 _ZN5realm5_impl16RealmCoordinator19run_async_notifiersEv + 1748
      8   librealm_dart.dylib                 0x000000011775ec90 _ZN5realm5_impl16RealmCoordinator9on_changeEv + 24
      9   librealm_dart.dylib                 0x000000011774a4b0 _ZN5realm5_impl20ExternalCommitHelper6listenEv + 204
      10  librealm_dart.dylib                 0x000000011774a578 _ZNSt3__1L14__thread_proxyINS_5tupleIJNS_10unique_ptrINS_15__thread_structENS_14default_deleteIS3_EEEEZN5realm5_impl20ExternalCommitHelperC1ERNS8_16RealmCoordinatorEE3$_0EEEEEPvSE_ + 52
      11  libsystem_pthread.dylib             0x00000001a83a826c _pthread_start + 148
      12  libsystem_pthread.dylib             0x00000001a83a308c thread_start + 8
      

            Assignee:
            nicola.cabiddu@mongodb.com Nicola Cabiddu
            Reporter:
            nikola.irinchev@mongodb.com Nikola Irinchev
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: