Sync fails with duplicate key constraint failue
See original GitHub issueSyncing from Sqlite to MySQL. First sync syncs to from the server to the client. Subsequent sync (to sync lo local change to the remote) fails with:
[InternalApplyThenGetChangesAsync]..[InternalApplyThenGetChangesAsync]..[InternalSaveScopeInfoClientAsync]..Duplicate entry '3ea49ef3-02c8-4cd0-af39-7acffab1338f-v1-YRV8q709t1f3m4tvB/5mP...' for key 'PRIMARY' (Dotmim.Sync.SyncException)
at Dotmim.Sync.RemoteOrchestrator.InternalApplyThenGetChangesAsync(ScopeInfoClient cScopeInfoClient, ScopeInfo cScopeInfo, SyncContext context, ClientSyncChanges clientChanges, DbConnection connection, DbTransaction transaction, CancellationToken cancellationToken, IProgress`1 progress)
at Dotmim.Sync.SyncAgent.SynchronizeAsync(String scopeName, SyncSetup setup, SyncType syncType, SyncParameters parameters, CancellationToken cancellationToken, IProgress`1 progress)
at Dotmim.Sync.SyncAgent.SynchronizeAsync(String scopeName, SyncSetup setup, SyncType syncType, SyncParameters parameters, CancellationToken cancellationToken, IProgress`1 progress)
[...]
It does appear before this that the client change is synced to the server, but something is going wrong here. This is with a minimal stock sync setup:
public class Foo
{
public MariaDBSyncProvider ServerProvider { get; set; }
public SqliteSyncProvider ClientProvider { get; set; }
public SyncSetup Setup { get; set; }
public SyncAgent Agent { get; set; }
public Foo()
{
ServerProvider = new MariaDBSyncProvider("Data Source=localhost,3306;Initial Catalog=project;User ID=user;Password=password");
var path = ""; // redacted for simplicity
ClientProvider = new SqliteSyncProvider(path);
Setup = new SyncSetup("Table1", "Table2");
Agent = new SyncAgent(ClientProvider, ServerProvider);
}
public async Task onEvent()
{
// Persist local changes...
//...
// Sync to remote...
var result = await Agent.SynchronizeAsync("v1", Setup, SyncType.ReinitializeWithUpload);
Console.WriteLine(result);
}
}
Using:
<PackageReference Include="Dotmim.Sync.MariaDB" Version="0.9.8" />
<PackageReference Include="Dotmim.Sync.Sqlite" Version="0.9.8" />
Issue Analytics
- State:
- Created 7 months ago
- Comments:14 (8 by maintainers)
Top Results From Across the Web
Capsule sync fails with "duplicate key value violates ...
Issue. Getting following error when synchronizing Capsule. Raw. duplicate key value violates unique constraint ...
Read more >Repo sync failed with: duplicate key value violates unique ...
Syncing AlmaLinux 8 Base repository fails with: duplicate key value violates unique constraint “rpm_updatecollection_name_update_record_id_6ef33bed_uniq”.
Read more >postgresql duplicate key violates unique constraint
The "duplicate key" error is telling you that the work was not done because it would produce a duplicate key, not that it...
Read more >Full Active Directory sync fails with constraint violation error
Active Directory full sync fails with duplicate key error. Steps to Reproduce. Use MS AD directory; Incremental synchronization disabled (enable ...
Read more >Error when syncing channels in SUSE Manager 4.2
Error when syncing channels in SUSE Manager 4.2: duplicate key value violates unique constraint "rhn_channelcomps_cid_ctype_uq".
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

next version will be publish early next month I think
Let me put together a quick console app with a schema demonstrating the failure and I’ll get back to you.