From cffc3d7a774c6f96f5983b1fdf4b40a4b840e0aa Mon Sep 17 00:00:00 2001 From: Leonid Borchuk Date: Fri, 20 Nov 2026 11:56:12 +0300 Subject: [PATCH] Fix flaky bfv_cte test The Share Input Scan part of bfv_cte checks the SISC debug LOG messages from seg2 in the order they appear in the client output. These messages are written by different QE processes, the SISC writer and one or two readers, and reach the client through separate QE connections, so the order in which the QD relays them is not deterministic. The test then fails now and then, e.g. with the ORCA plan, where one reader's "wrote notify_done" can arrive before the other reader's "initialized xslice state": -LOG: SISC (shareid=0, slice={2|4}): initialized xslice state LOG: SISC READER (shareid=0, slice={2|4}): wrote notify_done +LOG: SISC (shareid=0, slice={2|4}): initialized xslice state LOG: SISC READER (shareid=0, slice={2|4}): wrote notify_done Print the LOG lines sorted, followed by the rest of the output. The test still checks which slice initializes the shared state and that every reader and the writer log the expected steps; the order between processes was never guaranteed anyway. Co-Authored-By: Claude Opus 5.5 --- src/test/regress/expected/bfv_cte.out | 19 +++++++++++-------- .../regress/expected/bfv_cte_optimizer.out | 17 ++++++++++------- src/test/regress/sql/bfv_cte.sql | 7 +++++-- 3 files changed, 26 insertions(+), 17 deletions(-) diff --git a/src/test/regress/expected/bfv_cte.out b/src/test/regress/expected/bfv_cte.out index 2d2dc5ccb20..f955f247464 100644 --- a/src/test/regress/expected/bfv_cte.out +++ b/src/test/regress/expected/bfv_cte.out @@ -490,18 +490,21 @@ select wait_until_query_output_to_file('/tmp/bfv_cte.out'); -- s/slice=4\): initialized xslice state/slice={2|4}): initialized xslice state/g -- s/One-Time Filter: \(gp_execution_segment\(\) =\d+\)/One-Time Filter: \(gp_execution_segment\(\) =#\)/ -- end_matchsubs --- Filter out irrelevant LOG messages from segments other than seg2. -\! cat /tmp/bfv_cte.out | grep -P '^(?!LOG)|^(LOG.*seg2)' | grep -vP 'LOG.*fault|decreased xslice state refcount' -SET -SET -SET +-- Filter out irrelevant LOG messages from segments other than seg2. The +-- LOG messages come from different QE processes over separate connections, +-- so the order in which the QD relays them is not deterministic. Print +-- them sorted, followed by the rest of the output. +\! grep -P '^LOG.*seg2' /tmp/bfv_cte.out | grep -vP 'LOG.*fault|decreased xslice state refcount' | LC_ALL=C sort; grep -vP '^LOG' /tmp/bfv_cte.out LOG: SISC (shareid=0, slice=2): initialized xslice state (seg2 slice2 127.0.1.1:7004 pid=1049102) +LOG: SISC (shareid=0, slice=4): removed xslice state (seg2 slice4 127.0.1.1:7004 pid=1049114) LOG: SISC READER (shareid=0, slice=2): wrote notify_done (seg2 slice2 127.0.1.1:7004 pid=1049102) -LOG: SISC WRITER (shareid=0, slice=4): initializing because squelched (seg2 slice4 127.0.1.1:7004 pid=1049114) LOG: SISC WRITER (shareid=0, slice=4): No tuplestore yet, creating tuplestore (seg2 slice4 127.0.1.1:7004 pid=1049114) -LOG: SISC WRITER (shareid=0, slice=4): wrote notify_ready (seg2 slice4 127.0.1.1:7004 pid=1049114) LOG: SISC WRITER (shareid=0, slice=4): got DONE message from 1 readers (seg2 slice4 127.0.1.1:7004 pid=1049114) -LOG: SISC (shareid=0, slice=4): removed xslice state (seg2 slice4 127.0.1.1:7004 pid=1049114) +LOG: SISC WRITER (shareid=0, slice=4): initializing because squelched (seg2 slice4 127.0.1.1:7004 pid=1049114) +LOG: SISC WRITER (shareid=0, slice=4): wrote notify_ready (seg2 slice4 127.0.1.1:7004 pid=1049114) +SET +SET +SET SET a | a ---+--- diff --git a/src/test/regress/expected/bfv_cte_optimizer.out b/src/test/regress/expected/bfv_cte_optimizer.out index 211a7838d4d..ef3e3ead4e2 100644 --- a/src/test/regress/expected/bfv_cte_optimizer.out +++ b/src/test/regress/expected/bfv_cte_optimizer.out @@ -510,18 +510,21 @@ DETAIL: Falling back to Postgres-based planner because GPORCA does not support -- s/slice=4\): initialized xslice state/slice={2|4}): initialized xslice state/g -- s/One-Time Filter: \(gp_execution_segment\(\) =\d+\)/One-Time Filter: \(gp_execution_segment\(\) =#\)/ -- end_matchsubs --- Filter out irrelevant LOG messages from segments other than seg2. -\! cat /tmp/bfv_cte.out | grep -P '^(?!LOG)|^(LOG.*seg2)' | grep -vP 'LOG.*fault|decreased xslice state refcount' -SET -SET -SET +-- Filter out irrelevant LOG messages from segments other than seg2. The +-- LOG messages come from different QE processes over separate connections, +-- so the order in which the QD relays them is not deterministic. Print +-- them sorted, followed by the rest of the output. +\! grep -P '^LOG.*seg2' /tmp/bfv_cte.out | grep -vP 'LOG.*fault|decreased xslice state refcount' | LC_ALL=C sort; grep -vP '^LOG' /tmp/bfv_cte.out +LOG: SISC (shareid=0, slice=1): removed xslice state (seg2 slice1 127.0.1.1:7004 pid=1048234) LOG: SISC (shareid=0, slice=2): initialized xslice state (seg2 slice2 127.0.1.1:7004 pid=1048240) LOG: SISC READER (shareid=0, slice=2): wrote notify_done (seg2 slice2 127.0.1.1:7004 pid=1048240) LOG: SISC READER (shareid=0, slice=4): wrote notify_done (seg2 slice4 127.0.1.1:7004 pid=1048252) LOG: SISC WRITER (shareid=0, slice=1): No tuplestore yet, creating tuplestore (seg2 slice1 127.0.1.1:7004 pid=1048234) -LOG: SISC WRITER (shareid=0, slice=1): wrote notify_ready (seg2 slice1 127.0.1.1:7004 pid=1048234) LOG: SISC WRITER (shareid=0, slice=1): got DONE message from 2 readers (seg2 slice1 127.0.1.1:7004 pid=1048234) -LOG: SISC (shareid=0, slice=1): removed xslice state (seg2 slice1 127.0.1.1:7004 pid=1048234) +LOG: SISC WRITER (shareid=0, slice=1): wrote notify_ready (seg2 slice1 127.0.1.1:7004 pid=1048234) +SET +SET +SET SET a | a ---+--- diff --git a/src/test/regress/sql/bfv_cte.sql b/src/test/regress/sql/bfv_cte.sql index 6a7b15874ae..558bcc662e8 100644 --- a/src/test/regress/sql/bfv_cte.sql +++ b/src/test/regress/sql/bfv_cte.sql @@ -326,8 +326,11 @@ select wait_until_query_output_to_file('/tmp/bfv_cte.out'); -- s/slice=4\): initialized xslice state/slice={2|4}): initialized xslice state/g -- s/One-Time Filter: \(gp_execution_segment\(\) =\d+\)/One-Time Filter: \(gp_execution_segment\(\) =#\)/ -- end_matchsubs --- Filter out irrelevant LOG messages from segments other than seg2. -\! cat /tmp/bfv_cte.out | grep -P '^(?!LOG)|^(LOG.*seg2)' | grep -vP 'LOG.*fault|decreased xslice state refcount' +-- Filter out irrelevant LOG messages from segments other than seg2. The +-- LOG messages come from different QE processes over separate connections, +-- so the order in which the QD relays them is not deterministic. Print +-- them sorted, followed by the rest of the output. +\! grep -P '^LOG.*seg2' /tmp/bfv_cte.out | grep -vP 'LOG.*fault|decreased xslice state refcount' | LC_ALL=C sort; grep -vP '^LOG' /tmp/bfv_cte.out -- cleanup select gp_inject_fault_infinite('all', 'reset', dbid) from gp_segment_configuration;