-
Notifications
You must be signed in to change notification settings - Fork 249
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
App crash when using datastore with api sync and internet is offline #1816
Comments
Hi @yazoonic Thanks for reporting this issue. This is interesting... We can see the main exception probably is
All of these spots are doing similar thing - requiring permit to wait on the thread. I did a quick testing on Android emulator following your steps, I tried to add multiple entries after the emulator went to offline, and I couldn't reproduce the crash. Although I used API_KEY auth on the API which doesn't require fetch token step. Also... I don't have an android device so couldn't test further. Noticeably the sync engine will try to resume connection on every Need further investigation. |
@HuiSF Thanks for looking into this.. just to confirm, I just tested with emulator and I have the same error. |
@HuiSF I can confirm that the issue is not happening when I remove the selective sync expression, Please verify and let me know when this can be resolved |
Thanks for the follow up @yazoonic how many sync expressions you are using? Can you share the code snippet that initialize the DataStore plugin with the sync expressions? |
@HuiSF I cant share the exact code but this what I used, I just replaced table name .. i have 17 tables... AmplifyDataStore datastorePlugin = AmplifyDataStore( |
OK no problem @yazoonic
This sync expression can be removed as it does the same as the default syncing behavior Also are you syncing data based on |
i will try to do with less eync expression... what do you mean by owner based auth? I have tables defined as below and how to enable owner based auth? |
Please follow this documentation: https://docs.amplify.aws/lib/datastore/setup-auth-rules/q/platform/flutter/#per-user--owner-based-data-access When you enable owner based auth, only the models that belong to the currently signed in user will be synced into local database. |
oh I think I tired it before and I had a problem with my production app so I rolled back.. I will give it a try in my dev and see. |
so the problem with this one that if I pushed this update to my production database.. current app user will lose connectivity until I update the app code and push it to Apple app store which will take 1-2 days to approve ,,,, |
Hum OK, changing auth to existing data in prod env is troublesome for sure. |
@HuiSF I tried with just one sync expression and I got crash as well. |
Are you building the apk in release mode? @yazoonic |
before I wasnt .. but now I have the release mode on in build gradle and I just use the play button as debug... should I remove the settings for release? |
I can't repro this on emulator myself, so I want to determine a possible cause with different permutation... Also can you try run the App in a different emulator? |
I am using Android Studio... the build Variant is debug is it something related to my Auth flow... |
@HuiSF do you have anyway to migrate from private to owner auth? I tired multi auth then update to owner and I cant access data |
The crash happens in all these devices/emulators?
It's possible, sorry I don't have time right now for a thorough testing, can dig in deeper next week.
There is no easy way, here's the basic steps in my mind (rough)
If you are thinking about this, please test the migration in a pre-prod environment first. Also how many records roughly do you have in each table? |
@HuiSF yes the crash happening in all devices and simulators. I have more than 5k records and growing for one table. other tables have less than 200 entries. I am thinking of something else in migration by enabling multi auth with overriding owner field .. I have to test it though. |
@HuiSF any news? |
Hi @yazoonic sorry for the delayed response. No substantial update on my side, as I couldn't reproduce this crash so I'm pretty much blind on debugging this crash. |
@HuiSF I was reading this thread again in your repro and you mentioned that you use API_key Auth which maybe the reason you were not able to repro. |
@HuiSF I have tested flutter for this case with iPhone device and the crash is not happening.. seems like it is Android specific. |
We've merged a change to handle the exception shown in the logs, and the fix has been released with v0.6.11, which prevents the crash. As we are not able to actual reproduce this crash, I'm optimistically closing this issue. Please feel free to follow up and open a new issue if any further assistance is need/ |
Description
using datastore with api sync for cloud, when you disconnect internet and add entries to data store, it will work momentary then app crash
I/amplify:aws-datastore(27749): Orchestrator transitioning from SYNC_VIA_API to LOCAL_ONLY
I/amplify:aws-datastore(27749): Setting currentState to LOCAL_ONLY
I/amplify:aws-datastore(27749): Stopping subscription processor.
I/amplify:aws-datastore(27749): Stopped subscription processor.
W/amplify:aws-datastore(27749): API sync failed - transitioning to LOCAL_ONLY.
W/amplify:aws-datastore(27749): DataStoreException{message=Error during subscription., cause=ApiException{message=Interrupted waiting for Cognito Userpools token., cause=java.lang.InterruptedException, recoverySuggestion=Sorry, we don't have a suggested fix for this error yet.}, recoverySuggestion=Evaluate details.}
W/amplify:aws-datastore(27749): at com.amplifyframework.datastore.appsync.AppSyncClient.lambda$subscription$3(AppSyncClient.java:331)
W/amplify:aws-datastore(27749): at com.amplifyframework.datastore.appsync.AppSyncClient$$ExternalSyntheticLambda1.accept(Unknown Source:4)
W/amplify:aws-datastore(27749): at com.amplifyframework.api.aws.SubscriptionOperation.lambda$null$1$com-amplifyframework-api-aws-SubscriptionOperation(SubscriptionOperation.java:87)
W/amplify:aws-datastore(27749): at com.amplifyframework.api.aws.SubscriptionOperation$$ExternalSyntheticLambda0.accept(Unknown Source:4)
W/amplify:aws-datastore(27749): at com.amplifyframework.api.aws.SubscriptionEndpoint.requestSubscription(SubscriptionEndpoint.java:131)
W/amplify:aws-datastore(27749): at com.amplifyframework.api.aws.SubscriptionOperation.lambda$start$2$com-amplifyframework-api-aws-SubscriptionOperation(SubscriptionOperation.java:77)
W/amplify:aws-datastore(27749): at com.amplifyframework.api.aws.SubscriptionOperation$$ExternalSyntheticLambda3.run(Unknown Source:2)
W/amplify:aws-datastore(27749): at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:462)
W/amplify:aws-datastore(27749): at java.util.concurrent.FutureTask.run(FutureTask.java:266)
W/amplify:aws-datastore(27749): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
W/amplify:aws-datastore(27749): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
W/amplify:aws-datastore(27749): at java.lang.Thread.run(Thread.java:919)
W/amplify:aws-datastore(27749): Caused by: ApiException{message=Interrupted waiting for Cognito Userpools token., cause=java.lang.InterruptedException, recoverySuggestion=Sorry, we don't have a suggested fix for this error yet.}
W/amplify:aws-datastore(27749): at com.amplifyframework.api.aws.sigv4.DefaultCognitoUserPoolsAuthProvider.fetchToken(DefaultCognitoUserPoolsAuthProvider.java:90)
W/amplify:aws-datastore(27749): at com.amplifyframework.api.aws.sigv4.DefaultCognitoUserPoolsAuthProvider.getLatestAuthToken(DefaultCognitoUserPoolsAuthProvider.java:104)
W/amplify:aws-datastore(27749): at com.amplifyframework.api.aws.SubscriptionAuthorizer.forCognitoUserPools(SubscriptionAuthorizer.java:147)
W/amplify:aws-datastore(27749): at com.amplifyframework.api.aws.SubscriptionAuthorizer.createHeaders(SubscriptionAuthorizer.java:96)
W/amplify:aws-datastore(27749): at com.amplifyframework.api.aws.SubscriptionAuthorizer.createHeadersForConnection(SubscriptionAuthorizer.java:71)
W/amplify:aws-datastore(27749): at com.amplifyframework.api.aws.SubscriptionEndpoint.buildConnectionRequestUrl(SubscriptionEndpoint.java:300)
W/amplify:aws-datastore(27749): at com.amplifyframework.api.aws.SubscriptionEndpoint.requestSubscription(SubscriptionEndpoint.java:127)
W/amplify:aws-datastore(27749): ... 7 more
W/amplify:aws-datastore(27749): Caused by: java.lang.InterruptedException
W/amplify:aws-datastore(27749): at java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1024)
W/amplify:aws-datastore(27749): at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1334)
W/amplify:aws-datastore(27749): at java.util.concurrent.Semaphore.acquire(Semaphore.java:318)
W/amplify:aws-datastore(27749): at com.amplifyframework.api.aws.sigv4.DefaultCognitoUserPoolsAuthProvider.fetchToken(DefaultCognitoUserPoolsAuthProvider.java:88)
W/amplify:aws-datastore(27749): ... 13 more
W/System.err(27749): io.reactivex.rxjava3.exceptions.UndeliverableException: The exception could not be delivered to the consumer because it has already canceled/disposed the flow or the exception has nowhere to go to begin with. Further reading: https://github.com/ReactiveX/RxJava/wiki/What's-different-in-2.0#error-handling | java.lang.RuntimeException: java.lang.InterruptedException
W/System.err(27749): at io.reactivex.rxjava3.plugins.RxJavaPlugins.onError(RxJavaPlugins.java:367)
W/System.err(27749): at io.reactivex.rxjava3.internal.operators.completable.CompletableCreate$Emitter.onError(CompletableCreate.java:78)
W/System.err(27749): at io.reactivex.rxjava3.internal.operators.completable.CompletableCreate.subscribeActual(CompletableCreate.java:43)
W/System.err(27749): at io.reactivex.rxjava3.core.Completable.subscribe(Completable.java:2850)
W/System.err(27749): at io.reactivex.rxjava3.internal.operators.completable.CompletablePeek.subscribeActual(CompletablePeek.java:51)
W/System.err(27749): at io.reactivex.rxjava3.core.Completable.subscribe(Completable.java:2850)
W/System.err(27749): at io.reactivex.rxjava3.internal.operators.completable.CompletablePeek.subscribeActual(CompletablePeek.java:51)
W/System.err(27749): at io.reactivex.rxjava3.core.Completable.subscribe(Completable.java:2850)
W/System.err(27749): at io.reactivex.rxjava3.internal.operators.completable.CompletablePeek.subscribeActual(CompletablePeek.java:51)
W/System.err(27749): at io.reactivex.rxjava3.core.Completable.subscribe(Completable.java:2850)
W/System.err(27749): at io.reactivex.rxjava3.internal.operators.completable.CompletableSubscribeOn$SubscribeOnObserver.run(CompletableSubscribeOn.java:64)
W/System.err(27749): at io.reactivex.rxjava3.core.Scheduler$DisposeTask.run(Scheduler.java:614)
W/System.err(27749): at io.reactivex.rxjava3.internal.schedulers.ScheduledRunnable.run(ScheduledRunnable.java:65)
W/System.err(27749): at io.reactivex.rxjava3.internal.schedulers.ScheduledRunnable.call(ScheduledRunnable.java:56)
W/System.err(27749): at java.util.concurrent.FutureTask.run(FutureTask.java:266)
W/System.err(27749): at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301)
W/System.err(27749): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
W/System.err(27749): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
W/System.err(27749): at java.lang.Thread.run(Thread.java:919)
W/System.err(27749): Caused by: java.lang.RuntimeException: java.lang.InterruptedException
W/System.err(27749): at io.reactivex.rxjava3.internal.util.ExceptionHelper.wrapOrThrow(ExceptionHelper.java:46)
W/System.err(27749): at io.reactivex.rxjava3.internal.observers.BlockingMultiObserver.blockingGet(BlockingMultiObserver.java:94)
W/System.err(27749): at io.reactivex.rxjava3.core.Single.blockingGet(Single.java:3645)
W/System.err(27749): at com.amplifyframework.datastore.syncengine.QueryPredicateProvider.resolvePredicates(QueryPredicateProvider.java:64)
W/System.err(27749): at com.amplifyframework.datastore.syncengine.Orchestrator.lambda$startApiSync$3$com-amplifyframework-datastore-syncengine-Orchestrator(Orchestrator.java:298)
W/System.err(27749): at com.amplifyframework.datastore.syncengine.Orchestrator$$ExternalSyntheticLambda5.subscribe(Unknown Source:2)
W/System.err(27749): at io.reactivex.rxjava3.internal.operators.completable.CompletableCreate.subscribeActual(CompletableCreate.java:40)
W/System.err(27749): ... 16 more
W/System.err(27749): Caused by: java.lang.InterruptedException
W/System.err(27749): at java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1024)
W/System.err(27749): at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1334)
W/System.err(27749): at java.util.concurrent.CountDownLatch.await(CountDownLatch.java:232)
W/System.err(27749): at com.amazonaws.amplify.amplify_datastore.AmplifyDataStorePlugin.buildSyncExpressions$lambda-39$lambda-38(AmplifyDataStorePlugin.kt:540)
W/System.err(27749): at com.amazonaws.amplify.amplify_datastore.AmplifyDataStorePlugin.$r8$lambda$UO16rzDLOMeK1HlIWQ6n_FUcSvk(Unknown Source:0)
W/System.err(27749): at com.amazonaws.amplify.amplify_datastore.AmplifyDataStorePlugin$$ExternalSyntheticLambda12.resolvePredicate(Unknown Source:6)
W/System.err(27749): at com.amplifyframework.datastore.syncengine.QueryPredicateProvider.lambda$resolvePredicates$0(QueryPredicateProvider.java:62)
W/System.err(27749): at com.amplifyframework.datastore.syncengine.QueryPredicateProvider$$ExternalSyntheticLambda2.apply(Unknown Source:2)
W/System.err(27749): at io.reactivex.rxjava3.internal.operators.observable.ObservableMap$MapObserver.onNext(ObservableMap.java:58)
W/System.err(27749): at io.reactivex.rxjava3.internal.operators.observable.ObservableFromIterable$FromIterableDisposable.run(ObservableFromIterable.java:98)
W/System.err(27749): at io.reactivex.rxjava3.internal.operators.observable.ObservableFromIterable.subscribeActual(ObservableFromIterable.java:58)
W/System.err(27749): at io.reactivex.rxjava3.core.Observable.subscribe(Observable.java:13099)
W/System.err(27749): at io.reactivex.rxjava3.internal.operators.observable.ObservableMap.subscribeActual(ObservableMap.java:33)
W/System.err(27749): at io.reactivex.rxjava3.core.Observable.subscribe(Observable.java:13099)
W/System.err(27749): at io.reactivex.rxjava3.internal.operators.observable.ObservableCollectSingle.subscribeActual(ObservableCollectSingle.java:50)
W/System.err(27749): at io.reactivex.rxjava3.core.Single.subscribe(Single.java:4813)
W/System.err(27749): at io.reactivex.rxjava3.core.Single.blockingGet(Single.java:3644)
W/System.err(27749): ... 20 more
E/AndroidRuntime(27749): FATAL EXCEPTION: RxCachedThreadScheduler-24
E/AndroidRuntime(27749): Process: com.pinsbasket.walletin, PID: 27749
E/AndroidRuntime(27749): io.reactivex.rxjava3.exceptions.UndeliverableException: The exception could not be delivered to the consumer because it has already canceled/disposed the flow or the exception has nowhere to go to begin with. Further reading: https://github.com/ReactiveX/RxJava/wiki/What's-different-in-2.0#error-handling | java.lang.RuntimeException: java.lang.InterruptedException
E/AndroidRuntime(27749): at io.reactivex.rxjava3.plugins.RxJavaPlugins.onError(RxJavaPlugins.java:367)
E/AndroidRuntime(27749): at io.reactivex.rxjava3.internal.operators.completable.CompletableCreate$Emitter.onError(CompletableCreate.java:78)
E/AndroidRuntime(27749): at io.reactivex.rxjava3.internal.operators.completable.CompletableCreate.subscribeActual(CompletableCreate.java:43)
E/AndroidRuntime(27749): at io.reactivex.rxjava3.core.Completable.subscribe(Completable.java:2850)
E/AndroidRuntime(27749): at io.reactivex.rxjava3.internal.operators.completable.CompletablePeek.subscribeActual(CompletablePeek.java:51)
E/AndroidRuntime(27749): at io.reactivex.rxjava3.core.Completable.subscribe(Completable.java:2850)
E/AndroidRuntime(27749): at io.reactivex.rxjava3.internal.operators.completable.CompletablePeek.subscribeActual(CompletablePeek.java:51)
E/AndroidRuntime(27749): at io.reactivex.rxjava3.core.Completable.subscribe(Completable.java:2850)
E/AndroidRuntime(27749): at io.reactivex.rxjava3.internal.operators.completable.CompletablePeek.subscribeActual(CompletablePeek.java:51)
E/AndroidRuntime(27749): at io.reactivex.rxjava3.core.Completable.subscribe(Completable.java:2850)
E/AndroidRuntime(27749): at io.reactivex.rxjava3.internal.operators.completable.CompletableSubscribeOn$SubscribeOnObserver.run(CompletableSubscribeOn.java:64)
E/AndroidRuntime(27749): at io.reactivex.rxjava3.core.Scheduler$DisposeTask.run(Scheduler.java:614)
E/AndroidRuntime(27749): at io.reactivex.rxjava3.internal.schedulers.ScheduledRunnable.run(ScheduledRunnable.java:65)
E/AndroidRuntime(27749): at io.reactivex.rxjava3.internal.schedulers.ScheduledRunnable.call(ScheduledRunnable.java:56)
E/AndroidRuntime(27749): at java.util.concurrent.FutureTask.run(FutureTask.java:266)
E/AndroidRuntime(27749): at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301)
E/AndroidRuntime(27749): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
E/AndroidRuntime(27749): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
E/AndroidRuntime(27749): at java.lang.Thread.run(Thread.java:919)
E/AndroidRuntime(27749): Caused by: java.lang.RuntimeException: java.lang.InterruptedException
E/AndroidRuntime(27749): at io.reactivex.rxjava3.internal.util.ExceptionHelper.wrapOrThrow(ExceptionHelper.java:46)
E/AndroidRuntime(27749): at io.reactivex.rxjava3.internal.observers.BlockingMultiObserver.blockingGet(BlockingMultiObserver.java:94)
E/AndroidRuntime(27749): at io.reactivex.rxjava3.core.Single.blockingGet(Single.java:3645)
E/AndroidRuntime(27749): at com.amplifyframework.datastore.syncengine.QueryPredicateProvider.resolvePredicates(QueryPredicateProvider.java:64)
E/AndroidRuntime(27749): at com.amplifyframework.datastore.syncengine.Orchestrator.lambda$startApiSync$3$com-amplifyframework-datastore-syncengine-Orchestrator(Orchestrator.java:298)
E/AndroidRuntime(27749): at com.amplifyframework.datastore.syncengine.Orchestrator$$ExternalSyntheticLambda5.subscribe(Unknown Source:2)
E/AndroidRuntime(27749): at io.reactivex.rxjava3.internal.operators.completable.CompletableCreate.subscribeActual(CompletableCreate.java:40)
E/AndroidRuntime(27749): ... 16 more
E/AndroidRuntime(27749): Caused by: java.lang.InterruptedException
E/AndroidRuntime(27749): at java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1024)
E/AndroidRuntime(27749): at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1334)
E/AndroidRuntime(27749): at java.util.concurrent.CountDownLatch.await(CountDownLatch.java:232)
E/AndroidRuntime(27749): at com.amazonaws.amplify.amplify_datastore.AmplifyDataStorePlugin.buildSyncExpressions$lambda-39$lambda-38(AmplifyDataStorePlugin.kt:540)
E/AndroidRuntime(27749): at com.amazonaws.amplify.amplify_datastore.AmplifyDataStorePlugin.$r8$lambda$UO16rzDLOMeK1HlIWQ6n_FUcSvk(Unknown Source:0)
E/AndroidRuntime(27749): at com.amazonaws.amplify.amplify_datastore.AmplifyDataStorePlugin$$ExternalSyntheticLambda12.resolvePredicate(Unknown Source:6)
E/AndroidRuntime(27749): at com.amplifyframework.datastore.syncengine.QueryPredicateProvider.lambda$resolvePredicates$0(QueryPredicateProvider.java:62)
E/AndroidRuntime(27749): at com.amplifyframework.datastore.syncengine.QueryPredicateProvider$$ExternalSyntheticLambda2.apply(Unknown Source:2)
E/AndroidRuntime(27749): at io.reactivex.rxjava3.internal.operators.observable.ObservableMap$MapObserver.onNext(ObservableMap.java:58)
E/AndroidRuntime(27749): at io.reactivex.rxjava3.internal.operators.observable.ObservableFromIterable$FromIterableDisposable.run(ObservableFromIterable.java:98)
E/AndroidRuntime(27749): at io.reactivex.rxjava3.internal.operators.observable.ObservableFromIterable.subscribeActual(ObservableFromIterable.java:58)
E/AndroidRuntime(27749): at io.reactivex.rxjava3.core.Observable.subscribe(Observable.java:13099)
E/AndroidRuntime(27749): at io.reactivex.rxjava3.internal.operators.observable.ObservableMap.subscribeActual(ObservableMap.java:33)
E/AndroidRuntime(27749): at io.reactivex.rxjava3.core.Observable.subscribe(Observable.java:13099)
E/AndroidRuntime(27749): at io.reactivex.rxjava3.internal.operators.observable.ObservableCollectSingle.subscribeActual(ObservableCollectSingle.java:50)
E/AndroidRuntime(27749): at io.reactivex.rxjava3.core.Single.subscribe(Single.java:4813)
E/AndroidRuntime(27749): at io.reactivex.rxjava3.core.Single.blockingGet(Single.java:3644)
E/AndroidRuntime(27749): ... 20 more
I/Process (27749): Sending signal. PID: 27749 SIG: 9
Categories
Steps to Reproduce
Screenshots
No response
Platforms
Android Device/Emulator API Level
No response
Environment
Dependencies
Device
Pixel XL
OS
Android 10
CLI Version
7.6.26
Additional Context
No response
The text was updated successfully, but these errors were encountered: