Skip to content

Commit bcfeec6

Browse files
MashaMSFTAnnaMHuff
andauthored
Add migration tips for MI link - replication lag, error 1412, and failover improvements (#36985)
* Migration tips * Apply suggestions from PR review Grammar fix. --------- Co-authored-by: Anna Huff <v-annahuff@microsoft.com>
1 parent 68a68d2 commit bcfeec6

13 files changed

Lines changed: 337 additions & 23 deletions

azure-sql/managed-instance/doc-changes-updates-known-issues.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ This article lists the currently known issues with [Azure SQL Managed Instance](
2727
| [Unable to use accelerated database recovery after migrating to SQL Managed Instance](#unable-to-use-accelerated-database-recovery-after-migrating-to-sql-managed-instance) | March 2026 | Has workaround | |
2828
| [Misleading error message when connecting to a read replica using invalid credentials](#misleading-error-message-when-connecting-to-a-read-replica-using-invalid-credentials) | February 2026 |No resolution| |
2929
| [Modifying backup retention period for the free offer](#modifying-backup-retention-period-for-the-free-offer) | June 2025 | Has workaround | |
30+
| [Error 1412 when creating a Managed Instance link](#error-1412-when-creating-a-managed-instance-link) | May 2025 | Has workaround | |
3031
| [Login to read-secondary failed due to long wait on "HADR_DATABASE_WAIT_FOR_TRANSITION_TO_VERSIONING"](#login-to-read-secondary-failed-due-to-long-wait-on-hadr_database_wait_for_transition_to_versioning) | April 2025 | Has workaround | |
3132
| [Interim guidance on 2024 time zone updates for Paraguay](#interim-guidance-on-2024-time-zone-updates-for-paraguay) | March 2025 | Resolved | February 2026 |
3233
| [Error 8992 when running DBCC CHECKDB on a SQL Server database that originated from SQL Managed Instance](#error-8992-when-running-dbcc-checkdb-on-a-sql-server-database-that-originated-from-sql-managed-instance) | March 2025 | Has workaround | |
@@ -65,7 +66,6 @@ This article lists the currently known issues with [Azure SQL Managed Instance](
6566

6667
[!INCLUDE [known-issues-after-migration](../includes/sql-managed-instance/known-issues-after-migration.md)]
6768

68-
6969
### Modifying backup retention period for the free offer
7070

7171
You can only modify the backup retention policy of your databases in the free SQL managed instance by using [REST API](/rest/api/sql/managed-backup-short-term-retention-policies), [PowerShell](/powershell/module/az.sql/set-azsqlinstancedatabasebackupshorttermretentionpolicy), and [Azure CLI](/cli/azure/sql/midb/short-term-retention-policy) commands. You can't modify the backup retention policy through the [Azure portal](https://portal.azure.com).
@@ -93,6 +93,14 @@ To work around the issue, first drop the index, or the table with the index, fro
9393
> [!CAUTION]
9494
> If you create a partitioned index on a table after dropping an index as described in this scenario, the table becomes inaccessible.
9595
96+
### Error 1412 when creating a Managed Instance link
97+
98+
When you first create a [link](managed-instance-link-feature-overview.md), the first part of the process seeds a full backup of the database from the primary replica to the secondary replica. After seeding of the full backup completes, the link starts to replicate data by applying the differential data from the primary replica to the secondary replica. This process continues indefinitely until a failover command is issued, or the link is removed.
99+
100+
If a transaction log backup occurs on the primary replica during initial seeding of the full backup, the transaction log truncates. Creating the link fails with error 1412 since the data in the transaction log necessary for initial seeding is no longer available.
101+
102+
If you see error 1412 in the SQL Server error log on Azure SQL Managed Instance, then you must [drop](managed-instance-link-configure-how-to-ssms.md#drop-a-link) and recreate the link. To preemptively avoid this issue, pause transaction log backups during the initial seeding phase. If transaction log backups are necessary during the initial seeding phase, then begin an open transaction to prevent log truncation. For more information, review [Error 1412 when creating a Managed Instance link](managed-instance-link-troubleshoot-how-to.md#error-1412) in the troubleshooting guide for the link feature.
103+
96104
### List of long-term backups in Azure portal shows backup files for active and deleted databases with the same name
97105

98106
Long-term backups can be listed and managed on Azure portal page for an Azure SQL Managed Instance on the *Backups* tab. The page lists active or deleted databases, basic information about their long-term backups, and link for managing backups. When you select the *Manage* link, a new side pane opens with list of backups. Due to an issue with the filtering logic, the list shows backups for both active database and deleted databases with the same name. This requires a special attention when selecting backups for deletion, to avoid deleting backups for a wrong database.
@@ -271,7 +279,7 @@ Error logs that are available in SQL Managed Instance aren't persisted, and thei
271279

272280
**(Resolved in February 2026)**
273281

274-
On October 14, 2024, the Paraguayan government announced a permanent change to the time zone policy. Paraguay now remains on Daylight Saving Time (DST) year-round, effectively adopting UTC-3 as its standard time. As a result, clocks did not advance by 60 minutes at 12:00 a.m. on March 23, 2025, as previously scheduled. This change affects the Paraguay Standard time zone. Microsoft has released related [Windows updates in February and March 2025](https://techcommunity.microsoft.com/blog/dstblog/paraguay-2025-time-zone-update-now-available/4386720). SQL managed instances using the affected time zone reflect this change, and align to to the new UTC-3 offset.
282+
On October 14, 2024, the Paraguayan government announced a permanent change to the time zone policy. Paraguay now remains on Daylight Saving Time (DST) year-round, effectively adopting UTC-3 as its standard time. As a result, clocks did not advance by 60 minutes at 12:00 a.m. on March 23, 2025, as previously scheduled. This change affects the Paraguay Standard time zone. Microsoft has released related [Windows updates in February and March 2025](https://techcommunity.microsoft.com/blog/dstblog/paraguay-2025-time-zone-update-now-available/4386720). SQL managed instances using the affected time zone reflect this change, and align to the new UTC-3 offset.
275283

276284
### Changing the connection type doesn't affect connections through the failover group endpoint
277285

azure-sql/managed-instance/managed-instance-link-best-practices.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,37 @@ You can monitor the performance of replication by checking the redo queue size o
6565

6666
If the redo queue size is consistently high, consider increasing resources on the secondary replica.
6767

68+
## Monitor replication lag
69+
70+
Monitoring replication lag helps you determine the speed of which the secondary replica synchronizes with the primary replica. A large discrepancy indicates that the secondary replica is having trouble keeping up with the primary replica, which is typically caused by slow network throughput in the link between the two instances, mismatched resource allocation between the two replicas, or by an excessively high workload on the primary replica.
71+
72+
Monitoring replication lag is especially important when performing a planned failover, which requires the secondary replica to be fully synchronized with the primary replica before the failover can be executed. If replication lag is high, the failover might take longer to complete, and in some cases, it might even fail.
73+
74+
Use the following T-SQL query on both SQL Server and SQL Managed Instance to monitor replication lag between the replicas:
75+
76+
```sql
77+
-- Execute on SQL Server and SQL Managed Instance
78+
USE master
79+
DECLARE @link_name varchar(max) = '<DAGname>'
80+
SELECT
81+
ag.name [Link name],
82+
ars1.role_desc [Link role],
83+
ars2.connected_state_desc [Link connected state],
84+
ars2.synchronization_health_desc [Link sync health],
85+
drs.secondary_lag_seconds [Link replication latency (seconds)]
86+
FROM
87+
sys.availability_groups ag
88+
JOIN sys.dm_hadr_availability_replica_states ars1
89+
ON ag.group_id = ars1.group_id
90+
JOIN sys.dm_hadr_availability_replica_states ars2
91+
ON ag.group_id = ars2.group_id
92+
JOIN sys.dm_hadr_database_replica_states drs
93+
ON ars2.replica_id = drs.replica_id
94+
WHERE
95+
ag.is_distributed = 1 AND ag.name = @link_name AND ars1.is_local = 1 AND ars2.is_local = 0
96+
GO
97+
```
98+
6899
## Rotate certificate
69100

70101
You might need to manually rotate the certificate used to secure the database mirroring endpoint on SQL Server. Since the service manages and automatically rotates the certificate used to secure the database mirroring endpoint on SQL Managed Instance, you don't need to manually rotate it.

azure-sql/managed-instance/managed-instance-link-configure-how-to-scripts.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,9 @@ As you run scripts from this user guide, it's important not to mistake SQL Serve
9494

9595
## Set up database recovery and backup
9696

97-
If SQL Server is your initial primary, then databases that will be replicated via the link must be in the full recovery model and have at least one backup. Since Azure SQL Managed Instance takes backups automatically, skip this step if SQL Managed Instance is your initial primary.
97+
If SQL Server is your initial primary, then databases that will be replicated via the link must be in the full recovery model and have at least one backup. Since Azure SQL Managed Instance takes backups automatically, skip this step if SQL Managed Instance is your initial primary.
98+
99+
When you create a link, the initial seeding between the primary and secondary replicas happens by taking a full backup of the database on the primary replica, transferring it to the secondary replica, and restoring it there. When you take the full backup, we recommend that you use the `WITH CHECKSUM` option to ensure that the backup is valid and doesn't have any corruption. For more information, see [BACKUP (Transact-SQL)](/sql/t-sql/statements/backup-transact-sql).
98100

99101
Run the following code on SQL Server for all databases you wish to replicate. Replace `<DatabaseName>` with your actual database name.
100102

azure-sql/managed-instance/managed-instance-link-configure-how-to-ssms.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,15 @@ For Azure SQL Managed Instance, you need to be a member of the [SQL Managed Inst
7373

7474
If SQL Server is your initial primary, you need to create a backup of your database. Since Azure SQL Managed Instance takes backups automatically, skip this step if SQL Managed Instance is your initial primary.
7575

76+
When you create a link, the initial seeding between the primary and secondary replicas happens by taking a full backup of the database on the primary replica, transferring it to the secondary replica, and restoring it there. When you take the full backup, we recommend that you use the `WITH CHECKSUM` option to ensure that the backup is valid and doesn't have any corruption. For more information, see [BACKUP (Transact-SQL)](/sql/t-sql/statements/backup-transact-sql).
77+
7678
Use SSMS to back up your database on SQL Server. Follow these steps:
7779

7880
1. Connect to your SQL Server in SQL Server Management Studio (SSMS).
7981
1. In **Object Explorer**, right-click the database, hover over **Tasks**, and then choose **Back up**.
8082
1. Choose **Full** for backup type.
8183
1. Ensure the **Back up to** option has the backup path to a disk with sufficient free storage space available.
84+
1. (Optional but recommended) On the **Media Options** tab, check the box for **Perform checksum before writing to media** to have SQL Server verify the integrity of the backup after it's created.
8285
1. Select **OK** to complete the full backup.
8386

8487
For more information, see [Create a Full Database Backup](/sql/relational-databases/backup-restore/create-a-full-database-backup-sql-server).

azure-sql/managed-instance/managed-instance-link-failover-how-to.md

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,37 @@ To fail over your databases to your secondary replica through the link, you need
3131

3232
If you're ready to fail over your database to the secondary replica, first stop any application workloads on the primary replica during your maintenance hours. This enables database replication to catch up on the secondary so you can fail over to the secondary without data loss. Ensure your applications aren't committing transactions to the primary before failing over.
3333

34+
## Check replication lag
35+
36+
It's important that the secondary replica catches up to the primary replica before performing a planned failover. Planned failover can time out and fail if the secondary replica lags far behind the primary replica.
37+
38+
Use the following T-SQL query on both SQL Server and SQL Managed Instance to monitor replication lag between the replicas:
39+
40+
```sql
41+
-- Execute on SQL Server and SQL Managed Instance
42+
USE master
43+
DECLARE @link_name varchar(max) = '<DAGname>'
44+
SELECT
45+
ag.name [Link name],
46+
ars1.role_desc [Link role],
47+
ars2.connected_state_desc [Link connected state],
48+
ars2.synchronization_health_desc [Link sync health],
49+
drs.secondary_lag_seconds [Link replication latency (seconds)]
50+
FROM
51+
sys.availability_groups ag
52+
JOIN sys.dm_hadr_availability_replica_states ars1
53+
ON ag.group_id = ars1.group_id
54+
JOIN sys.dm_hadr_availability_replica_states ars2
55+
ON ag.group_id = ars2.group_id
56+
JOIN sys.dm_hadr_database_replica_states drs
57+
ON ars2.replica_id = drs.replica_id
58+
WHERE
59+
ag.is_distributed = 1 AND ag.name = @link_name AND ars1.is_local = 1 AND ars2.is_local = 0
60+
GO
61+
```
62+
63+
If the replication lag is high, wait for the secondary replica to catch up with the primary replica. You might need to perform additional troubleshooting steps if the lag persists, such as improving link network throughput between the two instances, or increasing resource capacity on the secondary replica.
64+
3465
## Fail over a database
3566

3667
You can fail over a linked database by using Transact-SQL (T-SQL), SQL Server Management Studio, or PowerShell.
@@ -93,7 +124,7 @@ If you chose to maintain the link for SQL Server 2022, the secondary becomes the
93124
If you're on SQL Server 2019 and earlier versions, or if you chose to drop the link for SQL Server 2022, the link is dropped and no longer exists after failover completes. The source database and target database on each replica can both execute a read/write workload. They're completely independent.
94125

95126
> [!IMPORTANT]
96-
> After successful fail over to SQL Managed Instance, manually repoint your application(s) connection string to the SQL managed instance FQDN to complete the migration or fail over process and continue running in Azure.
127+
> After successful failover to SQL Managed Instance, manually repoint your application(s) connection string to the SQL managed instance FQDN to complete the migration or fail over process and continue running in Azure.
97128
98129
### [PowerShell](#tab/powershell)
99130

@@ -245,7 +276,7 @@ Remove-AzSqlInstanceLink -ResourceGroupName $ResourceGroup |
245276
When failover succeeds, the link is dropped and no longer exists. The SQL Server database and SQL Managed Instance database can both execute read/write workloads as they're now completely independent.
246277

247278
> [!IMPORTANT]
248-
> After successful fail over to SQL Managed Instance, manually repoint your application(s) connection string to the SQL managed instance FQDN to complete the migration or fail over process and continue running in Azure.
279+
> After successful failover to SQL Managed Instance, manually repoint your application(s) connection string to the SQL managed instance FQDN to complete the migration or fail over process and continue running in Azure.
249280
250281
After the link is dropped, you can keep the availability group on SQL Server, but you must drop the _distributed_ availability group to remove link metadata from SQL Server. This additional step is only necessary when failing over by using PowerShell since SSMS performs this action for you.
251282

@@ -266,6 +297,10 @@ GO
266297
> [!IMPORTANT]
267298
> After executing a planned failover, the replication mode is set to asynchronous.
268299
300+
## Fail over multiple databases
301+
302+
If you plan to fail over multiple databases from instances on the same server, for optimal performance and predictability, fail over 8 databases per instance at a time. For example, if you have 10 instances with 32 linked databases each, fail over 8 databases at a time from each instance, and repeat the process until all databases are failed over.
303+
269304
## View database after failover
270305

271306
For SQL Server 2022, if you chose to maintain the link, you can check that the distributed availability group exists under **Availability Groups** in **Object Explorer** in SQL Server Management Studio.

azure-sql/managed-instance/managed-instance-link-migrate.md

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,52 @@ After you've assessed your existing environment, and determined the appropriate
7373

7474
After your target SQL managed instance is created, configure a link between the database on your SQL Server instance and Azure SQL Managed Instance. First, [prepare your environment](managed-instance-link-preparation.md) and then configure a link by using [SQL Server Management Studio (SSMS)](managed-instance-link-configure-how-to-ssms.md) or [scripts](managed-instance-link-configure-how-to-scripts.md).
7575

76+
## Check replication lag
77+
78+
It's important that the secondary replica catches up to the primary replica before performing a planned migration failover. Planned failover can time out and fail if the secondary replica lags far behind the primary replica.
79+
80+
Use the following T-SQL query on both SQL Server and SQL Managed Instance to monitor replication lag between the replicas:
81+
82+
```sql
83+
-- Execute on SQL Server and SQL Managed Instance
84+
USE master
85+
DECLARE @link_name varchar(max) = '<DAGname>'
86+
SELECT
87+
ag.name [Link name],
88+
ars1.role_desc [Link role],
89+
ars2.connected_state_desc [Link connected state],
90+
ars2.synchronization_health_desc [Link sync health],
91+
drs.secondary_lag_seconds [Link replication latency (seconds)]
92+
FROM
93+
sys.availability_groups ag
94+
JOIN sys.dm_hadr_availability_replica_states ars1
95+
ON ag.group_id = ars1.group_id
96+
JOIN sys.dm_hadr_availability_replica_states ars2
97+
ON ag.group_id = ars2.group_id
98+
JOIN sys.dm_hadr_database_replica_states drs
99+
ON ars2.replica_id = drs.replica_id
100+
WHERE
101+
ag.is_distributed = 1 AND ag.name = @link_name AND ars1.is_local = 1 AND ars2.is_local = 0
102+
GO
103+
```
104+
105+
If replication lag is high, wait for the secondary replica to catch up with the primary replica. You might need to perform additional troubleshooting steps if the lag persists, such as pausing workloads on the primary replica, improving link network throughput between the two instances, or increasing resource capacity on the secondary replica. The easiest way to stop workloads on a SQL Server primary replica is to cut application connections to the instance.
106+
107+
## Migrate multiple databases
108+
109+
If you plan to migrate multiple databases from instances on the same server, for optimal performance and predictability, migrate 8 databases per instance at a time. For example, if you have 10 instances with 32 linked databases each, migrate 8 databases at a time from each instance by using planned failovers, and repeat the process until all databases are migrated.
110+
76111
## Data sync and cutover
77112

78113
After your link is established, and you're ready to migrate, follow these steps (typically during a maintenance window):
79114

80-
1. Stop the workload on the primary SQL Server database so the secondary database on SQL Managed Instance catches up.
81-
1. Validate all data has made it over to the secondary database on SQL Managed Instance.
115+
1. Stop the workload on the primary SQL Server database so the secondary database on SQL Managed Instance catches up. The easiest way to stop workloads on a SQL Server primary replica is to cut application connections to the instance.
116+
1. Validate all data has made it over to the secondary database on SQL Managed Instance. Check [replication lag](#check-replication-lag) to ensure the secondary replica is caught up with the primary replica.
82117
1. [Fail over the link](managed-instance-link-failover-how-to.md) to the secondary SQL managed instance by choosing **Planned failover**.
83-
1. (For SQL Server 2022 migrations) Check the box to **Remove link after successful failover** to ensure that failover is one way, and the link is removed.
118+
1. (Optionally) Check the box to **Remove link after successful failover** to ensure that failover is one way, and the link is removed.
119+
1. (Optionally) If you're on a supported SQL Server version with a matching SQL Managed Instance [update policy](update-policy.md), you can keep the link after failover to reverse a migration if needed. Check the [reverse a migration section](#reverse-a-migration) for specific version details.
84120
1. Cut over the application to connect to the SQL managed instance endpoint.
121+
1. (Optionally) If you didn't choose to remove the link during failover, you can remove the link after cutover once you no longer need it.
85122

86123
## Validate migration
87124

0 commit comments

Comments
 (0)