locked
SyncFx 1.0 Mobile WM 6.0 -- How to handle when sync fails because network connection is lost. RRS feed

  • Question

  • I was testing this out to see what happens when I unplug my network cable in the middle of synching (UPLOAD ONLY) 500 records.

    1. Mobile device is sending 500 records to the Sql 2005 server.

    2. Unplug network cable in the middle of the sync.

    The result is that the 500 records are commited on the server however the LastSentAnchor is not updated on the client. Therefore the next sync attempts to send those 500 records again and the result is Primary key conflicts (Guids are generated on the device) which results in OOM exception because of how large the dataset is with all the conflicts.

    So my question is, how have others handled this scenario?

     

    Wednesday, December 15, 2010 8:18 PM

Answers

  • unfornately the behavior you described is expected with the current release. the upload sync will get the changes, and then send the changes to the web service and the the server takes it, then commited it at the backend sql server. the client and server doesn't have the handshaking meachanism during the server ( sql server and iis server ) to apply the changes.

    I cannot think of a ideal way to deal with this scenario. other than ignore the conflicts at the server due to the PK violations.

    if you want to put a complex logic in your app for this case, you can consider to put some guard here in your web service to keep the ACKs between the server and the client and if there is any errors, don't apply the changes if possible -- this would be relatively hard as there will be still some time window you cannot control of.

    thanks

    Yunwen


    This posting is provided "AS IS" with no warranties, and confers no rights.
    • Marked as answer by gs_ham Tuesday, January 4, 2011 8:47 PM
    Thursday, December 16, 2010 6:20 PM
  • Thanks. My solution is as you described. Although not elegant, it works.

    So I handle this case by subscribing to the ApplyChangeFailed event on the server side.

    When the error is one of a PK violation, I remove the row from the e.Conflict.ClientChange collection and set the e.Action to ApplyAction.Continue.

    Then I go through and clear the Conflicts collection from the TablesProgress collection.

    • Marked as answer by gs_ham Tuesday, January 4, 2011 8:47 PM
    Tuesday, January 4, 2011 8:46 PM

All replies

  • unfornately the behavior you described is expected with the current release. the upload sync will get the changes, and then send the changes to the web service and the the server takes it, then commited it at the backend sql server. the client and server doesn't have the handshaking meachanism during the server ( sql server and iis server ) to apply the changes.

    I cannot think of a ideal way to deal with this scenario. other than ignore the conflicts at the server due to the PK violations.

    if you want to put a complex logic in your app for this case, you can consider to put some guard here in your web service to keep the ACKs between the server and the client and if there is any errors, don't apply the changes if possible -- this would be relatively hard as there will be still some time window you cannot control of.

    thanks

    Yunwen


    This posting is provided "AS IS" with no warranties, and confers no rights.
    • Marked as answer by gs_ham Tuesday, January 4, 2011 8:47 PM
    Thursday, December 16, 2010 6:20 PM
  • Thanks. My solution is as you described. Although not elegant, it works.

    So I handle this case by subscribing to the ApplyChangeFailed event on the server side.

    When the error is one of a PK violation, I remove the row from the e.Conflict.ClientChange collection and set the e.Action to ApplyAction.Continue.

    Then I go through and clear the Conflicts collection from the TablesProgress collection.

    • Marked as answer by gs_ham Tuesday, January 4, 2011 8:47 PM
    Tuesday, January 4, 2011 8:46 PM