locked
Yet another Deprovisioning-Reprovisioning question RRS feed

  • Question

  • We have one server (SQL Server) and many clients (SQL Server Express) in our system.

    Synchronization databases working by next scenario: From server into clients databases send data from over 10 tables, from 5 tables send data from clients to server and 4 tables syncronize bi-directional. Primary Key in all tables is Uniqueidentifier.

    Now we need update database's schema often, but system is now in productive and have data in tables stored on clients. When I doing reprovisioning tables on clients and on server, on next synchronization occurs conflict LocalInsertRemoteInsert. This conflict I was fix by updating all tracking tables after provisioning: 

    UPDATE sync.{TABLE_NAME}_tracking SET scope_update_peer_key=0, scope_update_peer_timestamp=0
    

    This query I was execute for tables which sends from server to clients, and bi-directional - on clients, for tables sends from clients on server - on server.

    This operation I was execute for replace operation LocalInsertRemoteInsert to LocalUpdateRemoteUpdate, which I can process on destination side.

    My code for ApplyChangeFailed on server side:

    private void syncProvider_ApplyChangeFailed(object sender, DbApplyChangeFailedEventArgs e)
    {
        if (e.Conflict.Type == DbConflictType.LocalUpdateRemoteUpdate)
        {
            var tablesBiDirectional = new List<string>() { "TicketPack", "TicketNumber", "Ticket", "TicketHistory" };
            if tablesBiDirectional.Contains(e.Conflict.RemoteChange.TableName))
            {
                 e.Action = ApplyAction.Continue;
            }
            else 
            {
                e.Action = ApplyAction.RetryWithForceWrite;
            }
         }            
     }
    
    

    On clients for these tables I use ApplyAction.RetryWithForceWrite
    My problems for sync bi-directional tables. I was thinked what ApplyAction.Continue work as "do nothing", but now field scope_update_peer_timestamp in tracking tables set new timestamp every session in all tables on server's and client's sides.

    My questions:

    1. What are you think about my method for replacing LocalInsertRemoteInsert conflict to LocalUpdateRemoteUpdate conflict? May be exist better way for this? Or method for solve LocalInsertRemoteInsert conflict without additional operation?

    2. How I can solve problem with loop update data on server and on clients?

    Thanks!

     

    Friday, December 9, 2011 10:54 PM