Skip to content

Contained Availability Groups error

During my testing about the new SQL Server 2022 feature Contained Availability group I faced an issue during the creation of the system databases on the secondary instance.

I used the wizard to create a new Contained Availability Group and chose the Full database and lo backup synchronization method to restore database on my secondary instance.
I generated the script and ran it.

I was a bit confused to receive an error message.
It looks like that the master database has to be joined and recovered before the user databases in a Contained Availability group:

Msg 47148, Level 16, State 13, Line 180
Cannot join database ‘AdventureWorks’ to contained availability group ‘AAG_Thor9091_C01’. Before joining other databases to contained availability group, contained availability group master database has to be joined and recovered. Make sure contained availability group master database has been joined and recovered, then retry the operation.

If I check on my primary, my Contained Availability Group looks good with my master & msdb system databases and my AdventureWorks database are marked as Synchronized:

But if I check the dashboard of my Availability Group or even my secondary instance I can see that my AdventureWorks database is on Restoring mode, as pointed out by the previous error, and I have no master nor msdb databases:

Questions about your own setup? A dbi services consultant can look at your case.

Talk to an expert (opens in a new tab)

If I check the SQL logs on the primary instance I can see that my master and msdb database have been backed up but I have no trace of the restore on my secondary instance compare to the AdventureWorks database for which I can find a restore operation.

I dropped my Contained Availability Group and recreate the exactly same one but with the seeding synchronization method, I generate the scripts and run it:

No all is working perfectly, my master and msdb databases have been restored after some seconds to my secondary, the DMV dm_hadr_physical_seeding_stats shows that the success of the seeding method and my Contained Availability Group is synchronized on my 2 nodes.

I did those test with SQL Server 2022 CTP2.0 so no doubt that this issue will be fixed for the RTM version 😉
You can also read the blog of my colleague Steven on Contained Availability Group to have an overview of this feature.

Let’s work together

Ready to operate at
the next level?

Tell us about your challenge. We’ll bring the depth, the expertise, and the Swiss precision.

Stéphane Savorgnano

Stéphane Savorgnano

Stéphane Savorgnano has more than 20 years of experience in Microsoft software development and SQL Server database solutions, specializing in SQL Server installation, performance analysis, and best practices. He holds Microsoft Certified Solutions Associate (MCSA) and Expert (MCSE) for SQL Server 2012 through 2017, MCTS, MCITP for SQL Server 2008, and ITIL V3 Foundation certifications. Prior to dbi services, he was a software engineer at Ciba Specialty Chemicals in Basel. He holds a Master's degree in Informatics from the University of Mulhouse. His industry experience covers banking and financial services, chemicals, and pharmaceuticals.View Author posts

75 posts since November 2012

Most read in Database

The Database posts our readers open most: the all-time favourites, and what is trending right now.

Leave a Comment

Your email address will not be published. Required fields are marked *