-
Notifications
You must be signed in to change notification settings - Fork 307
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
Crash when removing relation and related entity #490
Comments
And in BoxStore.java, it show me that: |
Is this reproducible? Which version is it? |
I got it recently. In my case problem was in attempt to deploy existing db image instead of empty after access to db.
|
OK, we should look into it to fail more nicely... |
@greenrobot Yes, it is reproducible. And objectbox version is v1.3.4.
|
@williamwue So you can rule out it is the same scenario compared to Yazon2006's?
Do you have a percentage of users? |
I've got a crash and it's logcat output looks very similar to the one reported above:
ObjectBox version is 1.5.0. The crash appears only upon trying to update an app to a newer version, a fresh installation works ok, so it must have something to do with the way migrations are handled. Here's a list of the database-related changes I've made that led to a crash:
@Entity
data class DbPrice(
@Convert(dbType = String::class, converter = BigDecimalConverter::class)
var value: BigDecimal,
var currency: String,
@Id var id: Long = 0
) data class Price(
val value: BigDecimal,
val currency: String
) class PriceConverter : PropertyConverter<Price, String> {
override fun convertToDatabaseValue(entityProperty: Price?): String? = entityProperty?.let {
"${it.value}|${it.currency}"
}
override fun convertToEntityProperty(databaseValue: String?): Price? = databaseValue?.let {
val parsed = databaseValue.split("|")
Price(BigDecimal(parsed[0]), parsed[1])
}
}
@Entity
data class DbZone(
@Id(assignable = true)
var id: Long = 0,
val name: String? = "",
@Convert(converter = PriceConverter::class, dbType = String::class)
val fee: Price? = null,
@Convert(converter = ZoneStatusConverter::class, dbType = Int::class)
val status: Zone.Status = Zone.Status.DISABLED
)
@Entity
data class DbArea(
var name: String,
var parent: String,
@Id(assignable = true) var id: Long = 0,
var zoneId: Long?
) to this: @Entity
class DbArea {
@Id(assignable = true)
var id: Long = 0
lateinit var name: String
lateinit var parent: String
lateinit var zone: ToOne<DbZone>
} I didn't add any
|
Am also interested in this issue. Are there any updates? |
We would need a new crash log (starting with *** *** *** ...) with version 2.0.0-beta2. |
i change ToMany to String |
@ibnux Do you have the same crash? If so, please attach the crash log as requested above. Otherwise please submit a new issue, preferably with an example, so we can reproduce this. -ut |
@greenrobot I have a reliable reproduction for this case in the form of this repo: https://github.com/raja-baz/objectbox-490-reproduction Steps to reproduce:
This seems to be an issue during migration when an entity which is used as a target for a relation is removed. Some additional tests show that:
For now, we've decided to keep the legacy entities and not delete them to work around this issue while just not using them. Obviously this isn't ideal, but a segfault on app launch is even less ideal :P Cheers PS: This is on latest object box(2.1) and the crash in question is:
|
Note that my crash seems very similar to the one @s0nerik reported but not the original one(null pointer dereference versus what looks like an exception being thrown). Would you rather I file this as a separate issue? |
@raja-baz Thanks for your repro project, could verify the crash. Using this issue is fine as the original reporter has not responded. Passed this on to the development team. |
@greenrobot , any updates on the bug fix? I encountered similar crash as well. |
Thanks again everyone for reporting. A fix was issued internally and will be available with the next update. |
This is also part of the just released version '2.4.0-RC' - would be great if you could give it a try and report back. Thank you! |
@greenrobot I was having this same issue and I don't see it anymore with |
When I upgrade app it would crash when init objectbox, logcat is below:
The text was updated successfully, but these errors were encountered: