locked
Microsoft Sync Framerwork 2.1 fails on IndexOutOfRangeException when synchronizing RRS feed

  • Question

  • Hi, 
      I have installed my scope and created my local database and synchronized with an existing sever database. Then, when I create a new entity on my local database and try to synchronize I get the following error (the SyncTracer is set on level 4):
    INFO   , AcordeSystems.SAM.WinApp.vshost, 9, 05/19/2011 14:16:12:893,    ----- Inserts for Table "Opportunity" -----
    VERBOSE, AcordeSystems.SAM.WinApp.vshost, 9, 05/19/2011 14:16:12:909,    Executing Command: [Opportunity_bulkinsert]
    VERBOSE, AcordeSystems.SAM.WinApp.vshost, 9, 05/19/2011 14:16:12:909,       Parameter: @sync_min_timestamp Value: 42358
    VERBOSE, AcordeSystems.SAM.WinApp.vshost, 9, 05/19/2011 14:16:12:909,       Parameter: @sync_scope_local_id Value: 17
    VERBOSE, AcordeSystems.SAM.WinApp.vshost, 9, 05/19/2011 14:16:12:924,       Parameter: @changeTable Value: Opportunity
    INFO   , AcordeSystems.SAM.WinApp.vshost, 9, 05/19/2011 14:16:13:018, Applied 0 of 1 rows with bulk command BulkInsertCommand
    ERROR  , AcordeSystems.SAM.WinApp.vshost, 9, 05/19/2011 14:16:13:034, Caught exception while applying changes: System.IndexOutOfRangeException: Index was outside the bounds of the array.
       at Microsoft.Synchronization.Data.SqlServer.SqlChangeHandler.PopulateAppliedRowList(DataView dataView, DataTable failedRowPks, DataViewRowState applyType)
       at Microsoft.Synchronization.Data.SqlServer.SqlChangeHandler.ApplyBulkChanges(DataTable dataTable)
       at Microsoft.Synchronization.Data.RelationalSyncProvider.ApplyChangesInternal(DbSyncScopeMetadata scopeMetadata, IDbTransaction transaction, FailedDeleteDelegate_type failedDeleteDelegate, DataSet dataSet, ChangeApplicationType applyType)
       at Microsoft.Synchronization.Data.RelationalSyncProvider.ApplyChanges(DbSyncScopeMetadata scopeMetadata, IDbTransaction applyTransaction, DataSet dataSet, DbSyncSession DbSyncSession, Boolean commitTransaction, FailedDeleteDelegate_type failedDeleteDelegate, String batchFileName, ChangeApplicationAction& action)
    ERROR  , AcordeSystems.SAM.WinApp.vshost, 9, 05/19/2011 14:16:13:034, Rolling back application transaction.
    VERBOSE, AcordeSystems.SAM.WinApp.vshost, 9, 05/19/2011 14:16:13:034, Closing Connection
    INFO   , AcordeSystems.SAM.WinApp.vshost, 9, 05/19/2011 14:16:13:049,    EndSession() called on Provider SqlSyncProvider, Microsoft.Synchronization.Data.SqlServer, Version=3.1.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91
    INFO   , AcordeSystems.SAM.WinApp.vshost, 9, 05/19/2011 14:16:13:049,    EndSession() called on Provider SqlSyncProvider, Microsoft.Synchronization.Data.SqlServer, Version=3.1.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91
    It seems something is going wrong with the syncrhonization related SPs, isn´t it?
    Please, help,
    Thanks,
    Paola



    Thursday, May 19, 2011 1:45 PM

Answers

  • deprovisioning will not remove existing data, just the Sync Fx created objects. if you cant deprovision the database, you can deprovision the scope. however, Sync fx will only remove its objects if there are no other scope referencing them.

    So if you have two scopes defined against the same table, deprovisioning one scope will not remove the Sync fx objects because you still have one other scope that needs it.

    if you cant deprovision all scopes totally, then you will  have to manually hack the Sync Fx objects to reflect the new schema. you can check out what needs to be done from the blog site i referred above.

    if you are able to deprovision, you will wipe out the Sync knowledge (the metadata of what has been synched so far) (you've actually wiped it out already when you deleted the scope manually).

    you can still provision, but you will have sync conflicts the first time you sync since the client will try to upload its changes to the server and since those records already exists in the server, you get a conflict.

    if you have timestamps/datetime to indicate when a change happen on your client, then it will be easier to isolate the changes that nees to be synched.

    for example, if you know all the items that are newly inserted on the client, you can delete all other rows and just retain the newly inserted rows. so you can upload it and download the rest of the rows from the server.

    it becomes more complicated if you need to sync the updates and deletes.

    hth,

    junet

     

    • Marked as answer by Yunwen Bai Monday, May 23, 2011 7:25 PM
    Monday, May 23, 2011 5:41 AM

All replies

  • have you changed the schema after you provisioned the scope?
    Thursday, May 19, 2011 11:30 PM
  • Hi, 

      Yes, I have removed the relashionship FK_OpportunityDeliveries_Opportunity but before removing it I´ve manually deleted the content of scope_info and scope_config tables. After the removal i´ve installed the scopes again.



    Friday, May 20, 2011 12:49 PM
  • scope_info and scope_config are not the only objects created by Sync Fx. you should use the deprovisioning API to make sure all related objects are removed.

    did you remove a column? how did you re-provision the scope?

     

    Friday, May 20, 2011 1:09 PM
  • yes, some time ago, i have changed some table structures. I understand that the scopes that were installed by then are not updated, so i assume that this is the reason of the current sync failure for all of them. Anyway, I have just created a new scope on that same database. I understand that for this new scope all SyncFX objects should be updated now, but for some reason i see the same failure as the old scopes. 
    Friday, May 20, 2011 3:35 PM
  • Sync Fx doesnt support updating scope definitions...if you dont have any other scope in your database, deprovision the database using DeprovisionStore so you clear all the Sync Fx related objects.


    to get an idea of what gets created during provisioning, have a look at this post: http://jtabadero.wordpress.com/2011/03/21/modifying-sync-framework-scope-definition-part-1-introduction/

     

    Friday, May 20, 2011 4:05 PM
  • And if I DO have other scopes in my database, what should i do? i see that deprovisioning my scope is not enough.
    Friday, May 20, 2011 4:42 PM
  • So, my question is. How can i reset or restart all the sync info from the server and local databases without loosing the data in the local database that the user is not able to sync today (due to the error mentioned above). In other words, what are the concrete steps that i should follow in order to make the sync process work again.

    Thanks in advance,

    Paola

    Friday, May 20, 2011 7:20 PM
  • deprovisioning will not remove existing data, just the Sync Fx created objects. if you cant deprovision the database, you can deprovision the scope. however, Sync fx will only remove its objects if there are no other scope referencing them.

    So if you have two scopes defined against the same table, deprovisioning one scope will not remove the Sync fx objects because you still have one other scope that needs it.

    if you cant deprovision all scopes totally, then you will  have to manually hack the Sync Fx objects to reflect the new schema. you can check out what needs to be done from the blog site i referred above.

    if you are able to deprovision, you will wipe out the Sync knowledge (the metadata of what has been synched so far) (you've actually wiped it out already when you deleted the scope manually).

    you can still provision, but you will have sync conflicts the first time you sync since the client will try to upload its changes to the server and since those records already exists in the server, you get a conflict.

    if you have timestamps/datetime to indicate when a change happen on your client, then it will be easier to isolate the changes that nees to be synched.

    for example, if you know all the items that are newly inserted on the client, you can delete all other rows and just retain the newly inserted rows. so you can upload it and download the rest of the rows from the server.

    it becomes more complicated if you need to sync the updates and deletes.

    hth,

    junet

     

    • Marked as answer by Yunwen Bai Monday, May 23, 2011 7:25 PM
    Monday, May 23, 2011 5:41 AM
  • Thanks for the prompt response! 
    Monday, May 23, 2011 8:35 PM
  • I had this happen when I had added a custom trigger to the table I was syncing, SyncTracer would show:

    VERBOSE, vstest.executionengine.x86, 10, 01/31/2014 16:22:53:598,    Executing Command: [dbo].[conflicts_bulkinsert]
    VERBOSE, vstest.executionengine.x86, 10, 01/31/2014 16:22:53:598,       Parameter: @sync_min_timestamp Value: 10002
    VERBOSE, vstest.executionengine.x86, 10, 01/31/2014 16:22:53:598,       Parameter: @sync_scope_local_id Value: 1
    VERBOSE, vstest.executionengine.x86, 10, 01/31/2014 16:22:53:599,       Parameter: @changeTable Value: dbo.conflicts
    INFO   , vstest.executionengine.x86, 10, 01/31/2014 16:22:53:617, Applied 1 of 2 rows with bulk command BulkInsertCommand
    ERROR  , vstest.executionengine.x86, 10, 01/31/2014 16:22:53:631, Caught exception while applying changes: System.IndexOutOfRangeException: Index was outside the bounds of the array.
       at Microsoft.Synchronization.Data.SqlServer.SqlChangeHandler.PopulateAppliedRowList(DataView dataView, DataTable failedRowPks, DataViewRowState applyType)

    Using Sql Server Profiler I was able to capture the Sql lines being run and they ran fine directly in Sql Server, but Sync was still failing.

    The issue seems to be I can't have a custom trigger that returns the contents of a SELECT statement specified as 

    AFTER INSERT, UPDATE, DELETE 
    

    Or 2 AFTER INSERT triggers that return SELECT statement 

    This appears to be caused by the multiple selects created by the insert screwing up sync.

    UPDATE: 

    This is caused by triggers on table that is fired by sync. The trigger is returning the contents of a select that the SqlSyncAdapter can't deal with.

    To solve remove the select from the trigger, or this can be further mitigated by assigning a specific Sql user to the sync service, and wrapping trigger contents in if statement checking that current user is not the sync user.

    • Edited by HoldFast Stark Friday, April 25, 2014 3:49 PM Furthur clarification
    Friday, January 31, 2014 4:46 PM