This is a short story about how you can get and resolve stale Managed Metadata Service (MMS) databases in SharePoint 2010. I’ve been working with Managed Metadata quite much and done some backup/restore juggling from production to test and to dev environments. Which by the way works really smooth. I’ve also recreated the MMS databases a couple of times. After applying Service Pack and the re-released June 2011 CU I went into Central Administration to take a look at the databases and their upgrade status. This is what I found: four MMS databases, of which two didn’t upgrade, and I only have two MMS service applications in this particular environment.
As you can see two of the databases reports “Database is in compatibility range and upgrade is recommended”. There’s no link to click to upgrade and there’s no PowerShell command either to update them. These two databases were not connected to any MMS service application so it’s no big deal, but who wants these kind of “warnings” in their CA.
To create these stale MMS databases is an easy task; just go to Properties of the MMS SA and change the name of the database. This will provision a new and empty database for you, leaving the old database still registered in the configuration database of SharePoint. I don’t know if this should be considered a bug or not, of course the database should not be deleted automatically, but should they remain registered as databases in the configuration database?
So, in order to remove these databases, the easiest way is to fire up your favorite command line tool - PowerShell, and use a few lines of commands. This is how it’s done:
First of all the
command will return all registered in your farm.
By using the Id of the database it’s easy to get one explicit database into a PowerShell variable like this:
$db = Get-SPDatabase cb825c9d-8494-46fc-9ffc-3f81cffdfafc
Now that we have one of our stale MMS databases we can use the
method of the Database object to delete the actual reference in the configuration database, like this:
This will only delete the reference (the persisted object) and not the database. If you would like to remove the database as well, you can use the
method prior to the deletion:
If you do just an Unprovision of the database, and don’t delete the database, the database status in the upgrade status page will say “Not responding”:
That was it, a quick and short post about stale Managed Metadata Service databases - how they become stale and how you remove them.