locked
Damaged project collection on TFS 2013, no solution to delete it from server.

    Question

  • Hello.

    I have a problem with one project collection on our TFS 2013 Update 2. I've been moving and updating one big project collection from TFS 2008 to TFS 2013, using in the middle TFS 2012. While restoring database backup something went wrong I suppose, but I hadn't noticed it and I attached it to TFS. The project collection appeared on the list with collections but it's offline and damaged. I have tried delete it using command:

    TfsConfig.exe collection /delete /collectionName:XXX and the output is:

    Deleting a Team Project Collection is an irreversible operation. A deleted colle
    ction can not be reattached to the same or another Team Foundation Server. Are you sure you want to delete 'XXX'? (Yes/No) yes
    Found Collection 'XXX'. Deleting...

    The detach operation failed. See the log file for additional details. Log file:
    C:\ProgramData\Microsoft\Team Foundation\Server Configuration\Logs\TPC_XXX_DeleteCollection_0509_091525.log

    In the middle:

    [2014-05-08 12:45:30Z][Informational] Creating dictionary with 4 initial items:
    [2014-05-08 12:45:30Z][Informational] CollectionProperties => 5c913508-06a1-4266-8bce-9dda2ebdb32a (XXX)
    [2014-05-08 12:45:30Z][Informational] RequestingIdentity => System.Security.Principal.WindowsIdentity;S-1-5-21-3624227412-2955519344-4135408192-6665
    [2014-05-08 12:45:30Z][Informational] DatabaseMap => System.Collections.Generic.Dictionary`2[System.String,Microsoft.TeamFoundation.Framework.Server.SqlConnectionInfoWrapper]
    [2014-05-08 12:45:30Z][Informational] CollectionDatabaseReachable => True
    [2014-05-08 12:45:30Z][Informational] Acquiring servicing job lock 'Servicing-5c913508-06a1-4266-8bce-9dda2ebdb32a'
    [2014-05-08 12:45:30Z][Informational] Setting token. Key: JobId. Value: 982a963f-042e-4f26-a76e-ece0f221679b.
    [2014-05-08 12:45:30Z][Informational] Setting item. Key: DatabaseMap. Value: System.Collections.Generic.Dictionary`2[System.String,Microsoft.TeamFoundation.Framework.Server.ISqlConnectionInfo].
    [2014-05-08 12:45:30Z][Informational] OperationClass: DeleteCollection
    [2014-05-08 12:45:30Z][Informational] Setting token. Key: OnlineUpdate. Value: true.
    [2014-05-08 12:45:30Z][Error] TF400876: Could not find the partition for host 5c913508-06a1-4266-8bce-9dda2ebdb32a.
    [2014-05-08 12:45:30Z][Informational] Microsoft.TeamFoundation.Framework.Server.DatabasePartitionNotFoundException: TF400876: Could not find the partition for host 5c913508-06a1-4266-8bce-9dda2ebdb32a.
       at Microsoft.TeamFoundation.Framework.Server.TeamFoundationServiceHost.GetPartitionId(HostProperties hostProperties)
       at Microsoft.TeamFoundation.Framework.Server.TeamFoundationServiceHost.get_PartitionId()
       at Microsoft.TeamFoundation.Framework.Server.TeamFoundationServicingService.CreatePartitionIdToHostIdMap(TeamFoundationRequestContext deploymentContext, ServicingContext servicingContext, ServicingJobData servicingJobData, ISqlConnectionInfo frameworkConnectionInfo)
       at Microsoft.TeamFoundation.Framework.Server.TeamFoundationServicingService.PerformPreJobWork(TeamFoundationRequestContext requestContext, ServicingContext servicingContext, ServicingJobData servicingJobData, IServicingOperationProvider operationProvider, IStepPerformerProvider stepPerformerProvider, Guid jobId, DateTime jobQueueTime)
       at Microsoft.TeamFoundation.Framework.Server.TeamFoundationServicingService.PerformServicingJob(TeamFoundationRequestContext requestContext, ServicingJobData servicingJobData, Guid jobId, DateTime jobQueueTime, Int32 numberOfStepsToPerform)
    [2014-05-08 12:45:30Z][Informational] Clearing dictionary, removing all items.

    I have tried also detach from TFS admin console, and I get this error message:

    TF401219: The team project collection 'XXX' cannot be detached because its version ID is different than the ID for the configuration database. The collection has the following version: Dev11.M55. The Team Foundation Server is at the following version: Dev12.M62.

    Friday, May 09, 2014 11:00 AM

Answers

  • Hi,
    I am sorry that we introduced this regression in TFS 2013.2. The issue will be fixed in TFS 2013.3. To workaround this problem, you can drop your damaged collection database and create a fake collection database using the script below. Make sure to set @collectionDatabaseName and @serviceLoginName correctly before running this script. Once you created the fake database using the script, you can execute tfsconfig collection /delete /collectionName:<collection-to-delete> command to delete your collection:

    Thanks,

    --Vladimir

    DECLARE @collectionDatabaseName SYSNAME
    DECLARE @serviceLoginName SYSNAME = 'NT AUTHORITY\NETWORK SERVICE'
    
    SET @collectionDatabaseName = 'Tfs_<your-collection>'
    SET @serviceLoginName = 'NT AUTHORITY\NETWORK SERVICE'  -- TFS AND SQL Server on the same machine. TFS is running as NT AUTHORITY\NETWORK SERVICE
    -- SET @serviceLoginName = 'DOMAIN\ServiceAccount'      -- TFS is configured to use domain service account
    -- SET @serviceLoginName = 'DOMAIN\MACHINE$'            -- TFS AND SQL Server are on different machines. TFS is running as NT AUTHORITY\NETWORK SERVICE
    
    SET XACT_ABORT ON
    DECLARE @stmt NVARCHAR(MAX)
    
    SET @stmt = N'CREATE DATABASE ' + QUOTENAME(@collectionDatabaseName)
    EXEC(@stmt)
    SET @stmt = 'USE ' + QUOTENAME(@collectionDatabaseName) + '; EXEC sp_changedbowner @serviceLoginName'
    EXEC sp_executesql @stmt, N'@serviceLoginName SYSNAME', @serviceLoginName
    
    SET @stmt = 'USE ' + QUOTENAME(@collectionDatabaseName) + '
    EXEC(''
    CREATE PROCEDURE prc_QueryPartition
        @serviceHostId      UNIQUEIDENTIFIER
    AS 
    BEGIN
        SET NOCOUNT ON
    
        SELECT  @serviceHostId ServiceHostId,
                1 PartitionId,
                CONVERT(TINYINT, 1) State,
                CONVERT(DATETIME, NULL) StateChangedDate,
                4 HostType
    END
    '');
    EXEC(''
    CREATE PROCEDURE prc_GetServiceVersion(
        @serviceName VARCHAR(128))
    AS
    BEGIN
        SELECT  @serviceName ServiceName,
                1 Version,
                1 MinVersion
    END
    '');
    EXEC(''
    CREATE PROCEDURE prc_QueryNotificationWatermark
    AS
    SELECT CONVERT(BIGINT, 0) EventId'');
    EXEC(''
    CREATE PROCEDURE prc_QueryRegistry (
        @registryPath   NVARCHAR(260),
           @partitionId    INT = 1)
    AS
        SELECT  NULL RegistryPath,
                NULL RegValue
        WHERE   0 <> 0
    '')
    '
    EXEC(@stmt)
    

    Friday, May 23, 2014 3:14 AM
    Owner

All replies

  • Hi Jan, 

    Thanks for your post.

    TFS 2013 Update 2 database’s TFS_SERVICE_LEVEL version is Dev12.M62, you can check TFS database’s TFS_SERVICE_LEVEL version in SQL Server Management Studio: right-click on TFS database>>Properties>>Extended Properties tab, then you can find this’s database’s TFS_SERVICE_LEVEL version value in right panel.

    The Dev11.M55 value is TFS 2012 Server database’s TFS_SERVICE_LEVEL version, it seems this moved collection version didn’t be upgrade after you attached it into your TFS 2013 Server. We can ensure this issue relate your TFS database, but we don’t recommend edit TFS database directly, it may cause the unknown issues.

    For this issue, I am trying to involve someone familiar with this topic to further look at this issue. There might be some time delay. Appreciate your patience.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, May 12, 2014 5:35 AM
    Moderator
  • Thank you.

    I've checked it. You have got right. This database is Microsoft Team Foundation Server 2012 M55 ( Dev11.M55 ) I can see one small detail in extended properties in SQl Server Management Studio. On this broken database there is 2 properties which are absent on healthy databases, TFS_SNAPSHOT_COLLECTIONID and TFS_SNAPSHOT_STATE. 

    I'm waiting for your response, thank you.

    Monday, May 12, 2014 11:50 AM
  • Hello, any idea here?
    Thursday, May 15, 2014 7:49 AM
  • Hi Jan,
    I am sorry you are having difficulties. Please contact me via e-mail: vladimir dot khvostov at microsoft.com.

    Thanks,

    --Vladimir

    Wednesday, May 21, 2014 5:53 AM
    Owner
  • I've written an email to you. 

    Thank you.

    Wednesday, May 21, 2014 11:52 AM
  • Hi,
    I am sorry that we introduced this regression in TFS 2013.2. The issue will be fixed in TFS 2013.3. To workaround this problem, you can drop your damaged collection database and create a fake collection database using the script below. Make sure to set @collectionDatabaseName and @serviceLoginName correctly before running this script. Once you created the fake database using the script, you can execute tfsconfig collection /delete /collectionName:<collection-to-delete> command to delete your collection:

    Thanks,

    --Vladimir

    DECLARE @collectionDatabaseName SYSNAME
    DECLARE @serviceLoginName SYSNAME = 'NT AUTHORITY\NETWORK SERVICE'
    
    SET @collectionDatabaseName = 'Tfs_<your-collection>'
    SET @serviceLoginName = 'NT AUTHORITY\NETWORK SERVICE'  -- TFS AND SQL Server on the same machine. TFS is running as NT AUTHORITY\NETWORK SERVICE
    -- SET @serviceLoginName = 'DOMAIN\ServiceAccount'      -- TFS is configured to use domain service account
    -- SET @serviceLoginName = 'DOMAIN\MACHINE$'            -- TFS AND SQL Server are on different machines. TFS is running as NT AUTHORITY\NETWORK SERVICE
    
    SET XACT_ABORT ON
    DECLARE @stmt NVARCHAR(MAX)
    
    SET @stmt = N'CREATE DATABASE ' + QUOTENAME(@collectionDatabaseName)
    EXEC(@stmt)
    SET @stmt = 'USE ' + QUOTENAME(@collectionDatabaseName) + '; EXEC sp_changedbowner @serviceLoginName'
    EXEC sp_executesql @stmt, N'@serviceLoginName SYSNAME', @serviceLoginName
    
    SET @stmt = 'USE ' + QUOTENAME(@collectionDatabaseName) + '
    EXEC(''
    CREATE PROCEDURE prc_QueryPartition
        @serviceHostId      UNIQUEIDENTIFIER
    AS 
    BEGIN
        SET NOCOUNT ON
    
        SELECT  @serviceHostId ServiceHostId,
                1 PartitionId,
                CONVERT(TINYINT, 1) State,
                CONVERT(DATETIME, NULL) StateChangedDate,
                4 HostType
    END
    '');
    EXEC(''
    CREATE PROCEDURE prc_GetServiceVersion(
        @serviceName VARCHAR(128))
    AS
    BEGIN
        SELECT  @serviceName ServiceName,
                1 Version,
                1 MinVersion
    END
    '');
    EXEC(''
    CREATE PROCEDURE prc_QueryNotificationWatermark
    AS
    SELECT CONVERT(BIGINT, 0) EventId'');
    EXEC(''
    CREATE PROCEDURE prc_QueryRegistry (
        @registryPath   NVARCHAR(260),
           @partitionId    INT = 1)
    AS
        SELECT  NULL RegistryPath,
                NULL RegValue
        WHERE   0 <> 0
    '')
    '
    EXEC(@stmt)
    

    Friday, May 23, 2014 3:14 AM
    Owner
  • Thank you, it solve my problem.
    Monday, May 26, 2014 2:36 PM
  • Hi Vladimir,

    Could you please let me know how to declare the following first two lines. It would be great if you use an example.

    DECLARE @collectionDatabaseName SYSNAME
    DECLARE @serviceLoginName SYSNAME = 'NT AUTHORITY\NETWORK SERVICE'

    Regards,

    Prashant Gaikwad

    Thursday, June 26, 2014 11:06 AM
  • Hi Vladimir,

    Sorry to bother you. The issue is resolved. Thank you for the script.

    Regards,

    Prashant Gaikwad

    Thursday, June 26, 2014 11:33 AM
  • THANK YOU THANK YOU THANK YOU!!!! Been all over google all day until I found this.  Thanks!
    Thursday, August 21, 2014 9:35 PM
  • Our TFS administrators are getting the same error when upgrading TFS 2012 to TFS 2013.  As per a reply in this forum post, this issue should be resolved in TFS 2013 Update 3.  I reviewed the release notes for TFS 2013 Update 3(Bug fixed - TFS server category) but don't see this listed.  Can you please provide an update?

    Wednesday, October 01, 2014 12:20 PM