Dotmim.Sync
Dotmim.Sync copied to clipboard
Sync two sql server databases not working properly?
I am using the framework to sync to sql server databases one is the localdb and the other one is on the cloud with WinForms application. I use the code below to do the sync operation
`string constring = @"Data Source= " + Properties.Settings.Default.Server + " ; Database = " +
Properties.Settings.Default.Database + " ; User Id = " + Properties.Settings.Default.User_Name + "; Password = " +
Properties.Settings.Default.Password + "; Encrypt=True; TrustServerCertificate=True;
MultipleActiveResultSets=True";
string connect = @"Data Source=(LocalDB)\MSSQLLocalDB;Initial Catalog=db_file1;Integrated
Security=SSPI;AttachDBFilename= " + Properties.Settings.Default.dbFilePath + "";
SqlSyncProvider serverProvider = new SqlSyncProvider(connect);
SqlSyncProvider clientProvider = new SqlSyncProvider(constring);
SyncAgent agent = new SyncAgent(clientProvider, serverProvider, new string[] { "customers_tbl", "installments_tbl",
"items_tbl", "prod_disabled_zone_tbl", "products_tbl", "recipient_tbl", "returned_tbl", "substitutions_tbl",
"users_activity_tbl", "users_tbl", "zones_tbl" });
var syncContext = await agent.SynchronizeAsync();`
two to three months ago the operation was working properly but now each time I want to do sync operation I get different king of warnings and errors. Some of them stops the sync entirely while others does not stop sync operation but the it syncs a small number of records out of a large number of records. some of the errors and warnings I get: 1- "the command execution can not procced due to a pending a synchronous already in progress". 2- "procedure of function customers_tbl_changes has too many arguments specified". 3- "connection can not be changed while async operation is in progress". 4- "value cannot be null" 5- "the server failed to resume the transaction desc:3f00000002".
Did you changed your schema since you are using DMS
?
If yes, you should Deprovision and Provision again, to generate the new metadatas correctly (stored proc, triggers and so on ...)
Are you using the last version ?
Yes the schema has a little changes. How can I add Deprovision and Provision to my existing code?
Now I have updated it to newest version which I think 0.9.4. The old version was 0.6.0
If you are in test mode, just restart from scratch, it will be easier
If you are in production, call the DeprovisionAsync()
method on both side, Then Call ProvisionAsync()
on both side
I am in production mode but rather I did delete all triggers, procs, and tracking tables from both sides. Then, I used generate script - data only feature of SQL Server to export the data from server and import it into each client. One thing that I notice, when the connection is slow and you have a large number of records to be synced it faces timeout problem. Could you suggest a way to deal with this, please?
Did you tried to set a batch size low ? like 1000 ?
Where to set the batch size in the code?
SyncOptions on the client side
https://dotmimsync.readthedocs.io/Configuration.html#batch-mode
Thanks a lot. I will try it and let you know.