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

Queued mutations are lost on network exception #82

Closed
chorniyn opened this issue Dec 14, 2018 · 4 comments
Closed

Queued mutations are lost on network exception #82

chorniyn opened this issue Dec 14, 2018 · 4 comments
Assignees
Labels
bug Something isn't working pending-response Issue is pending response from the issue requestor

Comments

@chorniyn
Copy link

Description
It turns out that AppSync on Android "looses" the mutations after the network exception.

To Reproduce

  1. A couple of mutations were successfully queued while device had no connection to any network
  2. Device was connected to the wifi network with no internet connection
  3. AppSync SDK detected the connection and tried to synchronize the mutations and that expectedly failed
  4. Wifi was turned off and mobile internet (cellular connection) was turned on

Result: none of the queued (and failed on step 3) mutations were executed after that, the data was lost.

Expected behavior

  1. Events are stored in the way they are queued. If mutations A, B and C are queued and mutation A fails to be synced, mutation B synchronization should not even start (but it did actually)
  2. Failed mutations should not be lost (they have to be retried)

Logs

Mutation failure (step 3)

2018-12-14 15:05:16.939 5692-18037/com.ehawk.ehawktracker E/SaveEventOperations_AS: Mutation CreateEvent failed, op id: 49d603320ce837d012619193ffb100e60bb4a6fd0e66345e8cd2341ac729b185, input: {id=afe67eb2-e0ed-4064-bfdd-afd3b09a852b, caseId=5678-chorniy-11635e63-5674-4018-a08d-aad42fd9f02e, offenderId=5678-chorniy-b49b6766-9da0-4d03-bea5-72e9188a8e3d, time=1.544792706797E9, type=ServiceStateChange, agencyId=agency, serviceName=LocationService, enabledProviders=["GPS","NETWORK"]}
    com.apollographql.apollo.exception.ApolloNetworkException: Failed to execute http call
        at com.apollographql.apollo.internal.interceptor.ApolloServerInterceptor$1$1.onFailure(ApolloServerInterceptor.java:105)
        at okhttp3.RealCall$AsyncCall.execute(RealCall.java:148)
        at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
        at java.lang.Thread.run(Thread.java:760)
     Caused by: java.net.SocketTimeoutException: timeout
        at okhttp3.internal.http2.Http2Stream$StreamTimeout.newTimeoutException(Http2Stream.java:593)
        at okhttp3.internal.http2.Http2Stream$StreamTimeout.exitAndThrowIfTimedOut(Http2Stream.java:601)
        at okhttp3.internal.http2.Http2Stream.takeResponseHeaders(Http2Stream.java:146)
        at okhttp3.internal.http2.Http2Codec.readResponseHeaders(Http2Codec.java:120)
        at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.java:75)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
        at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:45)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
        at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
        at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
        at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:120)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
        at com.amazonaws.mobileconnectors.appsync.sigv4.AppSyncSigV4SignerInterceptor.intercept(AppSyncSigV4SignerInterceptor.java:181)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
        at com.amazonaws.mobileconnectors.appsync.retry.RetryInterceptor.intercept(RetryInterceptor.java:50)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
        at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:185)
        at okhttp3.RealCall$AsyncCall.execute(RealCall.java:135)
        at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32) 
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) 
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) 
        at java.lang.Thread.run(Thread.java:760) 

Environment:

Device Information:

  • Device: Xiaomi MI5s
  • Android Version: 7.0
@chorniyn chorniyn changed the title Queued mutations are lost on network exception (Android) Queued mutations are lost on network exception Dec 14, 2018
@scb01 scb01 added the bug Something isn't working label Dec 14, 2018
@scb01 scb01 self-assigned this Dec 14, 2018
@scb01
Copy link
Contributor

scb01 commented Dec 14, 2018

@nchorniy

Thank you for reporting this issue. I am working on a solution for this and am targeting it to be included in the next version.

@sunchunqiang sunchunqiang added the pending-release Code has been merged but pending release label Dec 17, 2018
@scb01
Copy link
Contributor

scb01 commented Dec 19, 2018

@nchorniy

Version 2.7.1 of the SDK contains network error handling and queuing logic to address the issue that you reported. Please upgrade to this version and let us know how you fare.

@scb01 scb01 added pending-response Issue is pending response from the issue requestor and removed pending-release Code has been merged but pending release labels Dec 19, 2018
@chorniyn
Copy link
Author

@cbommas thanks, it seems the issue is fully fixed. Both things work :

  • data was not lost
  • and it was stored in the correct order

The testing was conducted on another device this time: Samsung J7 (2016) running on Android 7. Testing scenario was the same.

@frankmuellr
Copy link

Hello @nchorniy,

that's great news! Thank you for testing and providing a detailed update. I am going ahead and closing this issue. If you encounter any other problems, please open a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pending-response Issue is pending response from the issue requestor
Projects
None yet
Development

No branches or pull requests

4 participants