Freigeben über


Fixing Test-SPContentDatabase warnings

Test-SPContentDatabase cmdlet usage is almost an integral part of any SharePoint 2007 to SharePoint 2010 migration.

More about the internals of Test-SPContentDatabase can be found at one of my post here

Fixing Missing Feature Warnings:

The missing feature warning shows: "The feature with Id [FEATURE ID] is referenced in the database [CONTENT DB NAME], but not installed on the current farm. The missing feature may cause upgrade to fail. Please install any solution which contain the feature and restart upgrade if necessary"

We can find the name of the feature from the feature id shown by searching the 12 hive features folder. I Usuall use Visual Studio search to search content inside the files. Once we find the feature name, decision has to be made whether it is a required feature, or a feature thats is not needed and has to be deactivated.

The missing feature warning might come because of two reasons, one if the corresponding site in which the feature is present is locked in which case unlocking the site should remove the warning or two, the feature is actually not installed in the server.

Case 1:   To know what are the sites that are using this feature, the following query can be run against the content database:

 Select * from Webs where SiteId in 
 (select SiteId from Features 
 where FeatureId = '<feature Id>')

From the list of sites obtained, if the feature is deactivated from those sites, the missing feature warning is likely to be removed.

Case 2: In some scenarios, i have noticed that the deactivation of feature will still not remove the warning even though the above query returns 0 results. The reason for it is that the feature might have been deactivated all right from all the corresponding sites, but the reference to the feature might still be present in the database. Run the below query to see the remaining references:

 SELECT * From AllLists (NOLOCK) 
 WHERE tp_FeatureId = '<feature id>'

The above query shows all the rows in 'AllLists' table which still refer to the feature. The reason for it is that, some of the features might have had a feature activation code through which the specified lists or document libraries have been created. If those features did not have a feature deactivation code to deal with it, the references still remain.

One way to deal with this is to delete the corresponding lists or doc libraries if they are no longer needed. The other way that worked for me is to take the backup of the list first, then delete the list from the site and create the list manually again from the backup. That way i did not lose the data and the feature reference is removed too.

Case 3: In some very rare cases, i have noticed that there was an 'Object reference found' error in the log. Upon dwelling long on the reason and checking the database, i have noticed that there are duplicate entries in the 'Features' table with same feature id. Ideally, there should not be duplicate entries in the features table. I am not sure about how the duplicate entries might got added, but the noticable thing was the relative folder path was different.

i.e. the previous path to the feature was something like "Features\MyCompanyName\MyCustomFeature\Feature.xml" and the new path is something like "Features\MyCompanyName\TotalCustomFeatures\MyCustomFeature\Feature.xml"

The only thing i could do was to delete the entry directly from the 'Features' table directly for the obsolete entry. (Not advisable)

Fixing Missing Setup Files Warnings:

The missing setup file warning shows: "File [Features\...\abc.xyz] is referenced [n] times in the database [CONTENT DB NAME], but is not installed on the current farm. Please install any feature/solution which contains this file."

The following query can be used to find the list of all the missing setup files present in the sites:

 select DirName, LeafName from alldocs where SetupPath in 
 ( 
 '..\missingFile1.master', 
 '..\missingFile2.webpart',
 and so on...,
 ...
 )
 

Once the list of files is known, we can opt to either delete them from the sites if not needed or install the corresponding package and feature if the files are needed.

Fixing Missing Webpart Error:

The missing webpart error shows : "WebPart class [WEBPART CLASS ID] is referenced [n] times in the database [CONTENT DB NAME], but is not installed on the current farm. Please install any feature/solution which contains this web part."

The following query can be used to find the list of all the pages which contain the missing webpart:

 Select AllDocs.SiteId,WebId,
 Webs.Title as 'Web Title', ListId,
 DirName,LeafName from AllDocs
 inner join WebParts on
 Alldocs.Id = Webparts.tp_PageUrlIDinner
 join Webs on Alldocs.WebId = webs.Id 
 where Webparts.tp_WebPartTypeId ='<webpartclassid>'

From the query result, we can get the page urls which contain the error webpart. We can open the corresponding page (append ?contents=1 to the url to see the list of webparts on page) and delete the error webparts from the page.

In some cases even after deleting the error webpart from the page, the entry is still shown in the database. Not only that the entry is still present, but the entry gets duplicated too. There is nothing to worry though because it might be the case that we have checked out the page, deleted the error webpart but did not check-in the page. Proper check-in of the page should resolve this issue.

Note: If the Test-SPContentDatabase cmdlet shows a missing webpart error, but on the corresponding page if you are not able to find any error webparts, then it means there is a mismatch in the SP 2007 and SP 2010 test environments. Some of the required packages might not have been installed.

Fixing Orphan Sites:

It is not often we encounter orphan sites warning, but even if there are no warnings in this category, executing the "stsadm  -o databaserepair –url <webapplicationName> -databasename <DataBaseName>" command and checking for any existense of orphan sites is useful.

Comments

  • Anonymous
    June 30, 2013
    Let me know if you can help in below issue; I am trying to migrate SP 2010 to SP 2013 using contend db upgrade method. Before runing Test-SPContentDatabase command I deployed all the custom wsps. But still I am getting feature not found. No change in GUIDs. I deployed branding feature in compitible mode and rest of other features are in native mode. upgrade error log shows both types of features are missing. But when I create Site Collection on default content database then I can see custom features are avaiable. I had followed same steps as you described in your post except one change in wsp deployment. I had deployed branding wsp in compatible mode (14) and rest of features are native mode (15) with same GUID. Still I am getting both type of features marked as missing. After upgrade failuer when I browse Site collection/_layout/Settings.aspx, I found OOB features like Site Collection Feature page, List and Library page etc were throwing exception. Thanks in advance
  • Sudarshan S Vatturkar