You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-- Detect distributed deadlock and return set of process involed in deadlock. If there is no deadlock then this view ias empty.
1993
+
--
1994
+
-- This query is based on the algorithm described by Knuth for detecting a cycle in a linked list. In one column, keep track of the children,
1995
+
-- the children's children, the children's children's children, etc. In another column, keep track of the grandchildren, the grandchildren's grandchildren,
1996
+
-- the grandchildren's grandchildren's grandchildren, etc.
1997
+
--
1998
+
-- For the initial selection, the distance between Child and Grandchild columns is 1. Every selection from union all increases the depth of Child by 1, and that of Grandchild by 2.
1999
+
-- The distance between them increases by 1.
2000
+
--
2001
+
-- If there is any loop, since the distance only increases by 1 each time, at some point after Child is in the loop, the distance will be a multiple of the cycle length.
2002
+
-- When that happens, the Child and the Grandchild columns are the same. Use that as an additional condition to stop the recursion, and detect it in the rest of your code as an error.
2003
+
CREATEVIEWdeadlockAS
2004
+
WITH RECURSIVE LinkTable AS (SELECT wait AS Parent, hold AS Child FROMshardman.deserialize_lock_graph(shardman.global_lock_graph())),
0 commit comments