Bugs in Azure Portal With PITR Restore of a CDC-Enabled Database Between SQL Managed Instances

sguidos 10 Reputation points
2025-01-17T18:55:34.7333333+00:00

When using the Azure Portal to the a Point In Time Restore (PITR) of a database on SQL Managed Instance:

  • The restored database does not have the source database’s CDC Capture's Retention period in its [msdb].[dbo].[cdc_jobs] record (it contains the default Retention period of 3 days)
  • The CDC Capture and Cleanup Jobs are always created, even if they do not exist in the source database's Managed Instance
  • The CDC Cleanup Job is always enabled, even if it is disabled in the source database's Managed Instance
  • The CDC Cleanup Job runs immediately, and not at the time next scheduled at the source database's Managed Instance

The cumulative impact of the above issues is that when you restore a CDC-enabled database, all CDC data older than the default Retention of 3 days is immediately deleted from the restored database, and there is nothing you can do to stop this :-(

In addition, the Job Names for the destination SQL Server Agent Capture and Cleanup jobs are created using the [sys].[databases].physical_database_name] and not the [dbName].  Since the Azure UI for the PITR Restore requires that the destination database name does not exist on the destination SQL Managed Instance, those new jobs should be named using the destination database name, which is what happens when you enable CDC on a new database.  Using the physical database name is confusing and requires the user to perform additional work to determine which SQL Server Agent Jobs belong to which restored database.

 

Azure SQL Database
{count} votes

1 answer

Sort by: Most helpful
  1. Oury Ba-MSFT 20,106 Reputation points Microsoft Employee
    2025-01-27T19:57:22.93+00:00

    @sguidos Thank you for reaching out.

    This is not a bug but a combination of design limitations and preventative measures from our side when restoring a CDC enabled database.

    • The CDC Capture and Cleanup Jobs are always created, even if they do not exist in the source database's Managed Instance. When restoring a CDC enabled database, we create and start capture and cleanup jobs. When a CDC database is restored, the restored database also has CDC enabled. If the capture job is not started, the transaction log will fill up over time and can result in log full and write unavailability on the database.
    • The restored database does not have the source database’s CDC Capture's Retention period in its [msdb].[dbo].[cdc_jobs] record (it contains the default Retention period of 3 days).
    • The CDC Cleanup Job is always enabled, even if it is disabled in the source database's Managed Instance.
    • **The CDC Cleanup Job runs immediately, and not at the time next scheduled at the source database's Managed Instance. **

    These three issues are due to the fact that information (job enabled/disabled, retention, schedule), persisted in msdb and not within the context of the user database. This feedback is something we haven’t encountered previously and will require further internal discussion.

    • DBName / Physical DB Name in CDC job names – feedback taken

     However, we can disable automatically running CDC jobs after a restore on customer’s instance. In that case, you must manually add and start the jobs in order to avoid the log full issue down the line. However, it will also allow you to configure CDC jobs before running them.

    Hope that helps.

    Regards,

    Oury


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.