ground-android icon indicating copy to clipboard operation
ground-android copied to clipboard

[Crash] FK constraint failing, likely on insert observation

Open gino-m opened this issue 4 years ago • 6 comments
trafficstars

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 avatar Jul 30 '21 14:07 gino-m

@gino-m What is the thrown exception for the above stack trace? Feels like it is missing some lines

shobhitagarwal1612 avatar Aug 01 '21 07:08 shobhitagarwal1612

Is it because this is going into native code nativeExecuteForLastInsertedRowId?

shobhitagarwal1612 avatar Aug 01 '21 07:08 shobhitagarwal1612

Sorry it was clipped, added the full stack track in the description.

gino-m avatar Aug 04 '21 13:08 gino-m

I was able to repro it locally. This only happens if the observation gets inserted before the feature.

shobhitagarwal1612 avatar Aug 07 '21 04:08 shobhitagarwal1612

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

shobhitagarwal1612 avatar Aug 07 '21 04:08 shobhitagarwal1612

Thanks for looking into this. I shared a link private, let's discuss offline.

gino-m avatar Aug 09 '21 14:08 gino-m

Old issue, let's reopen if this occurs in practice.

gino-m avatar Feb 27 '23 17:02 gino-m