locked
ApplyChangeFailed Events fired for no apparent reason RRS feed

  • Question

  • I am using sync services to synchronize CE and Express 2008 databases.

     

    The code works fine until I register the ApplyChangeFailed event.

     

    Doing so causes clearly bogus primary key conflicts on the server or client.

     

    For instance, check tthis report:

     

    Code Snippet

    Wa, 1, 09:47:23:013116T, Server failed applying changes to table TimeCard due to a ClientInsertServerInsert conflict. Error Message: SQL Server Change Tracking has cleaned up tracking information for table 'dbo.TimeCard'. To recover from this error, the client must reinitialize its local database and try again., ""
    Wa, 1, 09:47:23:053174T, Conflict occurred on 7a7183df-569d-4155-ae97-e66386ca2ca3: Primary key violation.., ""
    Wa, 1, 09:47:23:053174T, Client change 549277586799 | CPS2 | 6 | 206 | 2027505 | 11/21/2008 1:46:15 PM | 11/21/2008 1:46:15 PM |  | False., ""
    Wa, 1, 09:47:23:053174T, Server change 549277586799 | CPS2 | 6 | 206 | 2027505 | 11/21/2008 1:46:15 PM | 11/21/2008 1:46:15 PM |  | False |

     

     

     

    This alerts a bogus conflict -- a new record was created on the client with a new primary key that definitely did not and could not exist on the server.

     

    Here is the code snippet that does the upload with the offending events exluded:

     

    Code Snippet

    Using syncAgent As New TimeCardCacheSyncAgent(Me.LocalConnectionString, Me.RemoteConnectionString)

     

    Try

     

    #If False Then

    ' this causes trouble!

    AddHandler syncAgent.clientSyncProvider.ApplyChangeFailed, AddressOf reportClientSyncProviderApplyChangeFailed

    AddHandler syncAgent.ServerSyncProvider.ApplyChangeFailed, AddressOf reportServerSyncProviderApplyChangeFailed

    #End If

     

    syncAgent.TimeCardSyncTable.SyncDirection = SyncDirection.UploadOnly

     

    return  syncAgent.Synchronize

     

    Catch

     

    Throw

     

    Finally

     

    #If False Then

    Try

    RemoveHandler syncAgent.clientSyncProvider.ApplyChangeFailed, AddressOf reportClientSyncProviderApplyChangeFailed

    Finally

    End Try

    Try

    RemoveHandler syncAgent.ServerSyncProvider.ApplyChangeFailed, AddressOf reportServerSyncProviderApplyChangeFailed

    Finally

    End Try

    #End If

     

    End Try

     

    End Using

     

     

    Is there something I should look for?

     

    At this time, I am left unable to utilize conflict resultion or report inteligable sync failures.

     

    Thanks

     

    David

     

    • Moved by Hengzhe Li Friday, April 22, 2011 7:48 AM (From:SyncFx - Microsoft Sync Framework Database Providers [ReadOnly])
    Friday, November 21, 2008 10:21 PM

All replies

  • I wish to add some additional error information on this. 

    report:

     

    Code Snippet

    Er, 2, 07:59:16:969536T, Server failed applying changes to table CoreInventory due to a ClientInsertServerInsert conflict. Error Message: SQL Server Change Tracking has cleaned up tracking information for table 'dbo.CoreInventory'. To recover from this error, the client must reinitialize its local database and try again., ""
    Er, 2, 07:59:17:016413T, SQL Server Change Tracking has cleaned up tracking information for table 'dbo.CoreInventory'. To recover from this error, the client must reinitialize its local database and try again, ""
    Er, 2, 07:59:17:016413T,    at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection),
       at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection),
       at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj),
       at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj),
       at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString),
       at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async),
       at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result),
       at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe),
       at System.Data.SqlClient.SqlCommand.ExecuteNonQuery(),
       at Microsoft.Synchronization.Data.Server.DbServerSyncProvider.ApplyInsertsAndHandleConflicts(DataRow row, SyncAdapter adapter, IDbCommand cmd, IDbTransaction transaction, SyncGroupMetadata groupMetadata, SyncTableMetadata tableMetadata, SyncSession syncSession, DataColumnCollection columns, Exception& error), ""

     

    Wa, 1, 07:59:17:032038T, Server failed applying changes to table CoreInventory due to a ClientInsertServerInsert conflict. Error Message: SQL Server Change Tracking has cleaned up tracking information for table 'dbo.CoreInventory'. To recover from this error, the client must reinitialize its local database and try again., ""
    Wa, 1, 07:59:17:047664T, Conflict occurred on b4541ed7-5501-4c07-aa7e-8547fe70445a: Primary key violation.., ""
    Wa, 1, 07:59:17:047664T, Client change GM1234563 | 12345674 | CPS2 | 244 | 11/24/2008 11:57:43 AM |  | False | False | False | False | False |  |  | False., ""
    Wa, 1, 07:59:17:047664T, Server change GM1234563 | 12345674 | CPS2 | 244 | 11/24/2008 11:57:43 AM |  | False | False | False | False | False |  |  | False | System.Byte[] | ., ""
    Er, 2, 07:59:17:297672T, Unable to enumerate changes at the DbServerSyncProvider for table 'CoreInventory' in synchronization group 'CoreInventorySyncTableSyncGroup'., ""
    Er, 2, 07:59:17:297672T,    at Microsoft.Synchronization.Data.Server.DbServerSyncProvider.EnumerateChanges(SyncGroupMetadata groupMetadata, SyncSession syncSession, IDbTransaction transaction, EnumerateChangeType changeType, SyncSchema traceSchema),
       at Microsoft.Synchronization.Data.Server.DbServerSyncProvider.GetChanges(SyncGroupMetadata groupMetadata, SyncSession syncSession),
       at Microsoft.Synchronization.SyncAgent.DownloadChanges(SyncGroupMetadata groupMetadata),
       at Microsoft.Synchronization.SyncAgent.Synchronize(),
       at isr.Provers.Remote.SyncManager.syncCoreInventory(),
       at isr.Provers.Remote.SyncManager.UploadTable(UploadableTable value), ""
    Er, 2, 07:59:17:313297T, Unable to enumerate changes at the DbServerSyncProvider for table 'CoreInventory' in synchronization group 'CoreInventorySyncTableSyncGroup'. Inner Exception, ""
    Er, 2, 07:59:17:313297T,    at Microsoft.Synchronization.Data.Server.DbServerSyncProvider.EnumerateChanges(SyncGroupMetadata groupMetadata, SyncSession syncSession, IDbTransaction transaction, EnumerateChangeType changeType, SyncSchema traceSchema),
       at Microsoft.Synchronization.Data.Server.DbServerSyncProvider.GetChanges(SyncGroupMetadata groupMetadata, SyncSession syncSession),
       at Microsoft.Synchronization.SyncAgent.DownloadChanges(SyncGroupMetadata groupMetadata),
       at Microsoft.Synchronization.SyncAgent.Synchronize(),
       at isr.Provers.Remote.SyncManager.syncCoreInventory(),
       at isr.Provers.Remote.SyncManager.UploadTable(UploadableTable value), ""

     

     

    Here is another set on coming from the time card table:

     

    Code Snippet
    Er, 2, 07:59:28:813665T, Server failed applying changes to table TimeCard due to a ClientInsertServerInsert conflict. Error Message: SQL Server Change Tracking has cleaned up tracking information for table 'dbo.TimeCard'. To recover from this error, the client must reinitialize its local database and try again., ""
    Er, 2, 07:59:28:813665T, SQL Server Change Tracking has cleaned up tracking information for table 'dbo.TimeCard'. To recover from this error, the client must reinitialize its local database and try again, ""
    Er, 2, 07:59:28:813665T,    at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection),
       at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection),
       at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj),
       at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj),
       at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString),
       at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async),
       at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result),
       at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe),
       at System.Data.SqlClient.SqlCommand.ExecuteNonQuery(),
       at Microsoft.Synchronization.Data.Server.DbServerSyncProvider.ApplyInsertsAndHandleConflicts(DataRow row, SyncAdapter adapter, IDbCommand cmd, IDbTransaction transaction, SyncGroupMetadata groupMetadata, SyncTableMetadata tableMetadata, SyncSession syncSession, DataColumnCollection columns, Exception& error), ""
    Wa, 1, 07:59:28:829291T, Server failed applying changes to table TimeCard due to a ClientInsertServerInsert conflict. Error Message: SQL Server Change Tracking has cleaned up tracking information for table 'dbo.TimeCard'. To recover from this error, the client must reinitialize its local database and try again., ""
    Wa, 1, 07:59:28:829291T, Conflict occurred on b4541ed7-5501-4c07-aa7e-8547fe70445a: Primary key violation.., ""
    Wa, 1, 07:59:28:829291T, Client change 574546298217 | CPS2 | 6 | 244 | 2027565 | 11/24/2008 11:57:42 AM | 11/24/2008 11:57:42 AM |  | False., ""
    Wa, 1, 07:59:28:829291T, Server change 574546298217 | CPS2 | 6 | 244 | 2027565 | 11/24/2008 11:57:42 AM | 11/24/2008 11:57:42 AM |  | False | System.Byte[] | ., ""
    Ve, 8, 07:59:28:938669T, Finished syncrhonizing TimeCard. Statistics: Sync at 11/24/2008 11:59:28.610 completed in 313 ms. Uploaded 1 records; 0 applied and 1 failed., ""

     

     

     David

     

    Monday, November 24, 2008 8:50 PM