Uploaded image for project: 'Realm Cocoa SDK'
  1. Realm Cocoa SDK
  2. RCOCOA-1906

Crash due to duplicate primary key of an object that should have been deleted

      How frequently does the bug occur?

      Sometimes

      Description

      premise

      • person has an array of dog
      • dog has already been added to the realm
      • dog has a primary key

      Delete and then add.

      try realm.write {
         realm.delete(dog)
      }
      
      try realm.write {
         person.dogs.append(dog)
      }
      

      Sometimes crashes when adding.
      The actual code is more complex.
      What I want to know is not so much the solution, but why it crashes.
      Since it takes time to delete an object, we expected that it had not yet been deleted when we added it.
      But I'm not sure, because I think I saw somewhere that it should be fast enough that you don't have to take processing time into account.

      Stacktrace & log output

      Unable to find source-code formatter for language: shell. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      Attempting to create an object of type 'XXX' with an existing primary key value 'XXX'.
      

      Can you reproduce the bug?

      Yes, sometimes

      Reproduction Steps

      No response

      Version

      10.25.0

      What SDK flavour are you using?

      MongoDB Realm (i.e. Sync, auth, functions)

      Are you using encryption?

      No, not using encryption

      Platform OS and version(s)

      iOS 14-16

      Build environment

      Xcode version: ...
      Dependency manager and version: ...

            Assignee:
            Unassigned Unassigned
            Reporter:
            unitosyncbot Unito Sync Bot
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: