Skip to content

SDK crashes when migrating Primary Key from String to UUID #8045

@koneksa-sunny

Description

@koneksa-sunny

SDK and version

SDK : Swift
Version: 10.33.0

Observations

  • How frequent do the crash occur? Everytime
  • Does it happen in production or during dev/test? Dev
  • Can the crash be reproduced by you? Yes
  • Can you provide instructions for how we can reproduce it? Change my primary key type from String to UUID. The migrationBlock is never called and the SDK crashes.

Crash log / stacktrace

realm-core/src/realm/object-store/shared_realm.cpp:474: [realm-core-12.13.0] Assertion failed: additive || (required_changes = ObjectStore::schema_from_group(read_group()).compare(schema)).empty()
0   RealmPackage                        0x000000010b074390 _ZN5realm4utilL18terminate_internalERNSt3__118basic_stringstreamIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE + 28
1   RealmPackage                        0x000000010b074370 _ZN5realm4util9terminateEPKcS2_lOSt16initializer_listINS0_9PrintableEE + 204
2   RealmPackage                        0x000000010abf7184 _ZN5realm5Realm13update_schemaENS_6SchemaEyNSt3__18functionIFvNS2_10shared_ptrIS0_EES5_RS1_EEENS3_IFvS5_EEEb + 1680
3   RealmPackage                        0x000000010a637b18 +[RLMRealm realmWithConfiguration:queue:error:] + 2528
4   RealmPackage                        0x000000010a6db4f4 $sSo8RLMRealmC13configuration5queueABSo0A13ConfigurationC_So012OS_dispatch_C0CSgtKcfCTO + 144
5   RealmPackage                        0x000000010a791a30 $s10RealmSwift0A0V13configuration5queueA2C13ConfigurationV_So012OS_dispatch_D0CSgtKcfC + 112
6   XXXXXXX                            0x0000000102f468e4 $XXXXXXXXX + 156
7   XXXXXXX                            0x0000000102f469e0 $sIegh_IeyBh_TR + 48
8   libdispatch.dylib                   0x0000000103d64ec0 _dispatch_call_block_and_release + 24
9   libdispatch.dylib                   0x0000000103d667b8 _dispatch_client_callout + 16
10  libdispatch.dylib                   0x0000000103d6eaac _dispatch_lane_serial_drain + 912
11  libdispatch.dylib                   0x0000000103d6f7b0 _dispatch_lane_invoke + 420
12  libdispatch.dylib                   0x0000000103d7c1f0 _dispatch_root_queue_drain_deferred_wlh + 324
13  libdispatch.dylib                   0x0000000103d7b75c _dispatch_workloop_worker_thread + 732
14  libsystem_pthread.dylib             0x00000001038df814 _pthread_wqthread + 284
15  libsystem_pthread.dylib             0x00000001038de5d4 start_wqthread

Steps & Code to Reproduce

I changed my primary key type from String to UUID
OLD:

public class MyClass: Object {
  @Persisted(primaryKey: true) public var id: String?

NEW:

public class MyClass: Object {
  @Persisted(primaryKey: true) public var id: UUID?

configuration:

      schemaVersion: 3,
      migrationBlock: { migration, oldSchemaVersion in
/// THIS IS NEVER CALLED
        if oldSchemaVersion == 1 {
        } else if oldSchemaVersion == 2 {
          migration.enumerateObjects(ofType: MyClass.className()) { oldObject, newObject in
            newObject!["id"] = UUID(uuidString: oldObject!["id"]! as! String)
          }
        }
      }

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions