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
SELECTshardman.broadcast(poll, ignore_errors => true) INTO graph;
2011
2011
2012
2012
RETURN graph;
2013
2013
END;
2014
2014
$$ LANGUAGE plpgsql;
2015
2015
2016
2016
2017
-
-- Detect distributed deadlock and return set of process involed in deadlock. If there is no deadlock then this view ias empty.
2018
-
--
2019
-
-- 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,
2020
-
-- the children's children, the children's children's children, etc. In another column, keep track of the grandchildren, the grandchildren's grandchildren,
2021
-
-- the grandchildren's grandchildren's grandchildren, etc.
2022
-
--
2023
-
-- 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.
2024
-
-- The distance between them increases by 1.
2025
-
--
2026
-
-- 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.
2027
-
-- 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.
2028
-
CREATEVIEWdeadlockAS
2029
-
WITH RECURSIVE LinkTable AS (SELECT wait AS Parent, hold AS Child FROMshardman.deserialize_lock_graph(shardman.global_lock_graph())),
2017
+
-- Detect distributed deadlock and returns path in the lock graph forming deadlock loop
2018
+
CREATEFUNCTIONdetect_deadlock(lock_graph text) RETURNS shardman.process[] AS $$
2019
+
WITH RECURSIVE LinkTable AS (SELECT wait AS Parent, hold AS Child FROMshardman.deserialize_lock_graph(lock_graph)),
0 commit comments