I'm working with Microsoft Visual Studio 2005 Team Explorer Service Pack 1 (KB918525) against Visual Studio Team Foundation Server Service Pack 1 (KB922996) using SQL Server 2005 Standard Service Pack 1.
I started a merge from an integration to main line using the Team Explorer's Source Control Explorer GUI. I canceled this merge while still in the wizard.
Now when attempting a similar merge (involving the same targets and workspace) from the command line or from the GUI, I receive a dialog with the following error.
A database error occurred (SQL error 2627) ---> Violation of PRIMARY KEY constraint 'PK_tbl_PendingMerge'. Cannot insert duplication key in object 'dbo.tbl_PendingMerge'.
Using the Team Explorer's Source Control Explorer GUI, there are no pending changes to undo.
There are rows in tbl_PendingMerge.
Help

Hung merge possibly causing SQL error 2627
Bruce Baker
JocularJoe
Richard,
The problem is now resolved following the advice in this thread of removing the rows associated with my work space from the tbl_PendingMerge table. The rows were still left in this table after closing the conflict resolution dialogue and undoing checkout on all items, so effectively aborting the merge process. On susequent attempts after this the same error as detailed in the first post on this thread occurred e.g.
A database error occurred (SQL error 2627) ---> Violation of PRIMARY KEY constraint 'PK_tbl_PendingMerge'. Cannot insert duplication key in object 'dbo.tbl_PendingMerge'.
As previously stated I believe the extra warning dialogue about shown regarding permissions before the conflict resolution dialogue was shown may be significant as subsequent smaller merges where I haven't had this dialogue have aborted correctly.
Hope this extra info helps.
chaza
Rebooting the TFS server (single server deployment) didn't cause any nifty transaction rollbacks that clean out TfsVersionControl's tbl_PendingMerge.
And the same error is issued when attempting the similar merge.
If I destroy & re-create the workspace, I anticipate that the WorkspaceId will change, and the problem will be effectively worked around.
Alternately, can I remove the 21 rows from tbl_PendingMerge
Are there any automated (or at least guided) database consistency checking or enforcing tools for TFS (I enjoy being a software engineer, a cm user, and not a dba)
Philippe Cand
edit - this is a very old thread, please open a new one if you are still experiencing problems
Lee John
edit: if so, it's likely that the orphan rows already existed, i.e. the merge you recently canceled was not the root cause
We have a bug open to cleanup orphan rows during upgrades...should make it into the final SP1.
Georg Müller
I don't know if the rows were hanging around, but I can post their contents.
Better cleanup is good :) I'm glad it makes it into the final SP.
Maxim Michtchenko
I've stopped TFS related services and removed the rows from tbl_PendingMerge. After restarting the services, the merge operations completed successfully.
I still believe there is an error wrt/ cleanup of TfsVersionControl's tbl_PendingMerge when a Source Control Explorer initiated merge is cancelled.
Jamesx
I can confirm this is definitely still happening post SP1 and the tbl_PendingMerge was cleared down before this occurred.
The bug seems to trigger when the merge warning dialogue is shown before the conflicts window pops up. In my experience this tends to leave some row in tbl_PendingMerge for some reason, which would appear to be a bug.