locked
Subsequent synchronizations try to insert the same changes over and over. RRS feed

  • Question

  • Hi,

     

    I wonder if someone could explain these symptoms I'm seeing;

     

    I'm synchronzing between a sqlce database client and sql 2008 express server.

    Doing an UPLOADONLY from 4 grouped tables on the client. After doing a transaction on the client, from the sync progress, I get the following;

     

    Table Transaction: applied=1 failed=33 pending=0
    Table TransactionError: applied=89 failed=2865 pending=0
    Table TransactionDiscount: applied=0 failed=0 pending=0
    Table TransactionResponse: applied=3 failed=99 pending=0

    After the next transaction, I get;

     

    Table Transaction: applied=1 failed=34 pending=0
    Table TransactionError: applied=88 failed=2954 pending=0
    Table TransactionDiscount: applied=0 failed=0 pending=0
    Table TransactionResponse: applied=3 failed=102 pending=0

     

    In other words, it tries to apply the same inserts each subsequent synchronization, leading to conflict with a now existing row - for example:

    1:42 PM | ** CONFLICTING CHANGE OR ERROR AT SERVER **
    Table for which error or conflict occurred: TransactionResponse
    Sync stage: ApplyingInserts
    Conflict type: ClientInsertServerInsert
    Server row: 508 | 181 | 3 | 7700 |
    Client row: 508 | 181 | 3 | 7700 |

    So, it acts like it's never updating the anchor on the client, but I'm setting the sync providers new anchor command as per help docs;

    SqlCommand selectNewAnchorCommand = new SqlCommand();

    string newAnchorVariable = "@" + SyncSession.SyncNewReceivedAnchor;

    selectNewAnchorCommand.CommandText = "SELECT " + newAnchorVariable + " = min_active_rowversion() - 1";

    selectNewAnchorCommand.Parameters.Add(newAnchorVariable, SqlDbType.Timestamp);

    selectNewAnchorCommand.Parameters[newAnchorVariable].Direction = ParameterDirection.Output;

    selectNewAnchorCommand.Connection = serverConn;

    this.SelectNewAnchorCommand = selectNewAnchorCommand;

     

    I'm probably missing something obvious, but I don't see it yet.

     

    Thanks for any help.

    • Moved by Hengzhe Li Friday, April 22, 2011 5:31 AM (From:SyncFx - Microsoft Sync Framework Database Providers [ReadOnly])
    Tuesday, January 27, 2009 9:18 PM

All replies

  • so you are seeing rows being sent to the server every sync and hence the server side conflict due to PK violation ?

     

    the received anchor on client is not persisted if the sync direction is uploadOnly. the enumeration of changes from the client db is based on the lastSentAnchor on the client side, so as long as this value was persisted, the upload case should enumerate the changed rows only. can you check if this is not the case ?

     

    thanks

    Yunwen

    Thursday, January 29, 2009 11:42 PM
    Moderator
  • That's correct, same rows appear to generate a pk violation;
    Table for which error or conflict occurred: TransactionResponse
    Sync stage: ApplyingInserts
    Conflict type: ClientInsertServerInsert
    Server row: 590 | 208 | 3 | 700 | 1 |
    Client row: 590 | 208 | 3 | 700 | 1 |

    Looking in trace files from subsequent synchronizations, I see the following;
    From 01/30/09;
    <SyncTableMetadata>
    <TableName>Transaction</TableName>
    <SyncDirection>UploadOnly</SyncDirection>
    <LastSentAnchor>
    <Anchor>NxoAAAAAAAA=</Anchor>
    </LastSentAnchor>
    <LastReceivedAnchor></LastReceivedAnchor>
    </SyncTableMetadata>

    then from 02/03/09
    <SyncTableMetadata>
    <TableName>Transaction</TableName>
    <SyncDirection>UploadOnly</SyncDirection>
    <LastSentAnchor>
    <Anchor>NxoAAAAAAAA=</Anchor>
    </LastSentAnchor>
    <LastReceivedAnchor></LastReceivedAnchor>
    </SyncTableMetadata>

     

    Tuesday, February 3, 2009 7:51 PM
  • Still haven't been able to resolve this.

    The lastSentAnchor never appears to change in subsequent synchronizations.

    I'm not coding a specfic insert command on the serverProvider side - I guess I was assuming that since change tracking is automatic on the sqlCe side it would handle only trying to upload new rows. Is this wrong then?

    Thanks
    Wednesday, February 25, 2009 9:47 PM