Dead lock comes after using SQL source control.
amit987
Posts: 2 New member
I am using your SQL source control product in our organisation. We have issue with this product that deadlock alerts are coming after using this product on our server. Please find the below script that are the cause of dead lock on our server. and also suggest how we can prevent this dead lock.
UPDATE Child
SET UserName = Parent.UserName,
[Matched] = 1
FROM tempdb.dbo.RG_AllObjects_v4 Child
INNER JOIN tempdb.dbo.RG_AllObjects_v4 Parent
ON Parent.ObjectID = Child.ParentObjectID
AND Parent.ObjectID = Child.ParentObjectID
WHERE Child.[Matched] = 0 AND Parent.[Matched] = 1
UPDATE tempdb.dbo.RG_AllObjects_v4
SET EntryDateTime = GETUTCDATE(),
[Matched] = 0,
UserName = NULL,
ObjectName = NewObjects.ObjectName,
SchemaName = NewObjects.SchemaName,
TypeOfAction = 'Renamed',
ModifyDate = NewObjects.ModifyDate
FROM tempdb.dbo.RG_AllObjects_v4 CurrentObjects
INNER JOIN #CurrentDatabaseObjects NewObjects
ON CurrentObjects.DatabaseID = NewObjects.DatabaseID
AND CurrentObjects.ObjectID = NewObjects.ObjectID
AND CurrentObjects.ObjectType = NewObjects.ObjectType
WHERE (CurrentObjects.ObjectName <> NewObjects.ObjectName
OR COALESCE(CurrentObjects.SchemaName, '') <> COALESCE(NewObjects.SchemaName, ''))
UPDATE Child
SET UserName = Parent.UserName,
[Matched] = 1
FROM tempdb.dbo.RG_AllObjects_v4 Child
INNER JOIN tempdb.dbo.RG_AllObjects_v4 Parent
ON Parent.ObjectID = Child.ParentObjectID
AND Parent.ObjectID = Child.ParentObjectID
WHERE Child.[Matched] = 0 AND Parent.[Matched] = 1
UPDATE tempdb.dbo.RG_AllObjects_v4
SET EntryDateTime = GETUTCDATE(),
[Matched] = 0,
UserName = NULL,
ObjectName = NewObjects.ObjectName,
SchemaName = NewObjects.SchemaName,
TypeOfAction = 'Renamed',
ModifyDate = NewObjects.ModifyDate
FROM tempdb.dbo.RG_AllObjects_v4 CurrentObjects
INNER JOIN #CurrentDatabaseObjects NewObjects
ON CurrentObjects.DatabaseID = NewObjects.DatabaseID
AND CurrentObjects.ObjectID = NewObjects.ObjectID
AND CurrentObjects.ObjectType = NewObjects.ObjectType
WHERE (CurrentObjects.ObjectName <> NewObjects.ObjectName
OR COALESCE(CurrentObjects.SchemaName, '') <> COALESCE(NewObjects.SchemaName, ''))