Operation cannot be performed on database because it is involved in a database mirroring session or an availability group (Azure)

核能气质少年 提交于 2021-01-28 00:16:44

问题


I am experiencing an intermittent issue with SQL Azure. I am copying a readonly SQL Azure database (V12) from one elastic pool into another. Once the database is copied, I set it to read/write using:

$"ALTER DATABASE [{databaseName}] SET READ_WRITE"

This sometimes fails with the error:

The operation cannot be performed on database *** because it is involved in a database mirroring session or an availability group

I have tried implementing retry logic with backoff but that doesn't work. I have failed to find any documentation relating to this error or to database mirroring in Azure.

Any advice would be greatly appreciated!


回答1:


I've managed to rectify this issue and it was indeed related to geo-replication. The database I was copying originally had a geo replica but I was dropping the secondary database (using DROP DATABASE) prior to copying the primary. The fix was to first drop the replication link between the primary and secondary before dropping the secondary database (using ALTER DATABASE [dbName] REMOVE SECONDARY ON SERVER [serverName]).



来源:https://stackoverflow.com/questions/41288542/operation-cannot-be-performed-on-database-because-it-is-involved-in-a-database-m

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!