locked
Sync FX 2.1 : Only one scope can be provisioned at a time RRS feed

  • Question

  • I'm trying to provision a database with multiple scopes onto the same tables with different filters, but i am getting an error :(

    INFO   , SyncApp, 1, 04/12/2012 10:47:11:721, Version of connection detected to be Sql2008
    INFO   , SyncApp, 1, 04/12/2012 10:47:11:735, ----- Populating Scope Provisioning from Scope Description for 'test2' -----
    INFO   , SyncApp, 1, 04/12/2012 10:47:11:736, Adding Table Provisioning for '[Table_1]'
    INFO   , SyncApp, 1, 04/12/2012 10:47:11:777, --- END Populating Scope Provisioning from Scope Description for 'test2' ---
    INFO   , SyncApp, 5, 04/12/2012 10:47:11:801, ----- Provisioning Scope 'test2' on Database 'synctest2' -----
    ERROR  , SyncApp, 5, 04/12/2012 10:47:11:829, Caught exception: Microsoft.Synchronization.Data.DbProvisioningException: The runtime encountered an error when attempting to provision scope 'test2'.  This error can be thrown if another scope is also being provisioned at the same time or someone is attempting to synchronize a scope that is currently being provisioned.  For SQL Azure, please de-provision this scope and attempt to provision again.  For SQL Server or SQL Compact, all provisioning changes will be rolled back and it is only necessary to restart provisioning.  Only one scope can be provisioned at a time.
       at Microsoft.Synchronization.Data.SqlServer.SqlSyncScopeConfigurationTableHelper.ThrowExceptionIfProvisioning(SqlConnection connection, String scopeName)
       at Microsoft.Synchronization.Data.SqlServer.SqlSyncScopeProvisioning.ApplyInternal(SqlConnection connection)
       at Microsoft.Synchronization.Data.SqlServer.SqlSyncScopeProvisioning.Apply()

    According to this blogpost http://jtabadero.wordpress.com/2010/09/02/sync-framework-provisioning/ It should be possible to provision the same database more then once 

    Also, according to the post each Filter added should create a new scope-specific StoredProcedure... This does NOT happen, never has... 

    anyone who has a solution ?

    Thursday, April 12, 2012 11:29 AM

Answers

  • can you post some code snippet of your provisioning?

    Basically i've made a script just like yours on http://jtabadero.wordpress.com/2010/09/02/sync-framework-provisioning/ just a little more complex... 

    But i've found the solution to my problems:

                //serverConfig.SetCreateTrackingTableDefault(DbSyncCreationOption.CreateOrUseExisting);
                //serverConfig.SetCreateProceduresDefault(DbSyncCreationOption.CreateOrUseExisting);
                //serverConfig.SetCreateTriggersDefault(DbSyncCreationOption.CreateOrUseExisting);
    			serverConfig.SetCreateProceduresForAdditionalScopeDefault(DbSyncCreationOption.Create);
                //serverConfig.SetCreateTableDefault(DbSyncCreationOption.Skip);
    
                //if (setPopulate)
                //    serverConfig.SetPopulateTrackingTableDefault(DbSyncCreationOption.Create);
                //else
                //    serverConfig.SetPopulateTrackingTableDefault(DbSyncCreationOption.CreateOrUseExisting);

    Apparently one of all these 'Set' methods desturbs the provisioning which then fails to create the filtered StoredProcedure...  the only one left active is the one responsible for Filters 

    all problems solved now... 

    • Marked as answer by Montago Wednesday, May 9, 2012 2:27 PM
    Wednesday, May 9, 2012 2:27 PM

All replies

  • see: Provisioning additional scope using Sync Framework’s sync scope provisioning

    you can add tables to multiple scopes, however, the structure of the subsequent scope must be the same as the first scope.

    e.g., if first scope has column1+column2 for tableX, you cant have another scope that has column1 only or, column1+column2+column3.

    Thursday, April 12, 2012 11:48 AM
  • Hi June, thanks for the reply.

    According to the article i must "Skip" these 3 CreateDefaults:

    • SetCreateTrackingTableDefault
    • SetCreateTriggersDefault
    • SetCreateProceduresDefault

    But i noticed that the DbSyncCreationOption also contains the CreateOrUseExisting value... Would that work ?

    Also, There are many more "CreateDefaults" then those 3...

    .. I'm now following the guide you linked to, trying out what works...  

    Edit:
    I've tried using the CreateOrUseExisting but im still getting the error: 

    This error can be thrown if another scope is also being provisioned at the same time or someone is attempting to synchronize a scope that is currently being provisioned.  For SQL Azure, please de-provision this scope and attempt to provision
     again.  For SQL Server or SQL Compact, all provisioning changes will be rolled back and it is only necessary to restart provisioning.  Only one scope can be provisioned at a time.




    • Edited by Montago Friday, April 13, 2012 8:30 AM
    Friday, April 13, 2012 8:08 AM
  • are you running concurrent provisioning processes?

    can you do a query on your scope_info table and check if there is any row where scope_status  is not equal to "C"

    Friday, April 13, 2012 8:20 AM
  • are you running concurrent provisioning processes?

    can you do a query on your scope_info table and check if there is any row where scope_status  is not equal to "C"

    The scope_status in the table scope_config is currently "P"

    btw... regardless of the SetCreateProceduresForAdditionalScopeDefault setting, the Script from the SqlSyncScopeProvisioning object is never desclaring a Stored Procedure that contains a GUID in its name - Should it ?


    • Edited by Montago Friday, April 13, 2012 9:20 AM
    Friday, April 13, 2012 8:59 AM
  • a scope entry where status = P means its provisioning... did you have an interrupted provisioning before, thats why you're getting an error.

    if that's the only entry in the scope_info, try deprovisioning the database first to cleanup all sync objects previously created.

    i can't recall if the Script function also generates a name with a GUID, ill test when i get access to SQL later...

    anyway,  try setting all the SetCreatexxxx just before you call Apply.

    Friday, April 13, 2012 9:47 AM
  • a scope entry where status = P means its provisioning... did you have an interrupted provisioning before, thats why you're getting an error.

    The first provisioning went all OK - so i dont understand why its showing up as interrupted :-(

    if that's the only entry in the scope_info, try deprovisioning the database first to cleanup all sync objects previously created.

    The database was completely fresh from the start...

    anyway,  try setting all the SetCreatexxxx just before you call Apply.

    Okay - ill see if that makes a difference ;-)

    edit: 
    i tried moving all the SetCreate methods to just before Apply - no success either :(

    • Edited by Montago Friday, April 13, 2012 11:40 AM
    Friday, April 13, 2012 11:31 AM
  • a scope entry where status = P means its provisioning... 

    Does it matter that i haven't Synced the database yet ?... 

    could the P status mean that i need to Sync before setting up yet another Scope ?

    Friday, April 13, 2012 11:51 AM
  • the provisioning sets the value to P in scope_config while its provisioning the scope (creating triggers, SPs, UDTs and populating the tracking tables). it will automatically set it to C once provisioning is completed.

    it the database is empty, then your second provisioning may be running before the first one finishes?

    Friday, April 13, 2012 12:10 PM
  • I've found out that sync_status is P after i've provisioned the database !?

    somehow it's never altering the status from P to C ??

    Friday, April 13, 2012 12:18 PM
  • can you post some code snippet of your provisioning?
    Saturday, April 14, 2012 2:16 AM
  • can you post some code snippet of your provisioning?

    Basically i've made a script just like yours on http://jtabadero.wordpress.com/2010/09/02/sync-framework-provisioning/ just a little more complex... 

    But i've found the solution to my problems:

                //serverConfig.SetCreateTrackingTableDefault(DbSyncCreationOption.CreateOrUseExisting);
                //serverConfig.SetCreateProceduresDefault(DbSyncCreationOption.CreateOrUseExisting);
                //serverConfig.SetCreateTriggersDefault(DbSyncCreationOption.CreateOrUseExisting);
    			serverConfig.SetCreateProceduresForAdditionalScopeDefault(DbSyncCreationOption.Create);
                //serverConfig.SetCreateTableDefault(DbSyncCreationOption.Skip);
    
                //if (setPopulate)
                //    serverConfig.SetPopulateTrackingTableDefault(DbSyncCreationOption.Create);
                //else
                //    serverConfig.SetPopulateTrackingTableDefault(DbSyncCreationOption.CreateOrUseExisting);

    Apparently one of all these 'Set' methods desturbs the provisioning which then fails to create the filtered StoredProcedure...  the only one left active is the one responsible for Filters 

    all problems solved now... 

    • Marked as answer by Montago Wednesday, May 9, 2012 2:27 PM
    Wednesday, May 9, 2012 2:27 PM
  • its most likely, SetCreateProceduresDefault and SetCreateProceduresForAdditionalScopeDefault... the first one says reuse the SP if its existing, while you're second one says create a new one.
    Thursday, May 10, 2012 1:14 AM