none
Syncing from client (SQL Express 2008 R2) to central DB (MSSQL Server 2008) not uploading new changes Microsoft Sync Framework 2.1 RRS feed

  • General discussion

  • Hi,

    We are developing a system where all tables are synced to the clients but only certain tables are synced to the Central DB. There are 2 different buttons for syncing upwards and downwards. I am using the SyncOrchestrator.Synchronize() method to syncronize the dbs. Syncing downwards works fine. but syncing upwards we are having problems. In the logs it shows that 41 changes has been uploaded but  we can see no changes on the central DB. Even if we make no changes it still says 41 changes were uploaded. We followed the walk through on the MSDN site: http://msdn.microsoft.com/en-us/library/ee617382.

    We have 8 tables with 200 000 - 4000 000 rows, so we created a scope for each table and one general scope for the other tables that needs to be downloaded and one for all the tables that needs to be uploaded.

    Thanks,

    Waldo

    Friday, June 22, 2012 2:26 PM

All replies

  • try subscribing to the ApplyChangesFailed event of the central db sync provider and see if its raising an error or conflict.

    or you may also enable sync fx tracing in verbose mode to give you detailed trace of the sync.

    Monday, June 25, 2012 1:44 AM
    Moderator
  • Hi JuneT,

    I enabled tracing in verbose mode. There were conflicts like 'Optimistic change application failed' followed by 'Checking for conflict.   Remote peer contains local change. Returning RemoteSupersedes'. I setup another client on a new machine but that one also stopped syncing. It could'nt downsync nor upsync.  It showed no Failed changes nor any changes uploaded or downloaded although I made changes on the local DB and then on the online DB.  

    Any help will be Greatly Appreciated.

    private void UpSync()
            {
                try
                {
                    SyncOrchestrator syncOrchestrator = new SyncOrchestrator();
                    // set local provider of orchestrator to a sync provider associated with the
                    // ProductsScope in the SyncExpressDB express client database
                    SqlSyncProvider RemoteProvider = new SqlSyncProvider("TestUP", _serverConn);
                    SqlSyncProvider LocalProvider = new SqlSyncProvider("TestUP", _clientConn);
    
                    //Set memory allocation to the database providers
                    RemoteProvider.MemoryDataCacheSize = MemorySize;
                    LocalProvider.MemoryDataCacheSize = MemorySize;
                    RemoteProvider.CommandTimeout = 3000;
                    LocalProvider.CommandTimeout = 3000;
                    //Set application transaction size on destination provider.
                    RemoteProvider.ApplicationTransactionSize = BatchSize;
                    // set local provider of orchestrator to a sync provider associated with the
                    // ProductsScope in the SyncExpressDB express client database
                    syncOrchestrator.LocalProvider = LocalProvider;//new SqlSyncProvider("TestUP", _clientConn);
    
                    // set the remote provider of orchestrator to a server sync provider associated with
                    // the ProductsScope in the SyncDB server database
                    syncOrchestrator.RemoteProvider = RemoteProvider;//new SqlSyncProvider("TestUP", _serverConn);
    
                    // set the direction of sync session to Upload and Download
                    
                    syncOrchestrator.Direction = SyncDirectionOrder.Upload;
    
                    // subscribe for errors that occur when applying changes to the client
                    ((SqlSyncProvider)syncOrchestrator.LocalProvider).ApplyChangeFailed += new EventHandler<DbApplyChangeFailedEventArgs>(Program_ApplyChangeFailed);
                    ((SqlSyncProvider)syncOrchestrator.RemoteProvider).ApplyChangeFailed += new EventHandler<DbApplyChangeFailedEventArgs>(Server_ApplyChangeFailed);
                    Trace("Start Synchin up TstUP");
                    // execute the synchronization process
                    SyncOperationStatistics syncStats = syncOrchestrator.Synchronize();
    
                    // print statistics
                    Trace("Start Time: " + syncStats.SyncStartTime);
                    Trace("Total Changes Uploaded: " + syncStats.UploadChangesTotal);
                    Trace("Total Changes Failed: " + syncStats.UploadChangesFailed);
                    Trace("Total Changes Downloaded: " + syncStats.DownloadChangesTotal);
                    Trace("Complete Time: " + syncStats.SyncEndTime);
                    Trace(String.Empty);
                }
                catch (Exception ex)
                {
                    Trace(ex.ToString());
                }
            }
    
    private void SyncDaisy(string scope)
            {
                try
                {
                    SyncOrchestrator syncOrchestrator = new SyncOrchestrator();
    
                    // set local provider of orchestrator to a sync provider associated with the
                    // ProductsScope in the SyncExpressDB express client database
                    SqlSyncProvider RemoteProvider = new SqlSyncProvider(scope, _serverConn);
                    SqlSyncProvider LocalProvider = new SqlSyncProvider(scope, _clientConn);
    
                    //Set memory allocation to the database providers
                    RemoteProvider.MemoryDataCacheSize = MemorySize;
                    LocalProvider.MemoryDataCacheSize = MemorySize;
    
                    //Set application transaction size on destination provider.
                    RemoteProvider.ApplicationTransactionSize = BatchSize;
                    RemoteProvider.CommandTimeout = 3000;
                    LocalProvider.CommandTimeout = 3000;
                    syncOrchestrator.LocalProvider = LocalProvider;//new SqlSyncProvider(scope, _clientConn);
    
                    // set the remote provider of orchestrator to a server sync provider associated with
                    // the ProductsScope in the SyncDB server database
                    syncOrchestrator.RemoteProvider = RemoteProvider;//new SqlSyncProvider(scope, _serverConn);
    
                    // set the direction of sync session to Upload and Download
                    syncOrchestrator.Direction = SyncDirectionOrder.Download;
    
                    // subscribe for errors that occur when applying changes to the client
                    ((SqlSyncProvider)syncOrchestrator.LocalProvider).ApplyChangeFailed += new EventHandler<DbApplyChangeFailedEventArgs>(Program_ApplyChangeFailed);
                    ((SqlSyncProvider)syncOrchestrator.RemoteProvider).ApplyChangeFailed += new EventHandler<DbApplyChangeFailedEventArgs>(Server_ApplyChangeFailed);
                    Trace("Start Synchin Down" + scope);
                    // execute the synchronization process
                    
                    SyncOperationStatistics syncStats = syncOrchestrator.Synchronize();
                    //SyncTracer.Verbose(syncStats.UploadChangesApplied + " Chaneg");
                    // print statistics
                    Trace("Start Time: " + syncStats.SyncStartTime);
                    Trace("Total Changes Uploaded: " + syncStats.UploadChangesTotal);
                    Trace("Total Changes Failed: " + syncStats.UploadChangesFailed);
                    Trace("Total Changes Downloaded: " + syncStats.DownloadChangesTotal);
                    Trace("Complete Time: " + syncStats.SyncEndTime);
                    Trace(String.Empty);
                }
                catch (Exception ex)
                {
                    Trace(ex.ToString());
                }
            }
    
     private void DownSync()
            {                    
                SyncDaisy("TestDown");
                SyncDaisy("TestUP");
    }

    Thanks,

    Waldo

    Wednesday, June 27, 2012 8:06 PM
  • so the new client simply stops sync? no error whatsoever on the trace?

    if you suspect your sync is going slow and you see there are conflicts, then that explains it.

    sync fx tries to apply the change, it cant, so it has to raise a conflict or error, when it does, it also loads the destination row that is in conflict. multiply that by the number of conflicts.

    do you have an explicit conflict handling resolution?

    Thursday, June 28, 2012 2:35 AM
    Moderator
  • This message does not look like real conflict, could you paste completed trace info?
    Thursday, June 28, 2012 9:03 AM
  • There are no errors in the trace. It only says, 'Failed to insert' and then it goes to the same as in my previous post about optimistic change and remote supersedes.  

    I'm wondering if my whole procedure is maybe at fault. The size of the DB is about 5 GB. So what I do is the following:

    1. Provision the server.
    2. Create a backup of the server.
    3. Restore on a  Client. (when i try to sync on the client it does not want to work so I provision the client again)
    4. Provision the client. 
    5. Create backup of the client and restore on the other clients
    6. Start Syncing

    I've restored another client and it also stopped syncing. I update a single row on two separate clients and uploaded the first one and then the second one. As expected the second change did not go through (Action.Continue although I'd like to use Action.RetryWithForceWrite but that just loops). Now the second client does not want to Sync.  It shows Changes applied but no changes are being made on the Local DB. If I download again it shows the same amount. When I do a change on the local DB it shows no changes were uploaded.

     29-06-2012 20:32:38 > Start Synchin up TestUP
     29-06-2012 20:32:39 > Start Time: 2012/06/29 08:32:38 PM
     29-06-2012 20:32:39 > Total Changes Uploaded: 0
     29-06-2012 20:32:39 > Total Upload Changes Applied: 0
     29-06-2012 20:32:39 > Total Upload Changes Failed: 0
     29-06-2012 20:32:39 > Total Changes Downloaded: 0
     29-06-2012 20:32:39 > Total Download Changes Failed: 0
     29-06-2012 20:32:39 > Total Download Changes Applied: 0
     29-06-2012 20:32:39 > Complete Time: 2012/06/29 08:32:39 PM

    29-06-2012 20:35:21 > Start Synchin Down TestUP
     29-06-2012 20:35:23 > Start Time: 2012/06/29 08:35:21 PM
     29-06-2012 20:35:23 > Total Changes Uploaded: 0
     29-06-2012 20:35:23 > Total Upload Changes Applied: 0
     29-06-2012 20:35:23 > Total Upload Changes Failed: 0
     29-06-2012 20:35:23 > Total Changes Downloaded: 371
     29-06-2012 20:35:23 > Total Download Changes Failed: 0
     29-06-2012 20:35:23 > Total Download Changes Applied: 371
     29-06-2012 20:35:23 > Complete Time: 2012/06/29 08:35:23 PM

    How do I attach the trace info (TraceSample.log)? it's about 10 MB. 

    Thanks,

    Waldo

    Friday, June 29, 2012 7:07 PM
  • Waldo,

    after you restore the backup on step 3, make sure to run PerformPostRestoreFixup on the database before synching it.

    internally, Sync Framework stores replica Ids for each replica in the sync community, when you restore, the restored db and the original db has the same replica id.

    everytime you restore, make sure you run PerformPostRestoreFixup first before synching the database. Just look up in the documentation how to call the method.

    Cheers,

    JuneT

    Saturday, June 30, 2012 2:17 AM
    Moderator