I would like to write a query that will display this circle.
It is not always 1 -> 2 -> 3.
For example in our 9 node cluster after removals, additions and rebalances the order is 2 -> 3 -> 4 -> 5 -> 9 -> 6 -> 7 -> 1 -> 8 -> 2.
I found v_internal.VS_NODE_DEPENDENCIES view that can give the pairs of dependent nodes, but has no order to arrange them to predecessors and successors.
In 4 node cluster it is
Code: Select all
with X as (
select d.dependency_id as id,
n.name
from v_internal.VS_NODE_DEPENDENCIES d
join v_internal.VS_NODES n
on d.node_oid = n.oid
where d.dependency_id < (select count(*) from v_internal.VS_NODES)
)
select a.id,
least(a.name, b.name) as node1,
greatest(a.name, b.name) as node2
from X a,
X b
where a.id = b.id
and a.name > b.name
order by 1, 2;
Code: Select all
id | node1 | node2
----+----------------+---------------
0 | v_vdb_node0002 | v_vdb_node0003
1 | v_vdb_node0003 | v_vdb_node0004
2 | v_vdb_node0001 | v_vdb_node0002
3 | v_vdb_node0001 | v_vdb_node0004
(4 rows)
Ideas?
Thank you!