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
Fix nondeterministic age_global_graph regression test (#2365)
The age_global_graph test had two issues that could cause intermittent
failures:
1. Nondeterministic warning output: The graph_stats() call on a graph
with deliberately deleted vertices produces WARNING messages for
dangling edges. These warnings are emitted by iterating edge label
tables (knows, stalks), and the iteration order is not guaranteed.
Since PostgreSQL WARNING messages cannot be caught or counted from
SQL (only ERROR and above are catchable via PL/pgSQL exception
handling), we suppress them with SET client_min_messages = error.
The suppressed warnings are documented verbatim in comments. The
graph_stats() result row still validates correct dangling-edge
handling.
2. Nondeterministic row ordering: Multiple MATCH...RETURN queries
returned multi-row results without ORDER BY, relying on scan order.
Added ORDER BY id(u), id(v), id(e), id(n), or id(a) as appropriate
to all MATCH...RETURN queries for future-proofing, even those
currently returning a single row.
Files changed:
regress/sql/age_global_graph.sql
regress/expected/age_global_graph.out
Co-authored-by: GitHub Copilot <noreply@github.com>
@@ -193,14 +193,14 @@ SELECT * FROM cypher('ag_graph_2', $$ CREATE (:Person) $$) as (v agtype);
193
193
(0 rows)
194
194
195
195
---adding edges between nodes
196
-
SELECT * FROM cypher('ag_graph_2', $$ MATCH (a:Person), (b:Person) WHERE a.name = 'A' AND b.name = 'B' CREATE (a)-[e:RELTYPE]->(b) RETURN e $$) as (e agtype);
196
+
SELECT * FROM cypher('ag_graph_2', $$ MATCH (a:Person), (b:Person) WHERE a.name = 'A' AND b.name = 'B' CREATE (a)-[e:RELTYPE]->(b) RETURN e ORDER BY id(e) $$) as (e agtype);
197
197
e
198
198
---
199
199
(0 rows)
200
200
201
201
--checking if vertex stats have been updated along with the new label
202
202
--should return 3 vertices
203
-
SELECT * FROM cypher('ag_graph_1', $$ MATCH (n) RETURN vertex_stats(n) $$) AS (result agtype);
203
+
SELECT * FROM cypher('ag_graph_1', $$ MATCH (n) RETURN vertex_stats(n) ORDER BY id(n) $$) AS (result agtype);
SELECT*FROM cypher('ag_graph_3', $$ MATCH (u) RETURN vertex_stats(u) $$) AS (result agtype);
59
-
SELECT*FROM cypher('ag_graph_2', $$ MATCH (u) RETURN vertex_stats(u) $$) AS (result agtype);
60
-
SELECT*FROM cypher('ag_graph_1', $$ MATCH (u) RETURN vertex_stats(u) $$) AS (result agtype);
58
+
SELECT*FROM cypher('ag_graph_3', $$ MATCH (u) RETURN vertex_stats(u) ORDER BY id(u) $$) AS (result agtype);
59
+
SELECT*FROM cypher('ag_graph_2', $$ MATCH (u) RETURN vertex_stats(u) ORDER BY id(u) $$) AS (result agtype);
60
+
SELECT*FROM cypher('ag_graph_1', $$ MATCH (u) RETURN vertex_stats(u) ORDER BY id(u) $$) AS (result agtype);
61
61
62
62
-- delete all graph contexts
63
63
-- should return true
@@ -81,14 +81,14 @@ SELECT * FROM cypher('ag_graph_1', $$ CREATE (n), (m) $$) as (v agtype);
81
81
SELECT*FROM cypher('ag_graph_2', $$ CREATE (:Person) $$) as (v agtype);
82
82
83
83
---adding edges between nodes
84
-
SELECT*FROM cypher('ag_graph_2', $$ MATCH (a:Person), (b:Person) WHEREa.name='A'ANDb.name='B' CREATE (a)-[e:RELTYPE]->(b) RETURN e $$) as (e agtype);
84
+
SELECT*FROM cypher('ag_graph_2', $$ MATCH (a:Person), (b:Person) WHEREa.name='A'ANDb.name='B' CREATE (a)-[e:RELTYPE]->(b) RETURN e ORDER BY id(e) $$) as (e agtype);
85
85
86
86
--checking if vertex stats have been updated along with the new label
87
87
--should return 3 vertices
88
-
SELECT*FROM cypher('ag_graph_1', $$ MATCH (n) RETURN vertex_stats(n) $$) AS (result agtype);
88
+
SELECT*FROM cypher('ag_graph_1', $$ MATCH (n) RETURN vertex_stats(n) ORDER BY id(n) $$) AS (result agtype);
89
89
90
90
--should return 1 vertice and 1 label
91
-
SELECT*FROM cypher('ag_graph_2', $$ MATCH (a) RETURN vertex_stats(a) $$) AS (result agtype);
91
+
SELECT*FROM cypher('ag_graph_2', $$ MATCH (a) RETURN vertex_stats(a) ORDER BY id(a) $$) AS (result agtype);
92
92
93
93
--
94
94
-- graph_stats command
@@ -109,9 +109,9 @@ SELECT * FROM cypher('ag_graph_1', $$ MATCH (u)-[]->(v) SET u.id = id(u)
109
109
SETv.id= id(v)
110
110
SETu.name='u'
111
111
SETv.name='v'
112
-
RETURN u,v $$) AS (u agtype, v agtype);
112
+
RETURN u,v ORDER BY id(u), id(v) $$) AS (u agtype, v agtype);
113
113
SELECT*FROM cypher('ag_graph_1', $$ MATCH (u)-[]->(v) MERGE (v)-[:stalks]->(u) $$) AS (result agtype);
114
-
SELECT*FROM cypher('ag_graph_1', $$ MATCH (u)-[e]->(v) RETURN u, e, v $$) AS (u agtype, e agtype, v agtype);
114
+
SELECT*FROM cypher('ag_graph_1', $$ MATCH (u)-[e]->(v) RETURN u, e, v ORDER BY id(e) $$) AS (u agtype, e agtype, v agtype);
115
115
-- what is there now?
116
116
SELECT*FROM cypher('ag_graph_1', $$ RETURN graph_stats('ag_graph_1') $$) AS (result agtype);
117
117
-- remove some vertices
@@ -121,8 +121,25 @@ DELETE FROM ag_graph_1._ag_label_vertex WHERE id::text = '281474976710662';
0 commit comments