none
Sync with 2 scope - one download and one upload - don't send update records on server from client RRS feed

  • Question

  • Our application is server and many clients. We use SQL Server 2008. Synchronization is work via WCF.
    Problem with sync one table - Ticket. In begin, for our was needed only sync table Ticket from all clients to server database - used one Scope - UploadTicketScope. This sync process run by scheduler. 
    But later, was necessary getting records from table Ticket from server database. Because application already worked we were added Scope for every client with filter by client's ID and also Scopes for every cleint in server database (e.q. DownloadTicketScope_A63BA14A-267E-4D27-9EC6-D9B19946DE55).
    After this, records which were get from server database, don't send to server after change on clients over UploadTicketScope. But new records, what were created on client sending on server successfully.
    Please, help me, I don't understand problem at 2 scopes or other reason and how this problem solve, thanks!

    Wednesday, March 14, 2012 10:05 AM

Answers

  • nothing wrong that i can find in the provisioning code...

    you need to confirm if you make an update, does the corresponding entry in the tracking table get updated

    if it gets updated, subscribe to the changesselected event of your local provider to see if it the update gets selected

    if it gets selecte, subscribe to the ApplyChangeFailed event of the remote proider to see if its encountering an error applying the change

    looking at the logs you posted earlier, there was no change selected.

    • Marked as answer by viko_vks Wednesday, March 21, 2012 8:27 PM
    Wednesday, March 21, 2012 12:40 PM
    Moderator

All replies

  • just to clarify, you want to upload inserted rows only from the client, download rows from the server but dont upload updates?

    Wednesday, March 14, 2012 11:30 AM
    Moderator
  • All data inserting and updating at client's database. But when we change PC on clients, we want has ability load data from server's database. 

    In total, our  process synchronization can can show as:

    1. Create and update data rows in client's database

    2. Send data rows on server (UploadTicketScope)

    After reinstall OS or change PC on client:

    3. Get data rows from server's database (DownloadTicketScope_A63BA14A-267E-4D27-9EC6-D9B19946DE55)

    4. Update rows on client

    5. Send updated data rows on server (UploadTicketScope)

    This plan is right? Or I'm wrong anything? Please, help

    Wednesday, March 14, 2012 1:38 PM
  • two ways to deal with it:

    1. when you want to reinstall OS or change PC, back up the client database.  after reinstall of OS, restore client database and do PerformPostRestoreFixup

    2. Create one scope only:

     a. Create a filtered scope for client

     b.1 check if client database is empty, if it is, set SyncDirection to Download and sync.

     b.2 check if client database is empty, if it is not empty, set SyncDirection to Upload and sync. 

    Thursday, March 15, 2012 2:16 AM
    Moderator
  • Thanks for your reply, JuneT!

    Now we write second version of application and in this version will be change mechanism synchronization how you advise.

    But now for us need fix working version of application because synchronization don't work now.

    I think our problem is overlapping scope on client side (this problem described here

    http://msdn.microsoft.com/en-us/library/dd918682.aspx). We download records from table Ticket from server via filtered scope DownloadTicketScope_A63BA14A-267E-4D27-9EC6-D9B19946DE55 and after change record trying upload changed records to server via not filtered scope UploadTicketScope. Now changed records don't upload on server.

    Please, help for us. What we can do now for send changed records from clients to server. We has about 20 clients and half of them contains records what were downloaded from server via DownloadTicketScope_A63BA14A-267E-4D27-9EC6-D9B19946DE55 scope.


    • Edited by viko_vks Wednesday, March 21, 2012 7:17 AM
    Wednesday, March 21, 2012 6:28 AM
  • can you enable sync framework tracing and post the trace here? set it to verbose.

    here's how you do it: http://msdn.microsoft.com/en-us/library/cc807160.aspx

    Wednesday, March 21, 2012 7:02 AM
    Moderator
  • Here Verbose Trace Sync  I was place trace from client (~4Mb).  In trace you can see next scopes:

    Sync reference books:

    ServerSideScope
    CustomerSideScope
    TicketsNumberScope_d5a8f1dc-fee5-4d47-8083-0a2d2dcb0f69

    Sync Tickets (and additional data):

    UpdateTicketScope
    TicketsDownloadScope_d5a8f1dc-fee5-4d47-8083-0a2d2dcb0f69

    Last update in my synchronization was added call sync scope TicketsDownloadScope_d5a8f1dc-fee5-4d47-8083-0a2d2dcb0f69 after call UpdateTicketScope. I was thinked what this will be have effect, but records also don't send to server.

    Wednesday, March 21, 2012 9:36 AM
  • how are you doing the update? are you updating the PK value?
    Wednesday, March 21, 2012 9:56 AM
    Moderator
  • Update with using NHibernate. PK values don't updates. Query from SQL Profiler look like this:
    UPDATE Ticket SET TicketStatusType=2,... WHERE UID=...

    Wednesday, March 21, 2012 10:59 AM
  • not sure what's wrong with your setup. just tested having same table on two different scopes and it works.

    how did you provision the second scope TicketsDownloadScope_d5a8f1dc-fee5-4d47-8083-0a2d2dcb0f69?

    when you update a row, can you check the corresponding _tracking table to see if the corresponding row is updated? just look at the last update time column

    Wednesday, March 21, 2012 11:33 AM
    Moderator
  • Thanks, for answer! Will be check updating _tracking table, this code for provisioning TicketsDownloadScope_d5a8f1dc-fee5-4d47-8083-0a2d2dcb0f69:

    //METHOD PROVISIONING SCOPE TEMPLATE
    
    DbSyncScopeDescription scope = new DbSyncScopeDescription(templateTicketsScope);
    
    var tables = descHelper.GetTicketsDownloadTablesDesc();
    foreach (var t in tables)
     scope.Tables.Add(t);
    
    serverProvision = new SqlSyncScopeProvisioning(connection, scope, SqlSyncScopeProvisioningType.Template);   
    serverProvision.ObjectSchema = objectSchema;
    
    // Filter clauses
    serverProvision.Tables["Ticket"].FilterColumns.Add(new DbSyncColumnDescription("DivisionUID", "uniqueidentifier"));
    serverProvision.Tables["Ticket"].FilterParameters.Add(new SqlParameter("@DivisionUID", SqlDbType.UniqueIdentifier));
    serverProvision.Tables["Ticket"].FilterClause = "[side].DivisionUID=@DivisionUID";
    ...
    
    serverProvision.SetCreateProceduresForAdditionalScopeDefault(DbSyncCreationOption.Create);
    serverProvision.SetCreateTableDefault(DbSyncCreationOption.Skip);
    serverProvision.SetCreateTrackingTableDefault(DbSyncCreationOption.Skip);
    serverProvision.SetCreateTriggersDefault(DbSyncCreationOption.Skip);
    serverProvision.SetCreateProceduresDefault(DbSyncCreationOption.Skip);
    
    serverProvision.Apply();
    
    
    //METHOD PROVISIONING SCOPE
    
    SqlSyncScopeProvisioning prov = new SqlSyncScopeProvisioning(connection);
    prov.ObjectSchema = objectSchema;
    if (!prov.ScopeExists(scopeName))
    {
        prov.PopulateFromTemplate(scopeName, templateTicketsScope);
    
        prov.Tables["Ticket"].FilterParameters["@DivisionUID"].Value = divisionUid;
        ...
        prov.Apply();
    }
    
    

    Wednesday, March 21, 2012 12:03 PM
  • nothing wrong that i can find in the provisioning code...

    you need to confirm if you make an update, does the corresponding entry in the tracking table get updated

    if it gets updated, subscribe to the changesselected event of your local provider to see if it the update gets selected

    if it gets selecte, subscribe to the ApplyChangeFailed event of the remote proider to see if its encountering an error applying the change

    looking at the logs you posted earlier, there was no change selected.

    • Marked as answer by viko_vks Wednesday, March 21, 2012 8:27 PM
    Wednesday, March 21, 2012 12:40 PM
    Moderator
  • Thanks, JuneT!

    Really, in WCF service on server side was turned off processed ApplyChangeFailed. And after select changes from client on server was UpdateToUpdate conflict that don't processed. I was change this on ForceRewrite and now all working fine!

    Wednesday, March 21, 2012 8:34 PM