none
Concurrency on Sync Framework 2.1 RRS feed

  • Question

  • Hello, I want to ask about concurrency on Sync Framework 2.1. We are developing a aplication where n client syncs against 1 server. The server uses sql sever 2005 sp2 and the clients slq server 2008 R2 Express. All tables except 2 are only for download and 2 are upload/downloading and works if only one client synchornize once but, if another client synchronitzes just in the moment of another, the synchronization crash. For us is obviously a problem of concurrency. I learnt at http://msdn.microsoft.com/en-us/library/dd937753.aspx how to detect the concurrency between two threads we don't use this. We created own inherit class of sqlsynprovider and with SyncOrchestrator we synchronize. We don't use NotifyingChangeApplier or ProcessChangeBatch method but we control any error with ApplyChangeFailed. Is it necessary use Change Applier on Sync Framework 2.1? Can somebody tell me a site or a book, anything where I can see how to control concurrency on sync framework? Any example? Is the Pro Sync Framework book good for this propouse? Thanks a lot!
    • Edited by Jorge Grau Tuesday, December 13, 2011 5:36 PM
    Tuesday, December 13, 2011 5:33 PM

Answers

  • Hi,

    Finally I solved the problem.

    When I delete the scope filter for "order" the synchronization with concurrency works fine. The problem was that the download filter of "order" download "orders" with wrong user, because the scope of "order" on server was corrupted by the concurrency, and "order" uploading works fine because the scope of client wasn't corrupted. Because the download filter was wrong the client data base don't updates never. When deleted the filter for "order" all works fine.

    Thanks a lot JuneT.

    • Marked as answer by Jorge Grau Thursday, December 22, 2011 12:16 PM
    Thursday, December 22, 2011 12:16 PM

All replies

  • it would help if you share the actual error you are getting.

    you may also want to enable Sync Framework tracing.

    If you are using WCF, i suggest you check your WCF configuration especially around your service instances.

     

    Wednesday, December 14, 2011 1:01 AM
    Moderator
  • Hi, Ok, I will explain me: When two clients synchronize the rows, the data inserts on the server is successful. Furthermore, the server have an intern process and When a new row then it modifies and, in theory, the triggers modify the metadata. Well, when the clients syncs again the row on the server is deleted and replaced with the row of the client. The data server doesn't have control over the sync process and if the client inserts new rows it restores all lines to the state they were before the concurrence happened. his only happens with one of the the two clients When hving concurrency the 'solution' is to reset the metadata on the server but the problem of concurrency shows up once more. About SyncFx tracer we activated and we didn't see anything. If you want I can paste the tracer log here. Regards.
    • Edited by Jorge Grau Wednesday, December 14, 2011 9:59 AM
    Wednesday, December 14, 2011 9:59 AM
  • sorry but am a bit lost in your scenario.

    is it crashing? or are you simply not getting the behaviour your expecting?

    so let me just clarify my understanding:

    1. client inserts synchronize fine

    2. your server has some process- what does it exactly do? you mention, when new row it modifies it, how does it modify a new row?

    3. when the client syncs again it deletes and replaces the row - how do you this?

    4. what do you mean it restores rows to prior state?

    Wednesday, December 14, 2011 1:15 PM
    Moderator
  • Sorry, my english it's a little bit limited... I will try to explain myself again:

    When I said that it "crashed" I wanted to say that suddenly the program doesn't work like it usually does. When the client inserts a row, this row is modified later by other program that puts true into a field to specify it's been "processed" (for say "processed"). And when the concurrency occurs the client reinserts the row and this field returns to false. Also, the users' table (what is also upload/download) crashes and the data is stored incorrectly on the server but not on the clients.

    I will explain it all summed up:

    1. two clients sync at the same time.
    2. the inserted rows is processed by other program and it changes into true the value of the field "processed"
    3. one of these clients synchronizes again another row. This client has problems because concurrency has damaged the server's database.
    4. the row, after synchronizing, it synchronizes again with the client.
    ...
    X. whatever sync new row of this client put the field of old rows syncs after concurrency to false.
    Each new row of the client synchronized will change the previously synchronized after the concurrence rows' field "processed" into false.
     
    I put a visual explanation:

    client                                            server                                          client
    A----o                                           A----o                                          B----o
    A----o                                           B----o                                          B----o
    A----o                                           A----o                                          B----o
    A----x =====(new)========> A----x 
                                                        B----x <=====(new)======== B----x
                                                  (concurrency)
                              
    Other program updates the row server changing the "processed" value into true but the client don't update.

    client                                           server                                          client
    A----o                                          A----o                                          B----o
    A----o                                          B----o                                          B----o
    A----o                                          A----o                                          B----o
    A----x                                          A----o 
                                                       B----o                                          B----x

    new sync

    client                                           server                                          client
    A----o                                          A----o                                          B----o
    A----o                                          B----o                                          B----o
    A----o                                          A----o                                          B----o
    A----x ====( incorrect )=====> A----x <---- Reinsert
                                                       B----o =====(update)======> B----o
    A----x =====(new)========> A----x
                                                        ....
                                             (not concurrency)
                                                      B----x <=====(new)======== B----x


    As you can see, on one of the clients the rows are reinserted and it never updates the local data.

    I hope I have explained better the scenario.


    • Edited by Jorge Grau Thursday, December 15, 2011 8:21 AM
    Wednesday, December 14, 2011 3:49 PM
  • what is your primary key?

    am i right one of the client is uploadonly while the other is bidirectional?

    Am still lost as to why the client would reinsert the same row it already uploaded.  


    Thursday, December 15, 2011 2:37 PM
    Moderator
  • Hi,

    the sync of scope has two tables ={ order (what I explained before), lineOrder (correct) }. The table 'order' has these primary keys:

    -OrderId

    -UserName

    No, it doesn't. When synchronizing "order" all clients are bidirectional and when synchronizing "users" (another table) is also bidirectional. I don't understand why the client reinserts the same row but... it happens. Is it possible that the process of synchronization of the table "users" is corrupting the synchronization of the table "order" because in it the name of the user is used?

    Going back to the original questions, is the concurrency controlled in SncFx or will I have to create some Method to control it?

    Thanks a lot,

    Thursday, December 15, 2011 4:55 PM
  • can you try applying this hotfix: http://support.microsoft.com/kb/2530271

     

    Friday, December 16, 2011 1:49 AM
    Moderator
  • Hi,

    Finally I solved the problem.

    When I delete the scope filter for "order" the synchronization with concurrency works fine. The problem was that the download filter of "order" download "orders" with wrong user, because the scope of "order" on server was corrupted by the concurrency, and "order" uploading works fine because the scope of client wasn't corrupted. Because the download filter was wrong the client data base don't updates never. When deleted the filter for "order" all works fine.

    Thanks a lot JuneT.

    • Marked as answer by Jorge Grau Thursday, December 22, 2011 12:16 PM
    Thursday, December 22, 2011 12:16 PM