locked
Handling conflict table "Master-Detail" in Sync Framework v2 CTP2 RRS feed

  • Question

  • I would like to go back with some issues that i faced before.
    I do paste again what our issue is as below.

    we face the same problem of MASTER-DETAIL relationship. I will point out here all situation from our issues list. The question is: is there any suggest for each of the below issues?

    Let’s assume that we have 02 tables with the master-detail relationship. The master table named: MASTER, and the detail table named DETAIL.

     
    MASTER   DETAIL     

    M_ID        D_ID      

    Value        M_ID      
                   Value     


    + Issue 1: Client Insert Master and Detail, Server Insert Master and Detail, conflict in Master ID

     
    CLIENT SITE (SOURCE)                                      SERVER SITE (DESTINATION)      
                                                          
    MASTER                DETAIL                                   MASTER            DETAIL              

    M_ID    VALUE     D_ID       M_ID    VALUE          M_ID    VALUE     D_ID    M_ID    VALUE      
    m1        v1            d1           m1        dv1               m1         v1            d1        1           1      
    m2        v2            d2           m2        dv2               m2         v2            d2        2           2      
    m3        v3            d3           m3        dv3               m3         v3'           d4        m3        dv3'     

    Steps:
        +     SERVER: Insert Master(m3, v3’) va Detail(d4, m3, dv3’)
        +     CLIENT: Insert Master(m3, v3) va Detail(d3, m3, dv3)
        +     When running Sync, the conflict ClientInsertServerInsert will occurs
        +     If we choose CLIENT-WIN, the result will become:
     

    CLIENT SITE (SOURCE)                               SERVER SITE (DESTINATION)      

    MASTER                DETAIL                            MASTER            DETAIL                   

    M_ID    VALUE     D_ID    M_ID    VALUE      M_ID    VALUE   D_ID    M_ID    VALUE           
    m1        v1            d1        m1        dv1            m1        v1          d1        1        1           
    m2        v2            d2        m2        dv2            m2        v2          d2        2        2           
    m3        v3            d3        m3        dv3            m3        v3          d3        m3        dv3           
                     d4        m3        dv3'                             d4        m3        dv3'           
                                                                     
        +     If we choose SERVER-WIN, the result will become:
     
    CLIENT SITE (SOURCE)                                SERVER SITE (DESTINATION)      

    MASTER               DETAIL                             MASTER             DETAIL              

    M_ID    VALUE     D_ID    M_ID    VALUE       M_ID    VALUE   D_ID    M_ID    VALUE      
    m1        v1            d1        m1        dv1            m1        v1          d1         1          1      
    m2        v2            d2        m2        dv2            m2        v2          d2         2          2      
    m3        v3'           d3        m3        dv3            m3        v3'         d3         m3        dv3      
              d4      m3        dv3'                             d4         m3       dv3'     

    So, in both cases, the record of DETAIL table ((d3, m3, dv3), (d3, m3, dv3’)) might be wrong in biz logic. The new record might not belong to the newly updated master row.


    + Issue 2: Client Update Detail, Server Delete Master and Detail

     
    CLIENT SITE (SOURCE)                                 SERVER SITE (DESTINATION)        

    MASTER                  DETAIL                           MASTER        DETAIL    
        
    M_ID    VALUE        D_ID    M_ID    VALUE    M_ID    VALUE    D_ID    M_ID    VALUE        
    m1        v1               d1         m1         dv1        m1        v1          d1         1           1        
    m2        v2               d2         m2         dv2        m2        v2          d2         2           2        
    m3        v3               d3         m3         dv3’       m3        v3          d3         m3         dv3    

    Steps:
        +     SERVER: Delete Master(m3, v3) and Detail(d4, m3, dv3)
        +     CLIENT: Update Detail(d3, m3, dv3’)
        +     When running Sync, the conflict ClientUpdateServerDelete will occurs
        +     In this situation, there will be only option to let SERVER-WIN, otherwise the data will be inconsistent and exception will occurs.


    + Issue 3: Client Delete Master and Detail, Server Update Detail
     
    CLIENT SITE (SOURCE)                                 SERVER SITE (DESTINATION)      

    MASTER                 DETAIL                             MASTER            DETAIL              

    M_ID      VALUE     D_ID    M_ID    VALUE      M_ID    VALUE  D_ID    M_ID    VALUE      
    m1          v1            d1        m1        dv1            m1        v1        d1         1          1      
    m2          v2            d2        m2        dv2            m2        v2        d2         2          2      
    m3          v3            d3        m3        dv3            m3        v3        d3         m3       dv3'     

    Steps:
        +     SERVER: Update Detail(d3, m3, dv3’)
        +     CLIENT: Delete Master(m3, v3) and Detail(d3, m3, dv3)
        +     When running Sync, the conflict ClientDeleteServerUpdate will occurs
        +     In this situation, there will be only option to let CLIENT-WIN, otherwise the data will be inconsistent and exception will occurs.


    + Issue 4: Client Insert Detail, Server Delete Master
     
    CLIENT SITE (SOURCE)                                SERVER SITE (DESTINATION)      

    MASTER                DETAIL                            MASTER               DETAIL                   

    M_ID    VALUE     D_ID    M_ID    VALUE      M_ID    VALUE     D_ID    M_ID    VALUE           
    m1        v1            d1        m1        dv1            m1        v1            d1        1        1           
    m2        v2            d2        m2        dv2            m2        v2            d2        2        2           
    m3        v3            d3        m3        dv3            m3        v3                           
                                                                     

    Steps:
        +     SERVER: Delete Master(m3, v2)
        +     CLIENT: Insert Detail(d3, m3, dv3)
        +     When running Sync, there is no conflict, but this case will raise SqlException when adding Detail(d3, m3, dv3) to Server but there is no Master record for it.

    So far Microsoft just release Microsoft Sync Framework v2 CTP2. And maybe Microsoft seems added more new feature as Constraint conflict handling to solve the issues as mentioned early. But i cannot found any guidance of constraint conflict handling.

    Thanks
    DX
    • Edited by ckumark Friday, June 26, 2009 7:02 PM Fixing thread title bug
    • Moved by Hengzhe Li Friday, April 22, 2011 2:58 AM (From:SyncFx - Microsoft Sync Framework Database Providers [ReadOnly])
    Sunday, June 14, 2009 3:38 PM

Answers

  • Thank you for your answer. This information is very important for me.

    Thanks
    DX
    • Marked as answer by dungdx Tuesday, June 16, 2009 1:01 AM
    Tuesday, June 16, 2009 1:00 AM

All replies

  • Hi,

    They are good scenarios, and Sync Service ADO.net doesnot provide builtin solution to directly handle them. But as you described, Sync Service can detect these cases and raise Change Failed Event with a conflict or error. Inside the change failed event, the remote change dataset and the possible local conflict rows can be found. Instead of using a builtin conflict action to resolve the conflict, you can modify the local database to fix the conflict, error or business logic. Or just log it and pick the retryNextSync action for the current sync,and fix the records in one of the database before the next sync.

    For the MSFv2 CTP2 constraint conflict feature, it is only available if you plan to write a knowledge sync provider or simple sync provider, the Sync Service ADO.net provider doesnot support it yet. If you have installed CTP2 SyncSDK.msi, you can find more info of this constraint conflict handling feature in SyncSDk_v2.chm under %ProgramFiles%\Microsoft SDKs\Microsoft Sync Framework\v2.0\Documentation\1033\.

    Thanks,
    Dong 



    This posting is provided AS IS with no warranties, and confers no rights.
    Tuesday, June 16, 2009 12:52 AM
    Moderator
  • Thank you for your answer. This information is very important for me.

    Thanks
    DX
    • Marked as answer by dungdx Tuesday, June 16, 2009 1:01 AM
    Tuesday, June 16, 2009 1:00 AM