I have developed a synchronization software that will sync Databases and Directories using Microsoft Sync Framework 2.1.
After a while a client using the application gets this error :
A storage engine operation failed with error code 25104 (HRESULT = 0x80004005, Source IID = {0C733A63-2A1C-11CE-ADE5-00AA0044773D}, Parameters=(4001, 0, 0, , , ,)).
I tried to track the error within my code but with no success.
The error occurs when the SyncOchestrator begins Synchronization. And from the stacktrace I got :
at Microsoft.Synchronization.Files.FileSyncProvider...ctor()
Here is some of my coding :
try
{
// Set options for the sync operation
FileSyncOptions options = FileSyncOptions.ExplicitDetectChanges |
FileSyncOptions.RecycleDeletedFiles | FileSyncOptions.RecyclePreviousFileOnUpdates | FileSyncOptions.RecycleConflictLoserFiles;
FileSyncScopeFilter filter = new FileSyncScopeFilter();
filter.FileNameExcludes.Add("*.lnk"); // Exclude all *.lnk files
filter.FileNameExcludes.Add("*.mdf"); // Exclude all *.mdf files
filter.FileNameExcludes.Add("*.ldf"); // Exclude all *.ldf files
filter.FileNameExcludes.Add("*.MDF"); // Exclude all *.MDF files
filter.FileNameExcludes.Add("*.LDF"); // Exclude all *.LDF files
filter.FileNameExcludes.Add("*.tdms_index"); // Exclude all *.tdms_index files
Thread.Sleep(50);
// Synchronization of 2 Folders
FileSyncProvider providerA = new FileSyncProvider(Guid.NewGuid(), replica1RootPath, filter, options);
FileSyncProvider providerB = new FileSyncProvider(Guid.NewGuid(), replica2RootPath, filter, options);
providerA.DetectChanges();
providerB.DetectChanges();
Thread.Sleep(50);
SyncOrchestrator agent = new SyncOrchestrator();
agent.LocalProvider = providerA;
agent.RemoteProvider = providerB;
agent.Direction = SyncDirectionOrder.Upload;
MessageBox.Show("Let's SYNC");
agent.Synchronize(); // The error happens here
Thread.Sleep(50);
}
catch (Exception e)
{
MessageBox.Show(e.Message);
MessageBox.Show(e.StackTrace);
}
Can you please help me with this? I'm getting frustrated and I don't know where should I look! The code worked perfectly for one year.
For more information :
I'm on C#, Microsoft.Synchronization 2.1, .Net 4, Visual Studio 2015.
Thank you very much for any suggestion.
I finally figured out the solution. It happened that the Metadata file was too big / corrupted. So to solve my problem I fragmented the synchronization and selected all the subfolders one by one instead of selecting just one folder with 260 Go of files.
foreach (string dep in Directory.GetDirectories(plantFolder1)) // different departements
{
string depFolder1 = plantFolder1 + dep.Remove(0, plantFolder1.Length);
string depFolder2 = depFolder1.Replace(subReplica1, subReplica2); ;
Thread.Sleep(50);
// Synchronization of 2 Folders
FileSyncProvider providerA = new FileSyncProvider(Guid.NewGuid(), depFolder1, filter, options);
bool exists = Directory.Exists(depFolder2);
if (!exists)
Directory.CreateDirectory(depFolder2);
FileSyncProvider providerB = new FileSyncProvider(Guid.NewGuid(), depFolder2, filter, options);
providerA.DetectChanges();
providerB.DetectChanges();
Thread.Sleep(50);
SyncOrchestrator agent = new SyncOrchestrator();
agent.LocalProvider = providerA;
agent.RemoteProvider = providerB;
agent.Direction = SyncDirectionOrder.Upload;
agent.Synchronize();
Thread.Sleep(50);
}
That's the solution for my problem. I hope this will help you folks.
Thanks.