pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jeff Davis <pgsql@j-davis.com>
To: pgsql-bugs@postgresql.org
Subject: Query stuck with wait event IPC / ParallelFinish
Date: Mon, 04 Mar 2024 20:12:28 -0800
Message-ID: <0f64b4c7fc200890f2055ce4d6650e9c2191fac2.camel@j-davis.com> (raw)


If the attached test patch is applied (no code changes) to master, and
the "amcheck" target is run with debug_parallel_query = regress, I see
the following stuck query:

# select
    application_name,
    now() - state_change AS duration,
    wait_event_type,
    wait_event,
    state,
    query
  from pg_stat_activity
  where pid<>pg_backend_pid() and backend_type='client backend';

application_name | 004_verify_nbtree_unique.pl
duration         | 00:12:29.456255
wait_event_type  | IPC
wait_event       | ParallelFinish
state            | active
query            | DELETE FROM bttest_unique3 WHERE 380 <= i
                     AND i <= 420;

I found this while fixing a parallel query problem with 2af07e2f74, but
the problem can be observed on an earlier version of master as well
(2c29e7fc95) so it's unrelated to my change.

I haven't investigated much, but I don't see an explanation other than
a bug. It reproduces on my local machine consistently.

Regards,
	Jeff Davis

Attachments:

v1-0001-IPC-ParallelFinish-not-finishing.patch (text/x-patch, 5.7K) download From eea9bdc454d803c21c2c475eaeb2aa7521332337 Mon Sep 17 00:00:00 2001 From: Jeff Davis <jeff@j-davis.com> Date: Mon, 4 Mar 2024 19:44:47 -0800 Subject: [PATCH v1] IPC ParallelFinish not finishing --- contrib/amcheck/t/004_verify_nbtree_unique.pl | 33 +++++++++++-------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/contrib/amcheck/t/004_verify_nbtree_unique.pl b/contrib/amcheck/t/004_verify_nbtree_unique.pl index 3f474a158a..4b704e6815 100644 --- a/contrib/amcheck/t/004_verify_nbtree_unique.pl +++ b/contrib/amcheck/t/004_verify_nbtree_unique.pl @@ -20,8 +20,11 @@ $node->safe_psql( 'postgres', q( CREATE EXTENSION amcheck; + CREATE SCHEMA test_amcheck; + SET search_path = test_amcheck; + CREATE FUNCTION ok_cmp (int4, int4) - RETURNS int LANGUAGE sql AS + RETURNS int LANGUAGE sql SET search_path = test_amcheck AS $$ SELECT CASE WHEN $1 < $2 THEN -1 @@ -34,7 +37,7 @@ $node->safe_psql( --- Check 1: uniqueness violation. --- CREATE FUNCTION ok_cmp1 (int4, int4) - RETURNS int LANGUAGE sql AS + RETURNS int LANGUAGE sql SET search_path = test_amcheck AS $$ SELECT ok_cmp($1, $2); $$; @@ -43,7 +46,7 @@ $node->safe_psql( --- Make values 768 and 769 look equal. --- CREATE FUNCTION bad_cmp1 (int4, int4) - RETURNS int LANGUAGE sql AS + RETURNS int LANGUAGE sql SET search_path = test_amcheck AS $$ SELECT CASE WHEN ($1 = 768 AND $2 = 769) OR @@ -56,13 +59,13 @@ $node->safe_psql( --- Check 2: uniqueness violation without deduplication. --- CREATE FUNCTION ok_cmp2 (int4, int4) - RETURNS int LANGUAGE sql AS + RETURNS int LANGUAGE sql SET search_path = test_amcheck AS $$ SELECT ok_cmp($1, $2); $$; CREATE FUNCTION bad_cmp2 (int4, int4) - RETURNS int LANGUAGE sql AS + RETURNS int LANGUAGE sql SET search_path = test_amcheck AS $$ SELECT CASE WHEN $1 = $2 AND $1 = 400 THEN -1 @@ -74,13 +77,13 @@ $node->safe_psql( --- Check 3: uniqueness violation with deduplication. --- CREATE FUNCTION ok_cmp3 (int4, int4) - RETURNS int LANGUAGE sql AS + RETURNS int LANGUAGE sql SET search_path = test_amcheck AS $$ SELECT ok_cmp($1, $2); $$; CREATE FUNCTION bad_cmp3 (int4, int4) - RETURNS int LANGUAGE sql AS + RETURNS int LANGUAGE sql SET search_path = test_amcheck AS $$ SELECT bad_cmp2($1, $2); $$; @@ -142,7 +145,7 @@ my ($result, $stdout, $stderr); # We have not yet broken the index, so we should get no corruption $result = $node->safe_psql( 'postgres', q( - SELECT bt_index_check('bttest_unique_idx1', true, true); + SELECT bt_index_check('test_amcheck.bttest_unique_idx1', true, true); )); is($result, '', 'run amcheck on non-broken bttest_unique_idx1'); @@ -150,6 +153,7 @@ is($result, '', 'run amcheck on non-broken bttest_unique_idx1'); # values to be equal. $node->safe_psql( 'postgres', q( + SET search_path = test_amcheck; UPDATE pg_catalog.pg_amproc SET amproc = 'bad_cmp1'::regproc WHERE amproc = 'ok_cmp1'::regproc; @@ -157,7 +161,7 @@ $node->safe_psql( ($result, $stdout, $stderr) = $node->psql( 'postgres', q( - SELECT bt_index_check('bttest_unique_idx1', true, true); + SELECT bt_index_check('test_amcheck.bttest_unique_idx1', true, true); )); ok( $stderr =~ /index uniqueness is violated for index "bttest_unique_idx1"/, 'detected uniqueness violation for index "bttest_unique_idx1"'); @@ -175,13 +179,14 @@ ok( $stderr =~ /index uniqueness is violated for index "bttest_unique_idx1"/, # but no uniqueness violation. ($result, $stdout, $stderr) = $node->psql( 'postgres', q( - SELECT bt_index_check('bttest_unique_idx2', true, true); + SELECT bt_index_check('test_amcheck.bttest_unique_idx2', true, true); )); ok( $stderr =~ /item order invariant violated for index "bttest_unique_idx2"/, 'detected item order invariant violation for index "bttest_unique_idx2"'); $node->safe_psql( 'postgres', q( + SET search_path = test_amcheck; UPDATE pg_catalog.pg_amproc SET amproc = 'ok_cmp2'::regproc WHERE amproc = 'bad_cmp2'::regproc; @@ -189,7 +194,7 @@ $node->safe_psql( ($result, $stdout, $stderr) = $node->psql( 'postgres', q( - SELECT bt_index_check('bttest_unique_idx2', true, true); + SELECT bt_index_check('test_amcheck.bttest_unique_idx2', true, true); )); ok( $stderr =~ /index uniqueness is violated for index "bttest_unique_idx2"/, 'detected uniqueness violation for index "bttest_unique_idx2"'); @@ -206,7 +211,7 @@ ok( $stderr =~ /index uniqueness is violated for index "bttest_unique_idx2"/, # but no uniqueness violation. ($result, $stdout, $stderr) = $node->psql( 'postgres', q( - SELECT bt_index_check('bttest_unique_idx3', true, true); + SELECT bt_index_check('test_amcheck.bttest_unique_idx3', true, true); )); ok( $stderr =~ /item order invariant violated for index "bttest_unique_idx3"/, 'detected item order invariant violation for index "bttest_unique_idx3"'); @@ -215,6 +220,7 @@ ok( $stderr =~ /item order invariant violated for index "bttest_unique_idx3"/, # with different visibility. $node->safe_psql( 'postgres', q( + SET search_path = test_amcheck; DELETE FROM bttest_unique3 WHERE 380 <= i AND i <= 420; INSERT INTO bttest_unique3 (SELECT * FROM generate_series(380, 420)); INSERT INTO bttest_unique3 VALUES (400); @@ -228,6 +234,7 @@ $node->safe_psql( $node->safe_psql( 'postgres', q( + SET search_path = test_amcheck; UPDATE pg_catalog.pg_amproc SET amproc = 'ok_cmp3'::regproc WHERE amproc = 'bad_cmp3'::regproc; @@ -235,7 +242,7 @@ $node->safe_psql( ($result, $stdout, $stderr) = $node->psql( 'postgres', q( - SELECT bt_index_check('bttest_unique_idx3', true, true); + SELECT bt_index_check('test_amcheck.bttest_unique_idx3', true, true); )); ok( $stderr =~ /index uniqueness is violated for index "bttest_unique_idx3"/, 'detected uniqueness violation for index "bttest_unique_idx3"'); -- 2.34.1

Message-ID: <0f64b4c7fc200890f2055ce4d6650e9c2191fac2.camel@j-davis.com>
Permalink:  ../0f64b4c7fc200890f2055ce4d6650e9c2191fac2.camel@j-davis.com/
Also on:    postgresql.org/message-id/0f64b4c7fc200890f2055ce4d6650e9c2191fac2.camel@j-davis.com

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: pgsql@j-davis.com
  Subject: Re: Query stuck with wait event IPC / ParallelFinish
  In-Reply-To: <0f64b4c7fc200890f2055ce4d6650e9c2191fac2.camel@j-davis.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox