MSSQL Deadlock on Async Web Requests in Android

rlaskerrlasker Member ✭✭

Recently we have run into a strange problem. We have an offline (in-field) application that allows you to manually sync when you regain a connection. During this syncing process we push user filled in form information to a remote server. We do this using a WaitAll task to parallelize the async post requests. Recently, and ONLY in Android these parallel web requests are causing deadlocks in our database. iOS, all the code runs fine.

It is impossible for us to determine why only Android would run into deadlock issues on the remote server. Anyone out there have any clues to point us in a direction?

Answers

  • jezhjezh Member, Xamarin Team Xamurai

    Do you mean the deadlocks happened in your database of your remote server, not the mobile devices (android or ios devices)?

  • rlaskerrlasker Member ✭✭

    @jezh said:
    Do you mean the deadlocks happened in your database of your remote server, not the mobile devices (android or ios devices)?

    Yes, the deadlocks happen in the database of our remote server during a sync for Android but not iOS. It's weird.

  • JohnHJohnH GBMember ✭✭✭✭✭

    @rlasker said:

    @jezh said:
    Do you mean the deadlocks happened in your database of your remote server, not the mobile devices (android or ios devices)?

    Yes, the deadlocks happen in the database of our remote server during a sync for Android but not iOS. It's weird.

    I would suggest you log the requests server side and compare them to iOS. There will be a difference, this isn't magic it is deterministic. You should then be able to replicate the problem when using Postman, for example.

  • JohnHardmanJohnHardman GBUniversity mod

    @rlasker said:
    Recently we have run into a strange problem. We have an offline (in-field) application that allows you to manually sync when you regain a connection. During this syncing process we push user filled in form information to a remote server. We do this using a WaitAll task to parallelize the async post requests. Recently, and ONLY in Android these parallel web requests are causing deadlocks in our database. iOS, all the code runs fine.

    Do the different pushes contain information that server-side will affect different tables, or do the different pushes update the same tables? If it's the latter, you will need to add your own protection to avoid deadlocks (e.g. ensure that any locking is done in the same order (i.e. always Table A, Table B, rather than some updates doing A,B and others doing B,A), or will need to change the updates to not have different updates being issued in parallel that affect the same tables.

    As to why you are seeing this on Android and not iOS, there are a number of possibilities, ranging from luck regarding timings on iOS, to iOS not operating in parallel in the way that you expect. As @JohnH mentioned, Postman can help to identify what is going on.

  • jezhjezh Member, Xamarin Team Xamurai

    @rlasker
    Besides above advice, you can also try to debug the remote server during a sync for Android , there should be some question with the code, e.g. the format of the data being processed .
    This problem often occurs in application development.

    Yes, you can use postman to identify what is going on.

  • jezhjezh Member, Xamarin Team Xamurai

    @rlasker
    Have you resolved your problem?

  • rlaskerrlasker Member ✭✭

    @jezh said:
    @rlasker
    Have you resolved your problem?

    Thank you for all the responses. Turns out there was simply inherent dealock problems on the server. I'm still not sure why there was a minor different between iOS and Android when the number of forms being submitted was very small but ultimately when you tried to sync over a dozen forms at once the problem existed on both iOS and Android. The server team is in the process of diagnosing the issues now.

  • jezhjezh Member, Xamarin Team Xamurai

    @rlasker
    Waiting for your good news.

Sign In or Register to comment.