Reputation: 203
I've been getting conflicts during synchronization (mostly INSERT statements, one was UPDATE) using MS Sync Framework on the server (master) database.
Example:
The INSERT statement conflicted with the FOREIGN KEY constraint "FK_YX_Y". The conflict occurred in database "ZZZ", table "dbo.Y", column 'Id'.
In this case I have a many-to-many relationship between tables X and Y. They are added to the same sync scope (say, "sync1"). The many-to-many join table is also added to the same scope:
sync1.Tables.Add(X);
sync1.Tables.Add(Y);
sync1.Tables.Add(YX);
I always add them in the insert order (e.g. parent first, child next). It seems that somehow the Y table is not fully synced by the time YX many-to-many join table starts to sync, which violates the constraint.
I have all the FK, PK etc. on both local database and remote server created during the sync setup.
I see similar issue not only on may-to-many but also on one-to-many relationships.
The conflicts do not happen all the time, but time to time. However, there are still a lot of them. Some of them stopped showing up without any explicit action.
Thinking that it might be due to the size of the tables (YX - 2.5M records, Y - 170K, X - 570K), I tried to batch the sync and set large timeouts on syncProviders, but that doesn't seem to have helped.
There is some fundamental issue, which I coudn't figure out yet.
Upvotes: 4
Views: 166