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

Datastore, random crash when switching from online to offline use case #2458

Closed
1 task done
antoineberthelin opened this issue May 22, 2023 · 7 comments
Closed
1 task done
Assignees
Labels
bug Something isn't working datastore DataStore category/plugins

Comments

@antoineberthelin
Copy link

Before opening, please confirm:

Language and Async Model

Kotlin, Kotlin - Coroutines

Amplify Categories

DataStore

Gradle script dependencies

// Put output below this line

Environment information

# Put output below this line


Please include any relevant guides or documentation you're referencing

No response

Describe the bug

Use case : lose the network and recover the network
Random crash on production (not easy to reproduce)
RX java crash
io.reactivex.rxjava3.exceptions.OnErrorNotImplementedException: call. java.lang.IllegalStateException: Only a single observer allowed.

Reproduction steps (if applicable)

No response

Code Snippet

// Put your code below this line.

Log output

// Put your logs below this line



2023-05-22 09:04:19.601 11216-12708 amplify:aws-datastore   com.appsonic.android.whosnext        I  Started subscription processor for models: [Item, Draw, DrawBatch, Question] of types [ON_CREATE, ON_UPDATE, ON_DELETE].
2023-05-22 09:04:19.652 11216-12747 amplify:aws-datastore   com.appsonic.android.whosnext        I  Success on attempt #1
2023-05-22 09:04:19.703 11216-11216 ViewRootIm...nActivity] com.appsonic.android.whosnext        I  ViewPostIme pointer 0
2023-05-22 09:04:19.842 11216-11216 ViewRootIm...nActivity] com.appsonic.android.whosnext        I  ViewPostIme pointer 1
2023-05-22 09:04:19.846 11216-11581 amplify:aws-datastore   com.appsonic.android.whosnext        I  Successfully removed from mutations outboxPendingMutation{mutatedItem=SerializedModel{id='7c7ae155-afc2-455c-b61b-8f2328cf2d55', serializedData={date=1684736779, createdAt=2023-05-22T06:26:20.191Z, drawItemId=e5963d89-733d-412f-9797-46cc6f88095d, id=7c7ae155-afc2-455c-b61b-8f2328cf2d55, drawDrawBatchId=9ad53239-25d6-40d0-a089-81b46d182fd1, updatedAt=2023-05-22T06:26:20.191Z}, modelName=Draw}, mutationType=DELETE, mutationId=c9ac3321-f86e-11ed-954c-8f9ac001bc51, predicate=MatchAllQueryPredicate}
2023-05-22 09:04:20.124 11216-11546 amplify:aws-datastore   com.appsonic.android.whosnext        I  Successfully sync'd down model state from cloud.
2023-05-22 09:04:20.179 11216-11334 amplify:aws-datastore   com.appsonic.android.whosnext        I  Started Publish with retry: PendingMutation{mutatedItem=SerializedModel{id='e5963d89-733d-412f-9797-46cc6f88095d', serializedData={createdAt=null, itemQuestionId=486b3099-406d-4b5e-a85c-3c552a932414, orderItem=1, disabled=false, id=e5963d89-733d-412f-9797-46cc6f88095d, title=Nathalie (exemple), updatedAt=null}, modelName=Item}, mutationType=DELETE, mutationId=cac59264-f86e-11ed-954c-87f65657d657, predicate=MatchAllQueryPredicate}
2023-05-22 09:04:20.231 11216-11334 amplify:aws-datastore   com.appsonic.android.whosnext        I  Starting attempt #1
2023-05-22 09:04:20.332 11216-11216 ViewRootIm...nActivity] com.appsonic.android.whosnext        I  ViewPostIme pointer 0
2023-05-22 09:04:20.461 11216-11216 ViewRootIm...nActivity] com.appsonic.android.whosnext        I  ViewPostIme pointer 1
2023-05-22 09:04:20.486 11216-10862 AndroidRuntime          com.appsonic.android.whosnext        E  FATAL EXCEPTION: RxCachedThreadScheduler-85
Process: com.appsonic.android.whosnext, PID: 11216
io.reactivex.rxjava3.exceptions.OnErrorNotImplementedException: The exception was not handled due to missing onError handler in the subscribe() method call. Further reading: https://github.com/ReactiveX/RxJava/wiki/Error-Handling | java.lang.IllegalStateException: Only a single observer allowed.
	at io.reactivex.rxjava3.internal.observers.EmptyCompletableObserver.onError(EmptyCompletableObserver.java:50)
	at io.reactivex.rxjava3.internal.operators.completable.CompletablePeek$CompletableObserverImplementation.onError(CompletablePeek.java:95)
	at io.reactivex.rxjava3.internal.operators.completable.CompletablePeek$CompletableObserverImplementation.onError(CompletablePeek.java:95)
	at io.reactivex.rxjava3.internal.util.AtomicThrowable.tryTerminateConsumer(AtomicThrowable.java:156)
	at io.reactivex.rxjava3.internal.operators.observable.ObservableFlatMapCompletableCompletable$FlatMapCompletableMainObserver.onError(ObservableFlatMapCompletableCompletable.java:125)
	at io.reactivex.rxjava3.internal.observers.DisposableLambdaObserver.onError(DisposableLambdaObserver.java:65)
	at io.reactivex.rxjava3.internal.disposables.EmptyDisposable.error(EmptyDisposable.java:63)
	at io.reactivex.rxjava3.subjects.UnicastSubject.subscribeActual(UnicastSubject.java:294)
	at io.reactivex.rxjava3.core.Observable.subscribe(Observable.java:13099)
	at io.reactivex.rxjava3.internal.operators.observable.ObservableDoOnLifecycle.subscribeActual(ObservableDoOnLifecycle.java:33)
	at io.reactivex.rxjava3.core.Observable.subscribe(Observable.java:13099)
	at io.reactivex.rxjava3.internal.operators.observable.ObservableFlatMapCompletableCompletable.subscribeActual(ObservableFlatMapCompletableCompletable.java:49)
	at io.reactivex.rxjava3.core.Completable.subscribe(Completable.java:2850)
	at io.reactivex.rxjava3.internal.operators.completable.CompletablePeek.subscribeActual(CompletablePeek.java:51)
	at io.reactivex.rxjava3.core.Completable.subscribe(Completable.java:2850)
	at io.reactivex.rxjava3.internal.operators.completable.CompletablePeek.subscribeActual(CompletablePeek.java:51)
	at io.reactivex.rxjava3.core.Completable.subscribe(Completable.java:2850)
	at io.reactivex.rxjava3.core.Completable.subscribe(Completable.java:2836)
	at com.amplifyframework.datastore.syncengine.SubscriptionProcessor.startDrainingMutationBuffer(SubscriptionProcessor.java:258)
	at com.amplifyframework.datastore.syncengine.Orchestrator.lambda$startApiSync$4$com-amplifyframework-datastore-syncengine-Orchestrator(Orchestrator.java:351)
	at com.amplifyframework.datastore.syncengine.Orchestrator$$ExternalSyntheticLambda8.subscribe(Unknown Source:2)
	at io.reactivex.rxjava3.internal.operators.completable.CompletableCreate.subscribeActual(CompletableCreate.java:40)
	at io.reactivex.rxjava3.core.Completable.subscribe(Completable.java:2850)
	at io.reactivex.rxjava3.internal.operators.completable.CompletablePeek.subscribeActual(CompletablePeek.java:51)
	at io.reactivex.rxjava3.core.Completable.subscribe(Completable.java:2850)
	at io.reactivex.rxjava3.internal.operators.completable.CompletablePeek.subscribeActual(CompletablePeek.java:51)
	at io.reactivex.rxjava3.core.Completable.subscribe(Completable.java:2850)
	at io.reactivex.rxjava3.internal.operators.completable.CompletablePeek.subscribeActual(CompletablePeek.java:51)
	at io.reactivex.rxjava3.core.Completable.subscribe(Completable.java:2850)
	at io.reactivex.rxjava3.internal.operators.completable.CompletableSubscribeOn$SubscribeOnObserver.run(CompletableSubscribeOn.java:64)
	at io.reactivex.rxjava3.core.Scheduler$DisposeTask.run(Scheduler.java:614)
	at io.reactivex.rxjava3.internal.schedulers.ScheduledRunnable.run(ScheduledRunnable.java:65)
	at io.reactivex.rxjava3.internal.schedulers.ScheduledRunnable.call(ScheduledRunnable.java:56)
	at java.util.concurrent.FutureTask.run(FutureTask.java:264)
2023-05-22 09:04:20.486 11216-10862 AndroidRuntime          com.appsonic.android.whosnext        E  	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:307)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637)
	at java.lang.Thread.run(Thread.java:1012)
Caused by: java.lang.IllegalStateException: Only a single observer allowed.
	... 31 more
2023-05-22 09:04:20.545 11216-12969 amplify:aws-datastore   com.appsonic.android.whosnext        I  Success on attempt #1
2023-05-22 09:04:20.624 11216-10862 Process                 com.appsonic.android.whosnext        I  Sending signal. PID: 11216 SIG: 9
---------------------------- PROCESS ENDED (11216) for package com.appsonic.android.whosnext ----------------------------
2023-05-22 09:04:25.283   749-749   audit                   auditd                               E  type=1400 audit(1684739065.281:53927): avc:  granted  { execute } for  pid=13888 comm="re-initialized>" path="/data/data/com.appsonic.android.whosnext/code_cache/startup_agents/4615cd08-agent.so" dev="dm-49" ino=260350 scontext=u:r:untrusted_app:s0:c180,c258,c512,c768 tcontext=u:object_r:app_data_file:s0:c180,c258,c512,c768 tclass=file SEPF_SM-A336B_12_0001 audit_filtered


----------------

amplifyconfiguration.json

No response

GraphQL Schema

// Put your schema below this line

Additional information and screenshots

No response

@antoineberthelin
Copy link
Author

antoineberthelin commented May 22, 2023

Hello,

Following RXJava documentation, I just patch my APP like this to avoid amplify crash

`

RxJavaPlugins.setErrorHandler { throwable: Throwable? ->
if (throwable != null) {
Log.e(logTag, "RxJavaPlugins error $throwable")
if (BuildConfig.DEBUG) {
throw throwable
}
}
}

`

Could you tell me if it is a safe workaround ?
Thanks

@tylerjroach tylerjroach added datastore DataStore category/plugins pending-triage Issue is pending triage labels May 22, 2023
@antoineberthelin antoineberthelin changed the title Datastore, random crash on lose the network use case Datastore, random crash when switching from online to offline use case May 22, 2023
@mattcreaser
Copy link
Member

Hi @antoineberthelin - can you please indicate which version of Amplify you are using? We recently made some changes that may have affected the occurrence of this error.

You are certainly welcome to use RxJava's error handler to avoid a crash, but I am concerned that the underlying error could still cause issues with your application's behaviour.

@antoineberthelin
Copy link
Author

Hi @mattcreaser

My Amplify version is : 2.8.4
So, I keep my RxJava's error handler waiting new release, thanks for your feedback :)

Thanks

@mattcreaser
Copy link
Member

Okay, seems like we still have some work to do in this area. Please stay tuned for updates 😄

@mattcreaser mattcreaser added bug Something isn't working and removed pending-triage Issue is pending triage labels Jun 1, 2023
@antoineberthelin
Copy link
Author

Hello @mattcreaser yes, I think so too.
In 2.8.4 version RxJava's error handler is mandatory in production to avoid APP crash
Good luck :)

@mattcreaser
Copy link
Member

This should be fixed in version 2.11.3 - @antoineberthelin please update and try it out!

@github-actions
Copy link
Contributor

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working datastore DataStore category/plugins
Projects
None yet
Development

No branches or pull requests

3 participants