locked
Store operations during constrain conflict resolution RRS feed

  • Question

  • My scenario: I had two empty stores and i inserted "item 1" into both stores. Then I performed a UploadAndDownload sync with local constrian resolution policy set to "destination wins" and remote constrain resolution policy set to "source wins". I traced the store operations and here are what happend:

    1. "Item 1" from local store was inserted to remote store. The insertion failed due to id constrain.

    2. "Item 1" from remote store was deleted.

    3. "Item 1" from local store was inserted into remote store (this time succeeded).

    So far so good. But during the download process two things happened

    1. "Item 1" from local store is DELETED.

    2. "Item 1" from remote store is inserted into local store.

    These two operations seemed strange because the local policy is destination wins. Shouldn't the framework just try to insert remote version into local store and ignore the constrain error because destination wins? 

    I tried to visualize the store knowledge changes but I was not sure if I understood it correctly:

    Initial state

    Store A: “Value a”,update version = A1, store knowledge = A1

    Store B: “Value b”,update version = B1, store knowledge = B1

     

    During upload (conflict detected)

    Store A: “Value a”,update version = A1, store knowledge = A1

    Store B: “Value b”,update version = B1, store knowledge =B1A1

     

    After upload (conflict resolved)

    Store A: “Value a”,update version = A1, store knowledge = A1

    Store B: “Value a”,update version = B2, store knowledge = B2A1

    After download (so here it should have been one UPDATE, but not one DELETE and one INSERT)

    Store A: “Value a”,update version = B2, store knowledge = A1B2

    Store B: “Value a”,update version = B2, store knowledge = B2A1

    Friday, April 16, 2010 7:20 PM

Answers

  • Friendly Dog II,

    what you see is correct.

    in the beginning you have item5 on both source and destination (with different itemId).

    Source                   Destination

    (s1) "item5"            (d1) "item5"

    after the first sync, the constraint is resolved with "Destination Wins", which means the item coming from source is deleted locally on the destination (with a new version so that the conflict resolution propagates). SO, after the sync you have this:

    Source                    Destination

    (s1) "item5"             (d1) "item5"

                                   (s1) - DELETED (marked as a tombstone)

    when you sync back, from destination to source, there will be 2 changes:  an INSERT for item d1 and a DELETE for item s1. This way the constraint is not re-detected, since you have already resolved it.

     

    Hope this helps.

    Adrian

    Friday, April 16, 2010 8:10 PM

All replies

  • Friendly Dog II,

    what you see is correct.

    in the beginning you have item5 on both source and destination (with different itemId).

    Source                   Destination

    (s1) "item5"            (d1) "item5"

    after the first sync, the constraint is resolved with "Destination Wins", which means the item coming from source is deleted locally on the destination (with a new version so that the conflict resolution propagates). SO, after the sync you have this:

    Source                    Destination

    (s1) "item5"             (d1) "item5"

                                   (s1) - DELETED (marked as a tombstone)

    when you sync back, from destination to source, there will be 2 changes:  an INSERT for item d1 and a DELETE for item s1. This way the constraint is not re-detected, since you have already resolved it.

     

    Hope this helps.

    Adrian

    Friday, April 16, 2010 8:10 PM
  • My scenario is "Source wins" during upload. But I got your point. Thanks!
    Friday, April 16, 2010 8:14 PM