TFS2018构建定义保存错误 - 名称为%counterName =“BuildFolderId”的计数器;%不存在

时间:2018-04-27 13:13:30

标签: sql build build-definition tfs2018

我从2015update1到2018update2新迁移的TFS On-permise出现问题

我创建了一个新的构建定义,当我点击“保存”时,我有以下消息:

%error="800095";%:TFSSERVER.Tfs_DefaultCollection.dbo.prc_iCounterGetNext: Counter with name %counterName="BuildFolderId";% does not exist

%error="901004";%:TFSSERVER.Tfs_DefaultCollection.prc_iiEnsureFolder: Database Update Failure - Error %error="800095";% executing EXEC statement for prc_iCounterGetNext

%error="901004";%:TFSSERVER.Tfs_DefaultCollection.prc_AddDefinition: Database Update Failure - Error %error="901004";% executing EXEC statement for Build.prc_iiEnsureFolder

它与...相似 developer community 通过对sql数据库执行查询,已经重新启动了女巫 TFS2017Update1 release note - known issues

INSERT  tbl_Counter (PartitionId, DataspaceId, CounterName, CounterValue)
SELECT  DISTINCT
      dpm.PartitionId,
      ds.DataspaceId,
      N'TaskReferenceId',
      1
FROM    tbl_DatabasePartitionMap dpm
INNER LOOP JOIN Task.tbl_Hub h
ON      h.PartitionId = dpm.PartitionId
INNER LOOP JOIN tbl_Dataspace ds
ON      ds.PartitionId = dpm.PartitionId
      AND ds.DataspaceCategory = h.DataspaceCategory
      AND ds.DataspaceIdentifier <> '00000000-0000-0000-0000-000000000000'
WHERE   dpm.PartitionId > 0
      AND dpm.HostType = 4
      AND NOT EXISTS (
          SELECT  *
          FROM    tbl_Counter c
          WHERE   c.PartitionId = dpm.PartitionId
                  AND c.DataspaceId = ds.DataspaceId
                  AND c.CounterName = N'TaskReferenceId'
      )

感谢您的帮助。

1 个答案:

答案 0 :(得分:0)

我终于找到了解决这个问题的方法

  1. 如何知道正确的DataspaceId:

    SELECT TOP 1000 [PartitionId] ,[ProjectId],[DataspaceId], [ProjectUri],ProjectName],[SequenceId],[IsDeleted], [IsResolutionStateCustomized],[IsFailureTypeCustomized],[MigrationState], [MigrationError] FROM [Tfs_DefaultCollection].[dbo].[tbl_Project] WHERE ProjectName = "My project witch having an error"

  2. [ProjectUri]中字符串的结尾包含项目的唯一ID(在我的情况下为vstfs:///Classification/TeamProject/b96fbc5b-7bf3-452b-894f-6f5b4bb801c0

    1. 如何知道相应的DataspaceId

      SELECT TOP 1000 [PartitionId] ,[DataspaceCategory] ,[DataspaceIdentifier] ,[DataspaceId] ,[DatabaseId] ,[State] FROM [Tfs_DefaultCollection].[dbo].[tbl_Dataspace] where DataspaceIdentifier="b96fbc5b-7bf3-452b-894f-6f5b4bb801c0" and DataspaceCategory="Build"

    2. 它给了我数据空间ID:726

      1. 检查表格[Build]中是否没有记录。[tbl_Folder]

        SELECT TOP 1000 [PartitionId] ,[DataspaceId] ,[FolderId] ,[FolderPath] ,[FolderName] ,[CreatedBy] ,[CreatedOn] ,[Description] ,[ChangedBy] ,[ChangedOn] ,[Deleted] FROM [Tfs_DefaultCollection].[Build].[tbl_Folder] WHERE DataspaceId=726

      2. 如果没有记录,我必须创建一个。

        INSERT INTO [Build].[tbl_Folder]
               ([PartitionId]
               ,[DataspaceId]
               ,[FolderId]
               ,[FolderPath]
               ,[FolderName]
               ,[CreatedBy]
               ,[CreatedOn]
               ,[Description]
               ,[ChangedBy]
               ,[ChangedOn]
               ,[Deleted])
         VALUES
               (1
               ,726
               ,1
               ,''
               ,'\'
               ,'00000000-0000-0000-0000-000000000000'
               ,CURRENT_TIMESTAMP
               ,NULL
               ,NULL
               ,NULL
               ,0)
        GO
        
        1. 使用此DataspaceId检查表[tbl_Counter]中是否没有记录

          SELECT TOP 1000 [PartitionId],[DataspaceId],[CounterName],[CounterValue] FROM [Tfs_DefaultCollection].[dbo].[tbl_Counter] where CounterName='BuildFolderId' and DataspaceId=726

        2. 如果没有记录,我必须创建一个。

          INSERT INTO [dbo].[tbl_Counter]
                 ([PartitionId]
                 ,[DataspaceId]
                 ,[CounterName]
                 ,[CounterValue])
           VALUES
                 (1
                 ,726
                 ,'BuildFolderId'
                 ,2)
           GO
          

          之后,我可以保存我的构建定义。

          当我尝试启动我的构建定义时出现其他错误:

          %error="800095";%:TFSSERVER.Tfs_DefaultCollection.dbo.prc_iCounterGetNext: Counter with name %counterName="TimelineStringId";% does not exist
          

          基于前面的脚本,我在表[tbl_Counter]

          中插入新值
          INSERT INTO [dbo].[tbl_Counter]
                 ([PartitionId]
                 ,[DataspaceId]
                 ,[CounterName]
                 ,[CounterValue])
           VALUES
                 (1
                 ,726
                 ,'TimelineStringId'
                 ,2)
           GO
          

          最后我有一个遗留错误:

          %error="800095";%:TFSSERVER.Tfs_DefaultCollection.dbo.prc_iCounterGetNext: Counter with name %counterName="TaskOrchestrationPlanId";% does not exist
          

          这样:

          INSERT INTO [dbo].[tbl_Counter]
                 ([PartitionId]
                 ,[DataspaceId]
                 ,[CounterName]
                 ,[CounterValue])
           VALUES
                 (1
                 ,726
                 ,'TaskOrchestrationPlanId'
                 ,2)
           GO
          

          我终于能够成功启动我的构建定义了。

          希望能帮助别人。

          我用两个版本编写一个sql脚本,一个用于TFS2018,另一个用于TFS2015

          按实际项目名称更改变量@projectName。
          TFS2018版本:

          USE [Tfs_DefaultCollection]
          GO
          declare @projectUriGlobal varchar(max);
          declare @projectName varchar(max);
          declare @DataspaceIdentifier varchar(max);
          declare @DataspaceId int;
          select @projectName='MyProjectName'
          select @projectUriGlobal = (select [ProjectUri] from [tbl_Project] where ProjectName=@projectName)
          select @DataspaceIdentifier = (select right(@projectUriGlobal, charindex('/', reverse(@projectUriGlobal) + '/') - 1))
          if not exists(select DataspaceId from [tbl_Dataspace] where DataspaceIdentifier = @DataspaceIdentifier and DataspaceCategory='Build')
          BEGIN
            PRINT 'Création d" un enregistrement dans [tbl_Dataspace] pour le DataspaceIdentifier '+@DataspaceIdentifier;
            INSERT INTO [tbl_Dataspace] VALUES (1,'Build', @DataspaceIdentifier,1,1)
          END
          
          select  @DataspaceId = (select DataspaceId from [tbl_Dataspace] where DataspaceIdentifier = @DataspaceIdentifier and DataspaceCategory='Build')
          
          PRINT 'Project Name : '+@projectName;
          PRINT 'Project Uri :'+  @projectUriGlobal
          PRINT 'DataspaceIdentifier : '+ @DataspaceIdentifier
          PRINT 'DataSpaceID : '+ CAST(@DataspaceId as varchar)
          
          if EXISTS(SELECT TOP 1 [DataspaceId] FROM [Build].[tbl_Folder] where DataspaceId=@DataspaceId)
          BEGIN
            PRINT 'Pas d"enregistrement a creer dans [Build].[tbl_Folder] pour le dataspace ID '+ CAST(@DataspaceId as varchar) +' car existe déjà'
          END
          ELSE
          BEGIN
            PRINT 'Creation d"un enregistrement dans la table [Build].[tbl_Folder] pour le dataspace ID '+ CAST(@DataspaceId as varchar)
            INSERT INTO [Build].[tbl_Folder] ([PartitionId] ,[DataspaceId],[FolderId],[FolderPath],[FolderName],[CreatedBy],[CreatedOn],[Description],[ChangedBy],[ChangedOn],[Deleted])
                  VALUES (1,@DataspaceId,1,'','\','00000000-0000-0000-0000-000000000000',CURRENT_TIMESTAMP,NULL ,NULL,NULL,0)
          END
          
          if EXISTS(SELECT TOP 1 [PartitionId],[DataspaceId],[CounterName] FROM [tbl_Counter]  where CounterName='BuildFolderId' and DataspaceId=@DataspaceId)
          BEGIN
             PRINT 'Pas d"enregistrement a creer dans la table [tbl_Counter] pour le dataspace ID '+ CAST(@DataspaceId as varchar) +' avec le counterName=BuildFolderId  car existe déjà';
          END
          ELSE
          BEGIN
             PRINT 'Creation d"un enregistrement dans la table [tbl_Counter] pour le dataspace ID '+ CAST(@DataspaceId as varchar) +' avec le counterName=BuildFolderId';
             INSERT INTO [dbo].[tbl_Counter] ([PartitionId],[DataspaceId],[CounterName],[CounterValue]) VALUES (1,@DataspaceId,'BuildFolderId',2)
          END
          
          if EXISTS(SELECT TOP 1 [PartitionId],[DataspaceId],[CounterName] FROM [tbl_Counter]  where CounterName='TimelineStringId' and DataspaceId=@DataspaceId)
          BEGIN
             PRINT 'Pas d"enregistrement a creer dans la table [tbl_Counter] pour le dataspace ID '+ CAST(@DataspaceId as varchar) +' avec le counterName=TimelineStringId  car existe déjà';
          END
          ELSE
          BEGIN
             PRINT 'Creation d"un enregistrement dans la table [tbl_Counter] pour le dataspace ID '+ CAST(@DataspaceId as varchar) +' avec le counterName=TimelineStringId';
             INSERT INTO [dbo].[tbl_Counter] ([PartitionId],[DataspaceId],[CounterName],[CounterValue]) VALUES (1,@DataspaceId,'TimelineStringId',2)
          END
          
          if EXISTS(SELECT TOP 1 [PartitionId],[DataspaceId],[CounterName] FROM [tbl_Counter]  where CounterName='TaskOrchestrationPlanId' and DataspaceId=@DataspaceId)
          BEGIN
             PRINT 'Pas d"enregistrement a creer dans la table [tbl_Counter] pour le dataspace ID '+ CAST(@DataspaceId as varchar) +' avec le counterName=TaskOrchestrationPlanId  car existe déjà';
          END
          ELSE
          BEGIN
             PRINT 'Creation d"un enregistrement dans la table [tbl_Counter] pour le dataspace ID '+ CAST(@DataspaceId as varchar) +' avec le counterName=TaskOrchestrationPlanId';
             INSERT INTO [dbo].[tbl_Counter] ([PartitionId],[DataspaceId],[CounterName],[CounterValue]) VALUES (1,@DataspaceId,'TaskOrchestrationPlanId',2)
          END
          

          TFS2015的版本为

          USE [Tfs_DefaultCollection]
          GO
          declare @projectUriGlobal varchar(max);
          declare @projectName varchar(max);
          declare @DataspaceIdentifier varchar(max);
          declare @DataspaceId int;
          
          select @projectName='MyProjectName'
          select @projectUriGlobal = (select [ProjectUri] from [tbl_Project] where ProjectName=@projectName)
          select @DataspaceIdentifier = (select right(@projectUriGlobal, charindex('/', reverse(@projectUriGlobal) + '/') - 1))
          if not exists(select DataspaceId from [tbl_Dataspace] where DataspaceIdentifier = @DataspaceIdentifier and DataspaceCategory='Build')
          BEGIN
            PRINT 'Création d" un enregistrement dans [tbl_Dataspace] pour le DataspaceIdentifier '+@DataspaceIdentifier;
            INSERT INTO [tbl_Dataspace] VALUES (1,'Build', @DataspaceIdentifier,1,1)
          END
          
          select  @DataspaceId = (select DataspaceId from [tbl_Dataspace] where DataspaceIdentifier = @DataspaceIdentifier and DataspaceCategory='Build')
          
          PRINT 'Project Name : '+@projectName;
          PRINT 'Project Uri :'+  @projectUriGlobal
          PRINT 'DataspaceIdentifier : '+ @DataspaceIdentifier
          PRINT 'DataSpaceID : '+ CAST(@DataspaceId as varchar)
          
          if EXISTS(SELECT TOP 1 [PartitionId],[DataspaceId],[CounterName] FROM [tbl_Counter]  where CounterName='BuildFolderId' and DataspaceId=@DataspaceId)
          BEGIN
             PRINT 'Pas d"enregistrement a creer dans la table [tbl_Counter] pour le dataspace ID '+ CAST(@DataspaceId as varchar) +' avec le counterName=BuildFolderId  car existe déjà';
          END
          ELSE
          BEGIN
             PRINT 'Creation d"un enregistrement dans la table [tbl_Counter] pour le dataspace ID '+ CAST(@DataspaceId as varchar) +' avec le counterName=BuildFolderId';
             INSERT INTO [dbo].[tbl_Counter] ([PartitionId],[DataspaceId],[CounterName],[CounterValue]) VALUES (1,@DataspaceId,'BuildFolderId',2)
          END
          
          if EXISTS(SELECT TOP 1 [PartitionId],[DataspaceId],[CounterName] FROM [tbl_Counter]  where CounterName='TimelineStringId' and DataspaceId=@DataspaceId)
          BEGIN
             PRINT 'Pas d"enregistrement a creer dans la table [tbl_Counter] pour le dataspace ID '+ CAST(@DataspaceId as varchar) +' avec le counterName=TimelineStringId  car existe déjà';
          END
          ELSE
          BEGIN
             PRINT 'Creation d"un enregistrement dans la table [tbl_Counter] pour le dataspace ID '+ CAST(@DataspaceId as varchar) +' avec le counterName=TimelineStringId';
             INSERT INTO [dbo].[tbl_Counter] ([PartitionId],[DataspaceId],[CounterName],[CounterValue]) VALUES (1,@DataspaceId,'TimelineStringId',2)
          END
          
          if EXISTS(SELECT TOP 1 [PartitionId],[DataspaceId],[CounterName] FROM [tbl_Counter]  where CounterName='TaskOrchestrationPlanId' and DataspaceId=@DataspaceId)
          BEGIN
             PRINT 'Pas d"enregistrement a creer dans la table [tbl_Counter] pour le dataspace ID '+ CAST(@DataspaceId as varchar) +' avec le counterName=TaskOrchestrationPlanId  car existe déjà';
          END
          ELSE
          BEGIN
             PRINT 'Creation d"un enregistrement dans la table [tbl_Counter] pour le dataspace ID '+ CAST(@DataspaceId as varchar) +' avec le counterName=TaskOrchestrationPlanId';
             INSERT INTO [dbo].[tbl_Counter] ([PartitionId],[DataspaceId],[CounterName],[CounterValue]) VALUES (1,@DataspaceId,'TaskOrchestrationPlanId',2)
          END