Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Orphaned embedded objects are not deleted when migrating from Object to Embedded Object #1464

Closed
sipersso opened this issue Jul 28, 2023 · 8 comments · Fixed by #1473
Closed

Comments

@sipersso
Copy link

sipersso commented Jul 28, 2023

How frequently does the bug occur?

  • select --

Description

According this ticket migration from object to embedded should now be automatic in core and orphaned children should automatically be deleted: realm/realm-core#5737

This doesn't seem to work in the Kotlin SDK. I have a unit test where I have an orphaned object and do an upgrade. Instead of deleting the orphaned object, the migration fails and the app crashes. I have no such issues on iOS

Stacktrace & log output

java.lang.IllegalStateException: [RLM_ERR_ILLEGAL_OPERATION]: Cannot convert 'MyEmbeddedObject:' to embedded: at least one object has no incoming links and would be deleted.
at io.realm.kotlin.internal.interop.CoreErrorConverter.asThrowable(CoreErrorConverter.kt:44)
at io.realm.kotlin.internal.interop.realmcJNI.open_realm_with_scheduler(Native Method)
at io.realm.kotlin.internal.interop.realmc.open_realm_with_scheduler(realmc.java:1757)
at io.realm.kotlin.internal.interop.RealmInterop.realm_open(RealmInterop.kt:194)
at io.realm.kotlin.internal.interop.RealmInterop.realm_open$default(RealmInterop.kt:183)
at io.realm.kotlin.internal.ConfigurationImpl.openRealm$suspendImpl(ConfigurationImpl.kt:110)
at io.realm.kotlin.internal.ConfigurationImpl.openRealm(Unknown Source:0)
at io.realm.kotlin.internal.RealmImpl$1.invokeSuspend(RealmImpl.kt:125)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:284)
at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:85)
at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:59)
at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source:1)
at io.realm.kotlin.internal.platform.CoroutineUtilsSharedJvmKt.runBlocking(CoroutineUtilsSharedJvm.kt:22)
at io.realm.kotlin.internal.platform.CoroutineUtilsSharedJvmKt.runBlocking$default(CoroutineUtilsSharedJvm.kt:21)
at io.realm.kotlin.internal.RealmImpl.<init>(RealmImpl.kt:107)
at io.realm.kotlin.internal.RealmImpl.<init>(Unknown Source:0)
at io.realm.kotlin.internal.RealmImpl$Companion.create$io_realm_kotlin_library(RealmImpl.kt:285)
at io.realm.kotlin.Realm$Companion.open(Realm.kt:82)

Can you reproduce the bug?

Always

Reproduction Steps

No response

Version

1.10.1

What Atlas App Services are you using?

  • select --

Are you using encryption?

  • select --

Platform OS and version(s)

Android

Build environment

Android Studio version: ...
Android Build Tools version: ...
Gradle version: ...

@sipersso
Copy link
Author

I assume that this is exactly the same issue that used to be in the Java SDK: realm/realm-java#7769 and was fixed by realm/realm-java#7772

@rorbech
Copy link
Contributor

rorbech commented Jul 31, 2023

Hi @sipersso. Thanks for the report. It is a bit different in Kotlin as we do not yet support manual migration and can handle this on a per class basis. Only option in Kotlin is to set the default behavior on the configuration. We will see to expose that option on the configuration.

@sipersso
Copy link
Author

I don't understand. I did supply a migration block and was able to do the same workaround as I was previously using in java before it was handled automatically. What default behavior on the configuration are you talking about?

@sipersso
Copy link
Author

sipersso commented Aug 9, 2023

FIY: Same goes for when an object has multiple incoming links. This doesn't work either, but I guess it is the same issue? Any updates on when this would be fixed?

@sipersso
Copy link
Author

@rorbech any info on when this might be released? I am currently blocked from releasing a big feature because of this. Would be nice to get a feel for how long it might take so I can adjust priorities.

@cmelchior
Copy link
Contributor

Hi @sipersso We just want to get #1489 merged before doing a 1.11.0 release. This should hopefully happen next week. Otherwise, you can use the 1.11.0-SNAPSHOT where the feature is available now.

@sipersso
Copy link
Author

@cmelchior great news! Thanks for the update

@sipersso
Copy link
Author

I noticed that #1490 is now merged. Any updates on the release? I can use the snapshot build for beta testing, but hesitate to use snapshots in production.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants