SerializationException occurs when retrieving knowledge in peer to peer scenario RRS feed

  • Question

  • I am synchronizing two sql server dbs over wcf.  In some cases the server is throwing a SerializationException when retrieving the knowledge.  The code is calling the GetSyncBatchParameters method of the DBSyncProvider.  It seems like this is only happening when a previous sync failed with a lot of conflicts.  In my case I've been catching the ApplyChangeFailed event and and setting the action to RetryNextSync if the error is actually an exception where the conflict type is DBConflictType.ErrorsOccurred.  The sync proceeds with other rows and everything seems to be ok.  However, the next time you try to sync, the sync fails almost immediately when it tries to deserialize the knowledge. 


    The only way that I've found to recover from this error is to delete the sync knowledge and all of the data that was sync'd, fix up whatever was causing the issues in my data and try again.  This is fine during development but would be disastrous in a production environment. 


    This only seems to occur when I have a lot of exceptions thrown during the sync process.  Could it be that the exception data stored with the sync knowledge is too large? 


    Here are the exception details:


    System.Runtime.Serialization.SerializationException occurred
      Message="Deserialization failed, typically due to invalid serialization data supplied to the deserializer. "
           at Microsoft.Synchronization.SyncKnowledge.DeserializeHelper(SyncIdFormatGroup idFormats, Byte[] data, IReplicaKeyMap replicaKeyMap)
           at Microsoft.Synchronization.SyncKnowledge.Deserialize(SyncIdFormatGroup idFormats, Byte[] data)
           at Microsoft.Synchronization.Data.DbSyncProvider.ReadScopeInfo(DbSyncScopeMetadata scopeMetadata)
           at Microsoft.Synchronization.Data.DbSyncProvider.GetScope(DbSyncSession DbSyncSession)
           at Microsoft.Synchronization.Data.DbSyncProvider.GetSyncBatchParameters(UInt32& batchSize, SyncKnowledge& knowledge)
           at MyCode.SyncService.GetKnowledge(UInt32& batchSize, SyncKnowledge& knowledge) in C:\MyCode\Sync\Server\SyncService.vb:line 97
      InnerException: System.Runtime.InteropServices.COMException
           Message="Exception from HRESULT: 0x8004100C"
                at Microsoft.Synchronization.CoreInterop.SyncServicesClass.DeserializeSyncKnowledge(Byte[] pbKnowledge, UInt32 cbKnowledge, IReplicaKeyMap pReplicaKeyMap)
                at Microsoft.Synchronization.SyncKnowledge.DeserializeHelper(SyncIdFormatGroup idFormats, Byte[] data, IReplicaKeyMap replicaKeyMap)
           InnerException:  "Exception from HRESULT: 0x8004100C"

    Thanks for any help you can provide.

    • Moved by Hengzhe Li Friday, April 22, 2011 7:45 AM (From:SyncFx - Microsoft Sync Framework Database Providers [ReadOnly])
    Tuesday, December 2, 2008 9:45 PM

All replies

  • The error usually means a corrupt SyncKnowledge stored and the only way out is to null out the knowledge and restart. Nulling out the knowledge means you lost all local changes made on that database and possibly also renders your metadata on the side tables invalid. The only way to recover fully is to drop all data/side table/scope table and restart sync.


    If you want please forward us the corrupt knowledge blob so we can check to see why the deserialization failed.

    Wednesday, December 3, 2008 12:19 AM

    What are the SelectScopeInfoCommand and UpdateScopeInfoCommand that you have assigned to the provider?  Also, if you retry the sync operation do you get the same exception?



    Wednesday, December 3, 2008 12:26 AM
  • I agree that the syncknowledge is most likely corrupt.  The real question is why.  What would cause this?  Is there a size restriction?  It seems like a bug.  How exactly do you want me to send you the knowledge blob?  I can extract the byte array from the database but I'm not really sure what to do with it after that.  






    Wednesday, December 3, 2008 3:04 PM
  • Thats the anwer we will get when we debug the SyncKnowledge deserialization process. Please get the byte array and store it in base64 encoded form in a file and send it to us. You can also try it yourself by passing the byte array in to SyncKnowledge.Deserialize() call. Also as Phil requested in the other response can you confirm whether this is fatal or transitent error? I mean are you able to successfully run a new sync session for the same scope or is the scope completely toast?

    Wednesday, December 3, 2008 7:37 PM

    The failure is fatal.  If I try to synch again it fails with a SerializationException when retrieving the knowledge.  The only way to resolve the issue is to truncate all of the data, including the metadata table and start again.  I've got the syncknowledge in a file.  Where do I send  it or is there a place to upload files?  Thanks again for the help.
    Wednesday, December 3, 2008 8:28 PM
  • Send it to me at maheshwar dot jayaraman at microsoft dot com


    Wednesday, December 3, 2008 9:06 PM