Skip to content

Commit 571c198

Browse files
authored
Fix issue 2245 - Creating more than 41 vlabels causes crash in drop_graph (#2248)
Fixed issue 2245 - Creating more than 41 vlabels causes drop_grapth to fail with "label (relation) cache corrupted" and crashing out on the following command. This was due to corruption of the label_relation_cache during the HASH_DELETE process. As the issue was with a cache flush routine, it was necessary to fix them all. Here is the list of the flush functions that were fixed - static void flush_graph_name_cache(void) static void flush_graph_namespace_cache(void) static void flush_label_name_graph_cache(void) static void flush_label_graph_oid_cache(void) static void flush_label_relation_cache(void) static void flush_label_seq_name_graph_cache(void) Added regression tests. modified: regress/expected/catalog.out modified: regress/sql/catalog.sql modified: src/backend/utils/cache/ag_cache.c
1 parent 190354c commit 571c198

File tree

3 files changed

+241
-116
lines changed

3 files changed

+241
-116
lines changed

regress/expected/catalog.out

Lines changed: 140 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,146 @@ NOTICE: graph does not exist
457457
(1 row)
458458

459459
DROP FUNCTION raise_notice(TEXT);
460-
-- dropping the graph
460+
--
461+
-- Fix issue 2245 - Creating more than 41 vlabels causes drop_graph to fail with
462+
-- label (relation) cache corrupted
463+
--
464+
-- this result will change if another graph was created prior to this point.
465+
SELECT count(*) FROM ag_label;
466+
count
467+
-------
468+
2
469+
(1 row)
470+
471+
SELECT * FROM create_graph('issue_2245');
472+
NOTICE: graph "issue_2245" has been created
473+
create_graph
474+
--------------
475+
476+
(1 row)
477+
478+
SELECT * FROM cypher('issue_2245', $$
479+
CREATE (a1:Part1 {part_num: '123'}), (a2:Part2 {part_num: '345'}), (a3:Part3 {part_num: '456'}),
480+
(a4:Part4 {part_num: '789'}), (a5:Part5 {part_num: '123'}), (a6:Part6 {part_num: '345'}),
481+
(a7:Part7 {part_num: '456'}), (a8:Part8 {part_num: '789'}), (a9:Part9 {part_num: '123'}),
482+
(a10:Part10 {part_num: '345'}), (a11:Part11 {part_num: '456'}), (a12:Part12 {part_num: '789'}),
483+
(a13:Part13 {part_num: '123'}), (a14:Part14 {part_num: '345'}), (a15:Part15 {part_num: '456'}),
484+
(a16:Part16 {part_num: '789'}), (a17:Part17 {part_num: '123'}), (a18:Part18 {part_num: '345'}),
485+
(a19:Part19 {part_num: '456'}), (a20:Part20 {part_num: '789'}), (a21:Part21 {part_num: '123'}),
486+
(a22:Part22 {part_num: '345'}), (a23:Part23 {part_num: '456'}), (a24:Part24 {part_num: '789'}),
487+
(a25:Part25 {part_num: '123'}), (a26:Part26 {part_num: '345'}), (a27:Part27 {part_num: '456'}),
488+
(a28:Part28 {part_num: '789'}), (a29:Part29 {part_num: '789'}), (a30:Part30 {part_num: '123'}),
489+
(a31:Part31 {part_num: '345'}), (a32:Part32 {part_num: '456'}), (a33:Part33 {part_num: '789'}),
490+
(a34:Part34 {part_num: '123'}), (a35:Part35 {part_num: '345'}), (a36:Part36 {part_num: '456'}),
491+
(a37:Part37 {part_num: '789'}), (a38:Part38 {part_num: '123'}), (a39:Part39 {part_num: '345'}),
492+
(a40:Part40 {part_num: '456'}), (a41:Part41 {part_num: '789'}), (a42:Part42 {part_num: '345'}),
493+
(a43:Part43 {part_num: '456'}), (a44:Part44 {part_num: '789'}), (a45:Part45 {part_num: '456'}),
494+
(a46:Part46 {part_num: '789'}), (a47:Part47 {part_num: '456'}), (a48:Part48 {part_num: '789'}),
495+
(a49:Part49 {part_num: '789'}), (a50:Part50 {part_num: '456'}), (a51:Part51 {part_num: '789'})
496+
$$) AS (result agtype);
497+
result
498+
--------
499+
(0 rows)
500+
501+
SELECT count(*) FROM ag_label;
502+
count
503+
-------
504+
55
505+
(1 row)
506+
507+
SELECT drop_graph('issue_2245', true);
508+
NOTICE: drop cascades to 53 other objects
509+
DETAIL: drop cascades to table issue_2245._ag_label_vertex
510+
drop cascades to table issue_2245._ag_label_edge
511+
drop cascades to table issue_2245."Part1"
512+
drop cascades to table issue_2245."Part2"
513+
drop cascades to table issue_2245."Part3"
514+
drop cascades to table issue_2245."Part4"
515+
drop cascades to table issue_2245."Part5"
516+
drop cascades to table issue_2245."Part6"
517+
drop cascades to table issue_2245."Part7"
518+
drop cascades to table issue_2245."Part8"
519+
drop cascades to table issue_2245."Part9"
520+
drop cascades to table issue_2245."Part10"
521+
drop cascades to table issue_2245."Part11"
522+
drop cascades to table issue_2245."Part12"
523+
drop cascades to table issue_2245."Part13"
524+
drop cascades to table issue_2245."Part14"
525+
drop cascades to table issue_2245."Part15"
526+
drop cascades to table issue_2245."Part16"
527+
drop cascades to table issue_2245."Part17"
528+
drop cascades to table issue_2245."Part18"
529+
drop cascades to table issue_2245."Part19"
530+
drop cascades to table issue_2245."Part20"
531+
drop cascades to table issue_2245."Part21"
532+
drop cascades to table issue_2245."Part22"
533+
drop cascades to table issue_2245."Part23"
534+
drop cascades to table issue_2245."Part24"
535+
drop cascades to table issue_2245."Part25"
536+
drop cascades to table issue_2245."Part26"
537+
drop cascades to table issue_2245."Part27"
538+
drop cascades to table issue_2245."Part28"
539+
drop cascades to table issue_2245."Part29"
540+
drop cascades to table issue_2245."Part30"
541+
drop cascades to table issue_2245."Part31"
542+
drop cascades to table issue_2245."Part32"
543+
drop cascades to table issue_2245."Part33"
544+
drop cascades to table issue_2245."Part34"
545+
drop cascades to table issue_2245."Part35"
546+
drop cascades to table issue_2245."Part36"
547+
drop cascades to table issue_2245."Part37"
548+
drop cascades to table issue_2245."Part38"
549+
drop cascades to table issue_2245."Part39"
550+
drop cascades to table issue_2245."Part40"
551+
drop cascades to table issue_2245."Part41"
552+
drop cascades to table issue_2245."Part42"
553+
drop cascades to table issue_2245."Part43"
554+
drop cascades to table issue_2245."Part44"
555+
drop cascades to table issue_2245."Part45"
556+
drop cascades to table issue_2245."Part46"
557+
drop cascades to table issue_2245."Part47"
558+
drop cascades to table issue_2245."Part48"
559+
drop cascades to table issue_2245."Part49"
560+
drop cascades to table issue_2245."Part50"
561+
drop cascades to table issue_2245."Part51"
562+
NOTICE: graph "issue_2245" has been dropped
563+
drop_graph
564+
------------
565+
566+
(1 row)
567+
568+
-- this result should be the same as the one before the create_graph
569+
SELECT count(*) FROM ag_label;
570+
count
571+
-------
572+
2
573+
(1 row)
574+
575+
-- create the graph again
576+
SELECT * FROM create_graph('issue_2245');
577+
NOTICE: graph "issue_2245" has been created
578+
create_graph
579+
--------------
580+
581+
(1 row)
582+
583+
SELECT count(*) FROM ag_label;
584+
count
585+
-------
586+
4
587+
(1 row)
588+
589+
-- dropping the graphs
590+
SELECT drop_graph('issue_2245', true);
591+
NOTICE: drop cascades to 2 other objects
592+
DETAIL: drop cascades to table issue_2245._ag_label_vertex
593+
drop cascades to table issue_2245._ag_label_edge
594+
NOTICE: graph "issue_2245" has been dropped
595+
drop_graph
596+
------------
597+
598+
(1 row)
599+
461600
SELECT drop_graph('graph', true);
462601
NOTICE: drop cascades to 2 other objects
463602
DETAIL: drop cascades to table graph._ag_label_vertex

regress/sql/catalog.sql

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,5 +193,45 @@ SELECT raise_notice('graph1');
193193

194194
DROP FUNCTION raise_notice(TEXT);
195195

196-
-- dropping the graph
196+
--
197+
-- Fix issue 2245 - Creating more than 41 vlabels causes drop_graph to fail with
198+
-- label (relation) cache corrupted
199+
--
200+
201+
-- this result will change if another graph was created prior to this point.
202+
SELECT count(*) FROM ag_label;
203+
204+
SELECT * FROM create_graph('issue_2245');
205+
SELECT * FROM cypher('issue_2245', $$
206+
CREATE (a1:Part1 {part_num: '123'}), (a2:Part2 {part_num: '345'}), (a3:Part3 {part_num: '456'}),
207+
(a4:Part4 {part_num: '789'}), (a5:Part5 {part_num: '123'}), (a6:Part6 {part_num: '345'}),
208+
(a7:Part7 {part_num: '456'}), (a8:Part8 {part_num: '789'}), (a9:Part9 {part_num: '123'}),
209+
(a10:Part10 {part_num: '345'}), (a11:Part11 {part_num: '456'}), (a12:Part12 {part_num: '789'}),
210+
(a13:Part13 {part_num: '123'}), (a14:Part14 {part_num: '345'}), (a15:Part15 {part_num: '456'}),
211+
(a16:Part16 {part_num: '789'}), (a17:Part17 {part_num: '123'}), (a18:Part18 {part_num: '345'}),
212+
(a19:Part19 {part_num: '456'}), (a20:Part20 {part_num: '789'}), (a21:Part21 {part_num: '123'}),
213+
(a22:Part22 {part_num: '345'}), (a23:Part23 {part_num: '456'}), (a24:Part24 {part_num: '789'}),
214+
(a25:Part25 {part_num: '123'}), (a26:Part26 {part_num: '345'}), (a27:Part27 {part_num: '456'}),
215+
(a28:Part28 {part_num: '789'}), (a29:Part29 {part_num: '789'}), (a30:Part30 {part_num: '123'}),
216+
(a31:Part31 {part_num: '345'}), (a32:Part32 {part_num: '456'}), (a33:Part33 {part_num: '789'}),
217+
(a34:Part34 {part_num: '123'}), (a35:Part35 {part_num: '345'}), (a36:Part36 {part_num: '456'}),
218+
(a37:Part37 {part_num: '789'}), (a38:Part38 {part_num: '123'}), (a39:Part39 {part_num: '345'}),
219+
(a40:Part40 {part_num: '456'}), (a41:Part41 {part_num: '789'}), (a42:Part42 {part_num: '345'}),
220+
(a43:Part43 {part_num: '456'}), (a44:Part44 {part_num: '789'}), (a45:Part45 {part_num: '456'}),
221+
(a46:Part46 {part_num: '789'}), (a47:Part47 {part_num: '456'}), (a48:Part48 {part_num: '789'}),
222+
(a49:Part49 {part_num: '789'}), (a50:Part50 {part_num: '456'}), (a51:Part51 {part_num: '789'})
223+
$$) AS (result agtype);
224+
225+
SELECT count(*) FROM ag_label;
226+
SELECT drop_graph('issue_2245', true);
227+
228+
-- this result should be the same as the one before the create_graph
229+
SELECT count(*) FROM ag_label;
230+
231+
-- create the graph again
232+
SELECT * FROM create_graph('issue_2245');
233+
SELECT count(*) FROM ag_label;
234+
235+
-- dropping the graphs
236+
SELECT drop_graph('issue_2245', true);
197237
SELECT drop_graph('graph', true);

0 commit comments

Comments
 (0)