a·gen·tic a·gil·i·ty

Issue [ TFS 2012.2 ] Detaching collection fails on SnapshotIdentities with object reference not set to an instance of an object

Explains how detaching a Team Project Collection in TFS 2012.x can fail due to orphaned identities, causing a NullReferenceException, and outlines steps for diagnosis and support.

Published on
3 minute read
Image
https://nkdagility.com/resources/1jIPsnnKuNK
Subscribe

When you try to detach a Team Project Collection in Team Foundation Server the process fails on SnapshotIdentities with an “object reference not set to an instance of an object” error. While this does not inhibit the execution of TFS there is likely a good reason that you wanted to detach and found this issue.

Issue [ TFS 2012.2 ] Detaching collection fails on SnapshotIdentities with object reference not set to an instance of an object

Figure: object reference not set to an instance of an object

In this case I was trying to move the Collection to another server and this is a blocking issue.

Applies To

Findings

When you get these sorts of errors make sure that you look in the Event Log of the server and at the logs generated by TFS. In the event of an error there will be a link on the page that will open the relevant log in the Team Foundation Server Administration Console.

 1[11:16:24.010] ++ Executing - Operation: Snapshot, Group: Snapshot.TfsIdentities
 2[11:16:25.010] Executing step: Copy identities to collection database
 3[11:16:25.010]   Executing step: 'Copy identities to collection database' Identity.SnapshotIdentities (16 of 28)
 4[11:18:15.873]   [Error] Object reference not set to an instance of an object.
 5[11:18:15.877]   System.NullReferenceException: Object reference not set to an instance of an object.
 6[11:18:15.877]      at Microsoft.TeamFoundation.Framework.Server.IdentityTransferHandler.Transfer()
 7[11:18:15.877]      at Microsoft.TeamFoundation.Framework.Server.IdentityTransferHandler.Execute()
 8[11:18:15.877]      at Microsoft.VisualStudio.Services.Framework.IdentityStepPerformer.SnapshotIdentities(TeamFoundationRequestContext requestContext, ServicingContext servicingContext)
 9[11:18:15.877]      at Microsoft.TeamFoundation.Framework.Server.TeamFoundationStepPerformerBase.Microsoft.TeamFoundation.Framework.Server.IStepPerformer.PerformStep(String servicingOperation, String stepType, String stepData, ServicingContext servicingContext)
10[11:18:15.877]      at Microsoft.TeamFoundation.Framework.Server.ServicingStepDriver.PerformServicingStep(ServicingStep step, ServicingContext servicingContext, ServicingStepGroup group, ServicingOperation servicingOperation, Int32 stepNumber, Int32 totalSteps)
11[11:18:15.877] Step failed: Copy identities to collection database. Execution time: 110 seconds.
12[11:18:15.883]   Clearing dictionary, removing all items.

In the log you can clearly see that the step that is failing is the “Snapshot.TfsIdentities”. What I believe that this does is create a package inside of the Collection database for the new TFS Instance that you are moving it to. This package needs to contain all of the Identities that have interacted with this TFS Instance. The likely cause of this error is that there are orphaned group memberships in the Configuration database that do not exist within the Collection.

I would suggest that this would be the result of a TFS server that has backed up without the use of a ‘marked transaction log’ and that backup restored at some point. If you have large databases and you don’t use the built in Scheduled Backups tool or the documented process to manually back up Team Foundation Server then you are leaving yourself open for this type of inconsistency.

To find out if your have any orphaned identities then you should run:

Warning Do not make any changes to any of your TFS Databases manually unless specifically instructed by the Product Team. If you do then you can no longer be supported by Microsoft.

 1SELECT  gm
 2FROM    tbl_GroupMembership gm
 3WHERE   gm.PartitionId = 1
 4    AND NOT EXISTS (
 5        SELECT  *
 6        FROM    tbl_Group g
 7        WHERE   g.PartitionId = 1
 8            AND g.Id = gm.MemberId
 9    )
10    AND NOT EXISTS (
11        SELECT  *
12        FROM    tbl_Identity i
13        WHERE   i.PartitionId = 1
14            AND i.Id = gm.MemberId
15    )

If you get results from this query then you have this problem and you should immediately raise a support ticket with Microsoft to get this fixed.

Solution

You need to remove all of the orphaned identities from your server in order to fix this. To achieve that you should work with Microsoft by raising a support ticket and cleaning the instance.  If an invalid backup has been restored there are likely other things that need to happen to get into a supported state and changing the database yourself will not get you there.

Raise a ticket and get your server into a supported state…

Troubleshooting Software Development System Configuration
Subscribe

Related Blog

No related videos found.

Connect with Martin Hinshelwood

If you've made it this far, it's worth connecting with our principal consultant and coach, Martin Hinshelwood, for a 30-minute 'ask me anything' call.

Our Happy Clients​

We partner with businesses across diverse industries, including finance, insurance, healthcare, pharmaceuticals, technology, engineering, transportation, hospitality, entertainment, legal, government, and military sectors.​

NIT A/S

Akaditi Logo

Akaditi

Cognizant Microsoft Business Group (MBG) Logo

Cognizant Microsoft Business Group (MBG)

MacDonald Humfrey (Automation) Ltd. Logo

MacDonald Humfrey (Automation) Ltd.

Big Data for Humans Logo

Big Data for Humans

Illumina Logo

Illumina

Milliman Logo

Milliman

CR2

ProgramUtvikling Logo

ProgramUtvikling

Microsoft Logo

Microsoft

Freadom Logo

Freadom

Brandes Investment Partners L.P. Logo

Brandes Investment Partners L.P.

Jack Links Logo

Jack Links

Emerson Process Management Logo

Emerson Process Management

Capita Secure Information Solutions Ltd Logo

Capita Secure Information Solutions Ltd

YearUp.org Logo

YearUp.org

Ericson Logo

Ericson

Slicedbread Logo

Slicedbread

New Hampshire Supreme Court Logo

New Hampshire Supreme Court

Nottingham County Council Logo

Nottingham County Council

Washington Department of Enterprise Services Logo

Washington Department of Enterprise Services

Royal Air Force Logo

Royal Air Force

Washington Department of Transport Logo

Washington Department of Transport

Ghana Police Service Logo

Ghana Police Service

Lean SA Logo

Lean SA

Cognizant Microsoft Business Group (MBG) Logo

Cognizant Microsoft Business Group (MBG)

Trayport Logo

Trayport

Boxit Document Solutions Logo

Boxit Document Solutions

NIT A/S

Healthgrades Logo

Healthgrades