ground-android
ground-android copied to clipboard
[Crash] FK constraint failing, likely on insert observation
Stack trace from Crashlytics:
Fatal Exception: java.lang.Throwable: FOREIGN KEY constraint failed (code 787)
at android.database.sqlite.SQLiteConnection.nativeExecuteForLastInsertedRowId(SQLiteConnection.java)
at android.database.sqlite.SQLiteConnection.executeForLastInsertedRowId(SQLiteConnection.java:783)
at android.database.sqlite.SQLiteSession.executeForLastInsertedRowId(SQLiteSession.java:788)
at android.database.sqlite.SQLiteStatement.executeInsert(SQLiteStatement.java:86)
at androidx.sqlite.db.framework.FrameworkSQLiteStatement.executeInsert(FrameworkSQLiteStatement.java:51)
at androidx.room.EntityInsertionAdapter.insert(EntityInsertionAdapter.java:64)
at com.google.android.gnd.persistence.local.room.dao.ObservationDao_Impl$4.call(ObservationDao_Impl.java:304)
at com.google.android.gnd.persistence.local.room.dao.ObservationDao_Impl$4.call(ObservationDao_Impl.java:299)
at io.reactivex.internal.operators.completable.CompletableFromCallable.subscribeActual(CompletableFromCallable.java:36)
at io.reactivex.Completable.subscribe(Completable.java:2309)
at com.akaita.java.rxjava2debug.extensions.CompletableOnAssembly.subscribeActual(CompletableOnAssembly.java:39)
at io.reactivex.Completable.subscribe(Completable.java:2309)
at io.reactivex.internal.operators.completable.CompletablePeek.subscribeActual(CompletablePeek.java:51)
at io.reactivex.Completable.subscribe(Completable.java:2309)
at com.akaita.java.rxjava2debug.extensions.CompletableOnAssembly.subscribeActual(CompletableOnAssembly.java:39)
at io.reactivex.Completable.subscribe(Completable.java:2309)
at io.reactivex.internal.operators.completable.CompletableSubscribeOn$SubscribeOnObserver.run(CompletableSubscribeOn.java:64)
at io.reactivex.Scheduler$DisposeTask.run(Scheduler.java:578)
at io.reactivex.internal.schedulers.ScheduledRunnable.run(ScheduledRunnable.java:66)
at io.reactivex.internal.schedulers.ScheduledRunnable.call(ScheduledRunnable.java:57)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at java.lang.Thread.run(Thread.java:764)
@shobhitagarwal1612 Could you PTAL if you have a sec?
@gino-m What is the thrown exception for the above stack trace? Feels like it is missing some lines
Is it because this is going into native code nativeExecuteForLastInsertedRowId?
Sorry it was clipped, added the full stack track in the description.
I was able to repro it locally. This only happens if the observation gets inserted before the feature.
IMO, the only possible explanation is that insert operation for the feature failed and the UI still allowed to proceed with adding a new observation.
But that also doesn't make sense as getFeature call returns a Single<Feature> that checks for feature in local db.
https://github.com/google/ground-android/blob/master/gnd/src/main/java/com/google/android/gnd/repository/FeatureRepository.java#L115
Not sure what the reason is behind it. Can we get more visibility into the app version?
@gino-m
Thanks for looking into this. I shared a link private, let's discuss offline.
Old issue, let's reopen if this occurs in practice.