locked
Unable to enumerate changes RRS feed

  • Question

  • I'm using Sychonization Services in a NTier application.
    On server side table adapter there is this code whose sql query is able to raise exception:

    this.InsertCommand.CommandText = @";WITH CHANGE_TRACKING_CONTEXT (@sync_client_id_binary) INSERT INTO dbo.T_CLIENT ([ID], [NAME], [DESCRIPTION], [COMMENT], [ADDRESS], [GROUP_ID]) VALUES (@ID, @NAME, @DESCRIPTION, @COMMENT, @ADDRESS, @GROUP_ID) SET @sync_row_count = @@rowcount; IF CHANGE_TRACKING_MIN_VALID_VERSION(object_id(N'dbo.T_CLIENT')) > @sync_last_received_anchor RAISERROR (N'SQL Server Change Tracking has cleaned up tracking information for table ''%s''. To recover from this error, the client must reinitialize its local database and try again',16,3,N'dbo.T_CLIENT') ";


    Server handle correctly the exception when executing:

            [System.Diagnostics.DebuggerNonUserCodeAttribute()]
            public virtual SyncContext GetChanges(SyncGroupMetadata groupMetadata, SyncSession syncSession) {
                return this._serverSyncProvider.GetChanges(groupMetadata, syncSession);
            }
    My problem is on client side. I get a "System.Reflection.TargetInvocationException" with message "Exception has been thrown by the target of an invocation."
    The inner exception is a "System.ServiceModel.FaultException" with message "Unable to enumerate changes at the DbServerSyncProvider for table 'T_TABLE' in synchronization group 'GlobalSyncGroup'."
    How can I know that the client has to reinitialize the local database. Could the "System.ServiceModel.FaultException" happen in other cases? Or do I have to rebuild the client database each time I get this exception.

    Other question close to the subject. When I rebuild the client database, is there a strategy to send the client changes to the server. Should I save these changes in a separate database, rebuild the client database and send finally the changes to server?

    Thanks for help
    Olivier
    • Moved by Hengzhe Li Friday, April 22, 2011 1:58 AM (From:SyncFx - Microsoft Sync Framework Database Providers [ReadOnly])
    Tuesday, August 4, 2009 3:51 PM

Answers


  • My question: As the exception is raised on the server side, does the client know that his database is out of sync? He gets only a "TargetInvocationException" that is quite general.


    You can return a custom fault from your service which tells the client that it is out of sync.



    About your other question, cant you just do a Upload from client instead of bidirectional before dropping the client database?
    Maheshwar Jayaraman - WCF -- http://blogs.msdn.com/dotnetremoting
    • Proposed as answer by mjayaramModerator Wednesday, August 5, 2009 5:43 PM
    • Marked as answer by omonney Thursday, August 6, 2009 6:33 AM
    Wednesday, August 5, 2009 5:43 PM
    Moderator
  • Hi Omonney,
    Try reading this notes post around this issue.

    http://social.microsoft.com/Forums/en-US/uklaunch2007ado.net/thread/0e2dd016-5d14-4cf9-aebc-93b762b42ec7

    Maheshwar Jayaraman - WCF -- http://blogs.msdn.com/dotnetremoting
    • Proposed as answer by mjayaramModerator Tuesday, August 11, 2009 7:17 PM
    • Marked as answer by omonney Monday, August 17, 2009 6:57 AM
    Tuesday, August 11, 2009 7:17 PM
    Moderator

All replies

  • Hi Omonney,
    The exception you posted is due to an error running the SelectIncremental*Command for the T_Table sync adapter. I would recommend using SqlProfiler to see why the commands are failing.

    I didnt quite understand your other question around rebuild client database. Can you elaborate?


    Maheshwar Jayaraman - WCF -- http://blogs.msdn.com/dotnetremoting
    Wednesday, August 5, 2009 2:15 AM
    Moderator
  • Hi Maheshwar Jayaraman
    Thanks for your answer.
    The exception is thrown is the sql command I posted. This sql command compare the min valid version in sql serveur to the last received anchor of the client database. If the min valid version is greater than the client, it means that the client is out of synch (client wasn't synchronized enough, compared to the retention period of the change tracking in SQL Server). When client is out of synch the sql command makes a RAISERROR. Nothing wrong with this error. It has to happen, it's a normal case.

    The sql command is executed by the ServerSyncProvider (GetChanges method) and is correctly handled. This code is located in the web service. When the web service get this error, syncronisation stops to protect the server database from incoherent data.

    My question: As the exception is raised on the server side, does the client know that his database is out of sync? He gets only a "TargetInvocationException" that is quite general.


    For my other question. I execute a bidirectionnal synchronization. When client database is too old (out of sync), the official stategy I've seen on msdn is to destroy the client database, recreate the database and finally resync again. In this case the client get a "snapshot" from the server.
    But the client database could have important new data to transmit to the server, even if his database is old...
    What do I have to do with these changes... Should I save that in other database, synchronize and send them later?

    Olivier
    Wednesday, August 5, 2009 6:45 AM

  • My question: As the exception is raised on the server side, does the client know that his database is out of sync? He gets only a "TargetInvocationException" that is quite general.


    You can return a custom fault from your service which tells the client that it is out of sync.



    About your other question, cant you just do a Upload from client instead of bidirectional before dropping the client database?
    Maheshwar Jayaraman - WCF -- http://blogs.msdn.com/dotnetremoting
    • Proposed as answer by mjayaramModerator Wednesday, August 5, 2009 5:43 PM
    • Marked as answer by omonney Thursday, August 6, 2009 6:33 AM
    Wednesday, August 5, 2009 5:43 PM
    Moderator
  • Thanks for your answer.

    Ok, I will search about how managing custom fault. It's new for me, but I'm sure it will solve my problem.

    I didn't now that it was possible to change the sync direction, after having already synchronize with other direction before. It looks great.

    Thanks a lot.
    Thursday, August 6, 2009 6:33 AM
  • Hi Omonney,
    Try reading this notes post around this issue.

    http://social.microsoft.com/Forums/en-US/uklaunch2007ado.net/thread/0e2dd016-5d14-4cf9-aebc-93b762b42ec7

    Maheshwar Jayaraman - WCF -- http://blogs.msdn.com/dotnetremoting
    • Proposed as answer by mjayaramModerator Tuesday, August 11, 2009 7:17 PM
    • Marked as answer by omonney Monday, August 17, 2009 6:57 AM
    Tuesday, August 11, 2009 7:17 PM
    Moderator