none
Delay aborting a SyncProcess

Answers

  • Problem solved

        private void SyncProgress(object sender, DbSyncProgressEventArgs e)

            {

                try

                {

                    // stop sync immediately if cancel has been issued

                    if (m_syncOrchestrator.State == SyncOrchestratorState.Canceling)

                    {

                        throw new SyncAbortedException();

                    }

                }

                catch (Exception err)

                {

                    WriteLog(Resources.Strings.LogErrorHeader);

                    WriteLog(err.ToString());

                }

            }

    The SyncAbortedException is caught by the catch block in the routine - hence the Sync is not aborted

    You want

    OuUr SyncProgress handler was as follows

        private void SyncProgress(object sender, DbSyncProgressEventArgs e)

            {

                 // stop sync immediately if cancel has been issued

                 if (m_syncOrchestrator.State == SyncOrchestratorState.Canceling)

                 {

                     throw new SyncAbortedException();

                 }

            }

    I changed it to

    The SyncAbortedException is caught by the catch block in the routine - hence the Sync is not aborted

    I changed it to

        private void SyncProgress(object sender, DbSyncProgressEventArgs e)

            {

                 // stop sync immediately if cancel has been issued

                 if (m_syncOrchestrator.State == SyncOrchestratorState.Canceling)

                 {

                     throw new SyncAbortedException();

                 }

            }

    Problem solved !


    Howard P. Weiss

    • Marked as answer by hpweiss Wednesday, July 23, 2014 8:49 PM
    Wednesday, July 23, 2014 8:45 PM

All replies

  • easiest way to abort a sync is to subscribe to SyncProgress event, check if an abort is requested and throw an exception, the exception will force Sync Fx to abort the sync.
    Wednesday, June 25, 2014 2:11 AM
    Moderator
  • June -

    Thank you for your response.  We tried this.  We are synchronizing 17 tables.  The first time we attempt to start the sync, we see 17 messages over a period of 90 seconds.  The first message appears within a second of the Abort response

    07/22/2014 2:49:46 PM: ================= SYNCHRONIZATION STARTED =================
    07/22/2014 2:49:59 PM: *** ERROR ***
    07/22/2014 2:50:00 PM: Microsoft.Synchronization.SyncAbortedException: Exception of type 'Microsoft.Synchronization.SyncAbortedException' was thrown.
       at Hologic.Apex.Sql.Synchronization.SyncProgress(Object sender, DbSyncProgressEventArgs e) in C:\Projects\InfinityInProgress\Hologic.Apex.Sql\Hologic.Apex.Sql.Synchronization.cs:line 813
    07/22/2014 2:51:00 PM: *** ERROR ***
    07/22/2014 2:51:00 PM: Microsoft.Synchronization.SyncAbortedException: Exception of type 'Microsoft.Synchronization.SyncAbortedException' was thrown.
       at Hologic.Apex.Sql.Synchronization.SyncProgress(Object sender, DbSyncProgressEventArgs e) in C:\Projects\InfinityInProgress\Hologic.Apex.Sql\Hologic.Apex.Sql.Synchronization.cs:line 813
    07/22/2014 2:51:02 PM: *** ERROR ***
    07/22/2014 2:51:02 PM: Microsoft.Synchronization.SyncAbortedException: Exception of type 'Microsoft.Synchronization.SyncAbortedException' was thrown.
       at Hologic.Apex.Sql.Synchronization.SyncProgress(Object sender, DbSyncProgressEventArgs e) in C:\Projects\InfinityInProgress\Hologic.Apex.Sql\Hologic.Apex.Sql.Synchronization.cs:line 813
    07/22/2014 2:51:05 PM: *** ERROR ***
    07/22/2014 2:51:05 PM: Microsoft.Synchronization.SyncAbortedException: Exception of type 'Microsoft.Synchronization.SyncAbortedException' was thrown.
       at Hologic.Apex.Sql.Synchronization.SyncProgress(Object sender, DbSyncProgressEventArgs e) in C:\Projects\InfinityInProgress\Hologic.Apex.Sql\Hologic.Apex.Sql.Synchronization.cs:line 813
    07/22/2014 2:51:05 PM: *** ERROR ***
    07/22/2014 2:51:05 PM: Microsoft.Synchronization.SyncAbortedException: Exception of type 'Microsoft.Synchronization.SyncAbortedException' was thrown.
       at Hologic.Apex.Sql.Synchronization.SyncProgress(Object sender, DbSyncProgressEventArgs e) in C:\Projects\InfinityInProgress\Hologic.Apex.Sql\Hologic.Apex.Sql.Synchronization.cs:line 813
    07/22/2014 2:51:06 PM: *** ERROR ***
    07/22/2014 2:51:06 PM: Microsoft.Synchronization.SyncAbortedException: Exception of type 'Microsoft.Synchronization.SyncAbortedException' was thrown.
       at Hologic.Apex.Sql.Synchronization.SyncProgress(Object sender, DbSyncProgressEventArgs e) in C:\Projects\InfinityInProgress\Hologic.Apex.Sql\Hologic.Apex.Sql.Synchronization.cs:line 813
    07/22/2014 2:51:06 PM: *** ERROR ***
    07/22/2014 2:51:06 PM: Microsoft.Synchronization.SyncAbortedException: Exception of type 'Microsoft.Synchronization.SyncAbortedException' was thrown.
       at Hologic.Apex.Sql.Synchronization.SyncProgress(Object sender, DbSyncProgressEventArgs e) in C:\Projects\InfinityInProgress\Hologic.Apex.Sql\Hologic.Apex.Sql.Synchronization.cs:line 813
    07/22/2014 2:51:06 PM: *** ERROR ***
    07/22/2014 2:51:06 PM: Microsoft.Synchronization.SyncAbortedException: Exception of type 'Microsoft.Synchronization.SyncAbortedException' was thrown.
       at Hologic.Apex.Sql.Synchronization.SyncProgress(Object sender, DbSyncProgressEventArgs e) in C:\Projects\InfinityInProgress\Hologic.Apex.Sql\Hologic.Apex.Sql.Synchronization.cs:line 813
    07/22/2014 2:51:12 PM: *** ERROR ***
    07/22/2014 2:51:12 PM: Microsoft.Synchronization.SyncAbortedException: Exception of type 'Microsoft.Synchronization.SyncAbortedException' was thrown.
       at Hologic.Apex.Sql.Synchronization.SyncProgress(Object sender, DbSyncProgressEventArgs e) in C:\Projects\InfinityInProgress\Hologic.Apex.Sql\Hologic.Apex.Sql.Synchronization.cs:line 813
    07/22/2014 2:51:15 PM: *** ERROR ***
    07/22/2014 2:51:15 PM: Microsoft.Synchronization.SyncAbortedException: Exception of type 'Microsoft.Synchronization.SyncAbortedException' was thrown.
       at Hologic.Apex.Sql.Synchronization.SyncProgress(Object sender, DbSyncProgressEventArgs e) in C:\Projects\InfinityInProgress\Hologic.Apex.Sql\Hologic.Apex.Sql.Synchronization.cs:line 813
    07/22/2014 2:51:18 PM: *** ERROR ***
    07/22/2014 2:51:18 PM: Microsoft.Synchronization.SyncAbortedException: Exception of type 'Microsoft.Synchronization.SyncAbortedException' was thrown.
       at Hologic.Apex.Sql.Synchronization.SyncProgress(Object sender, DbSyncProgressEventArgs e) in C:\Projects\InfinityInProgress\Hologic.Apex.Sql\Hologic.Apex.Sql.Synchronization.cs:line 813
    07/22/2014 2:51:18 PM: *** ERROR ***
    07/22/2014 2:51:18 PM: Microsoft.Synchronization.SyncAbortedException: Exception of type 'Microsoft.Synchronization.SyncAbortedException' was thrown.
       at Hologic.Apex.Sql.Synchronization.SyncProgress(Object sender, DbSyncProgressEventArgs e) in C:\Projects\InfinityInProgress\Hologic.Apex.Sql\Hologic.Apex.Sql.Synchronization.cs:line 813
    07/22/2014 2:51:20 PM: *** ERROR ***
    07/22/2014 2:51:20 PM: Microsoft.Synchronization.SyncAbortedException: Exception of type 'Microsoft.Synchronization.SyncAbortedException' was thrown.
       at Hologic.Apex.Sql.Synchronization.SyncProgress(Object sender, DbSyncProgressEventArgs e) in C:\Projects\InfinityInProgress\Hologic.Apex.Sql\Hologic.Apex.Sql.Synchronization.cs:line 813
    07/22/2014 2:51:21 PM: *** ERROR ***
    07/22/2014 2:51:21 PM: Microsoft.Synchronization.SyncAbortedException: Exception of type 'Microsoft.Synchronization.SyncAbortedException' was thrown.
       at Hologic.Apex.Sql.Synchronization.SyncProgress(Object sender, DbSyncProgressEventArgs e) in C:\Projects\InfinityInProgress\Hologic.Apex.Sql\Hologic.Apex.Sql.Synchronization.cs:line 813
    07/22/2014 2:51:23 PM: *** ERROR ***
    07/22/2014 2:51:23 PM: Microsoft.Synchronization.SyncAbortedException: Exception of type 'Microsoft.Synchronization.SyncAbortedException' was thrown.
       at Hologic.Apex.Sql.Synchronization.SyncProgress(Object sender, DbSyncProgressEventArgs e) in C:\Projects\InfinityInProgress\Hologic.Apex.Sql\Hologic.Apex.Sql.Synchronization.cs:line 813
    07/22/2014 2:51:24 PM: *** ERROR ***
    07/22/2014 2:51:24 PM: Microsoft.Synchronization.SyncAbortedException: Exception of type 'Microsoft.Synchronization.SyncAbortedException' was thrown.
       at Hologic.Apex.Sql.Synchronization.SyncProgress(Object sender, DbSyncProgressEventArgs e) in C:\Projects\InfinityInProgress\Hologic.Apex.Sql\Hologic.Apex.Sql.Synchronization.cs:line 813
    07/22/2014 2:51:26 PM: *** ERROR ***
    07/22/2014 2:51:26 PM: Microsoft.Synchronization.SyncAbortedException: Exception of type 'Microsoft.Synchronization.SyncAbortedException' was thrown.
       at Hologic.Apex.Sql.Synchronization.SyncProgress(Object sender, DbSyncProgressEventArgs e) in C:\Projects\InfinityInProgress\Hologic.Apex.Sql\Hologic.Apex.Sql.Synchronization.cs:line 813
    07/22/2014 2:51:26 PM: ================ SYNCHRONIZATION CANCELED ================

    Subsequent aborts are quicker and generate fewer messages

    07/22/2014 2:51:27 PM: ================= SYNCHRONIZATION STARTED =================
    07/22/2014 2:51:28 PM: *** ERROR ***
    07/22/2014 2:51:28 PM: Microsoft.Synchronization.SyncAbortedException: Exception of type 'Microsoft.Synchronization.SyncAbortedException' was thrown.
       at Hologic.Apex.Sql.Synchronization.SyncProgress(Object sender, DbSyncProgressEventArgs e) in C:\Projects\InfinityInProgress\Hologic.Apex.Sql\Hologic.Apex.Sql.Synchronization.cs:line 813
    07/22/2014 2:51:28 PM: *** ERROR ***
    07/22/2014 2:51:28 PM: Microsoft.Synchronization.SyncAbortedException: Exception of type 'Microsoft.Synchronization.SyncAbortedException' was thrown.
       at Hologic.Apex.Sql.Synchronization.SyncProgress(Object sender, DbSyncProgressEventArgs e) in C:\Projects\InfinityInProgress\Hologic.Apex.Sql\Hologic.Apex.Sql.Synchronization.cs:line 813
    07/22/2014 2:51:28 PM: *** ERROR ***
    07/22/2014 2:51:28 PM: Microsoft.Synchronization.SyncAbortedException: Exception of type 'Microsoft.Synchronization.SyncAbortedException' was thrown.
       at Hologic.Apex.Sql.Synchronization.SyncProgress(Object sender, DbSyncProgressEventArgs e) in C:\Projects\InfinityInProgress\Hologic.Apex.Sql\Hologic.Apex.Sql.Synchronization.cs:line 813
    07/22/2014 2:51:28 PM: *** ERROR ***
    07/22/2014 2:51:28 PM: Microsoft.Synchronization.SyncAbortedException: Exception of type 'Microsoft.Synchronization.SyncAbortedException' was thrown.
       at Hologic.Apex.Sql.Synchronization.SyncProgress(Object sender, DbSyncProgressEventArgs e) in C:\Projects\InfinityInProgress\Hologic.Apex.Sql\Hologic.Apex.Sql.Synchronization.cs:line 813
    07/22/2014 2:51:28 PM: *** ERROR ***
    07/22/2014 2:51:28 PM: Microsoft.Synchronization.SyncAbortedException: Exception of type 'Microsoft.Synchronization.SyncAbortedException' was thrown.
       at Hologic.Apex.Sql.Synchronization.SyncProgress(Object sender, DbSyncProgressEventArgs e) in C:\Projects\InfinityInProgress\Hologic.Apex.Sql\Hologic.Apex.Sql.Synchronization.cs:line 813
    07/22/2014 2:51:28 PM: *** ERROR ***
    07/22/2014 2:51:28 PM: Microsoft.Synchronization.SyncAbortedException: Exception of type 'Microsoft.Synchronization.SyncAbortedException' was thrown.
       at Hologic.Apex.Sql.Synchronization.SyncProgress(Object sender, DbSyncProgressEventArgs e) in C:\Projects\InfinityInProgress\Hologic.Apex.Sql\Hologic.Apex.Sql.Synchronization.cs:line 813
    07/22/2014 2:51:28 PM: *** ERROR ***
    07/22/2014 2:51:28 PM: Microsoft.Synchronization.SyncAbortedException: Exception of type 'Microsoft.Synchronization.SyncAbortedException' was thrown.
       at Hologic.Apex.Sql.Synchronization.SyncProgress(Object sender, DbSyncProgressEventArgs e) in C:\Projects\InfinityInProgress\Hologic.Apex.Sql\Hologic.Apex.Sql.Synchronization.cs:line 813
    07/22/2014 2:51:28 PM: *** ERROR ***
    07/22/2014 2:51:28 PM: Microsoft.Synchronization.SyncAbortedException: Exception of type 'Microsoft.Synchronization.SyncAbortedException' was thrown.
       at Hologic.Apex.Sql.Synchronization.SyncProgress(Object sender, DbSyncProgressEventArgs e) in C:\Projects\InfinityInProgress\Hologic.Apex.Sql\Hologic.Apex.Sql.Synchronization.cs:line 813
    07/22/2014 2:51:28 PM: *** ERROR ***
    07/22/2014 2:51:28 PM: Microsoft.Synchronization.SyncAbortedException: Exception of type 'Microsoft.Synchronization.SyncAbortedException' was thrown.
       at Hologic.Apex.Sql.Synchronization.SyncProgress(Object sender, DbSyncProgressEventArgs e) in C:\Projects\InfinityInProgress\Hologic.Apex.Sql\Hologic.Apex.Sql.Synchronization.cs:line 813
    07/22/2014 2:51:28 PM: ================ SYNCHRONIZATION CANCELED ===============

    Our goal is to stop the sync within a second.

    Any recommendations?

    Howard


    Howard P. Weiss

    Tuesday, July 22, 2014 7:37 PM
  • the abort has to rollback the changes that's pending commit.

    not sure why you have multiple aborts in your log though? how many scopes are you synching?

    Wednesday, July 23, 2014 1:27 AM
    Moderator
  • Thank you for the quick replay

    We are synching 1 scope with 17 tables

    private string[] scopeTables = { "table01",
         "table02",
         "table03",
         "table04",
         "table05",
         "table06",
         "table07",
         "table08",
         "table09",
         "table10",
         "table11",
         "table12",
         "table13",
         "table14",
         "table15",
         "table16",
         "table17",
       };

    private const string syncScope = "SyncScope";

    public bool ProvisionMasterDatabase()
    {
      bool status = false;

      try
       {
           if (MasterDatabaseExists())
           {
               using (SqlConnection dbConn = new SqlConnection(GetConnectionString(true)))
               {
          // define the scope
          DbSyncScopeDescription scopeDesc = new DbSyncScopeDescription(syncScope);

          // get the description of the tables and add it to the scope
          foreach (string table in scopeTables)
          {
              scopeDesc.Tables.Add(SqlSyncDescriptionBuilder.GetDescriptionForTable(table, dbConn));
          }

          // create provisioning object
          SqlSyncScopeProvisioning dbProvision = new SqlSyncScopeProvisioning(dbConn, scopeDesc);

          // no need to create the tables since they should already exist so use the Skip parameter
          dbProvision.SetCreateTableDefault(DbSyncCreationOption.Skip);

          // set filter
          dbProvision.Tables[tablePatient].AddFilterColumn(field1);
          dbProvision.Tables[tablePatient].FilterClause = clause1;

          // set filter
          dbProvision.Tables[tableScanAnalysis].AddFilterColumn(field2);
          dbProvision.Tables[tableScanAnalysis].FilterClause = clause2;

          foreach (string table in scanTables)
          {
              dbProvision.Tables[table].AddFilterColumn(field3);
              dbProvision.Tables[table].FilterClause = clause3;
          }

          // set timeout to wait indefinitely
          dbProvision.CommandTimeout = 0;

          // start the provisioning process
          dbProvision.Apply();

          status = true;
               }
           }
       }
       catch (Exception)
       {
           status = false;
       }

       return status;
    }


    Howard P. Weiss

    Wednesday, July 23, 2014 1:35 PM
  • I know understand why there were 17 error messages

    Here is the code we were using in

    private void SyncProgress(object sender, DbSyncProgressEventArgs e)
    {
        try
        {
            // stop sync immediately if cancel has been issued
            if (m_syncOrchestrator.State == SyncOrchestratorState.Canceling)
            {
                throw new SyncAbortedException();
            }
        }
        catch (Exception err)
        {
            WriteLog(Resources.Strings.LogErrorHeader);
            WriteLog(err.ToString());
        }
    }

    We were capturing the exception we were trying to throw.

    I tried removing the try ... catch.  When I do so, I see an error

    An exception of type 'Microsoft.Synchronization.SyncAbortedException' occurred in Hologic.Apex.Sql.dll but was not handled in user code

    I can continue from this error at which the error is caught by the try ... catch enclosing the SyncOrchestrator.Synchronize call

    How do I avoid the error message?


    Howard P. Weiss

    Wednesday, July 23, 2014 7:47 PM
  • Problem solved

        private void SyncProgress(object sender, DbSyncProgressEventArgs e)

            {

                try

                {

                    // stop sync immediately if cancel has been issued

                    if (m_syncOrchestrator.State == SyncOrchestratorState.Canceling)

                    {

                        throw new SyncAbortedException();

                    }

                }

                catch (Exception err)

                {

                    WriteLog(Resources.Strings.LogErrorHeader);

                    WriteLog(err.ToString());

                }

            }

    The SyncAbortedException is caught by the catch block in the routine - hence the Sync is not aborted

    You want

    OuUr SyncProgress handler was as follows

        private void SyncProgress(object sender, DbSyncProgressEventArgs e)

            {

                 // stop sync immediately if cancel has been issued

                 if (m_syncOrchestrator.State == SyncOrchestratorState.Canceling)

                 {

                     throw new SyncAbortedException();

                 }

            }

    I changed it to

    The SyncAbortedException is caught by the catch block in the routine - hence the Sync is not aborted

    I changed it to

        private void SyncProgress(object sender, DbSyncProgressEventArgs e)

            {

                 // stop sync immediately if cancel has been issued

                 if (m_syncOrchestrator.State == SyncOrchestratorState.Canceling)

                 {

                     throw new SyncAbortedException();

                 }

            }

    Problem solved !


    Howard P. Weiss

    • Marked as answer by hpweiss Wednesday, July 23, 2014 8:49 PM
    Wednesday, July 23, 2014 8:45 PM