From: Tom Lane <tgl@sss.pgh.pa.us>
To: Noah Misch <noah@leadboat.com>
Cc: Andrey Borodin <x4mmm@yandex-team.ru>
Cc: PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>
Cc: Michael Paquier <michael@paquier.xyz>
Cc: Peter Geoghegan <pg@bowt.ie>
Cc: Andres Freund <andres@anarazel.de>
Subject: Re: conchuela timeouts since 2021-10-09 system upgrade
Date: Tue, 26 Oct 2021 15:41:58 -0400
Message-ID: <139687.1635277318@sss.pgh.pa.us> (raw)
In-Reply-To: <20211026134500.GA128912@rfd.leadboat.com>
References: <20211019030212.GB3403374@rfd.leadboat.com>
<20211024050028.GA3310519@rfd.leadboat.com>
<64835CF9-D9AA-49BF-A685-01C23B1023C1@yandex-team.ru>
<20211024161942.GB3945842@rfd.leadboat.com>
<640FA6DC-A998-4499-B3B4-2773685B8C56@yandex-team.ru>
<3792312.1635119599@sss.pgh.pa.us>
<B5CC4C8F-1B73-4359-AF68-26A08A17BCD1@yandex-team.ru>
<4170532.1635195582@sss.pgh.pa.us>
<20211026015157.GA113335@rfd.leadboat.com>
<52098.1635228234@sss.pgh.pa.us>
<20211026134500.GA128912@rfd.leadboat.com>
Noah Misch <noah@leadboat.com> writes:
> On Tue, Oct 26, 2021 at 02:03:54AM -0400, Tom Lane wrote:
>> Or more
>> practically, use advisory locks in that script to enforce that only one
>> runs at once.
> The author did try that.
Ah, I see: if the other pgbench thread is waiting in pg_advisory_lock,
then it is inside a transaction, so it blocks CIC from completing.
We can get around that though, by using pg_try_advisory_lock and not
proceeding if it fails. The attached POC does this for the 002 test;
it looks like the same thing could be done to 003.
Now the problem with this is it will only work back to v12, because
pgbench lacks the necessary features before that. However, I think
it's worth doing it like this in versions where we can do so, because
of the load-balancing aspect: this won't waste cycles running CICs
after the inserts have stopped, nor vice versa.
Thoughts?
regards, tom lane
Attachments:CIC-test-with-one-pgbench.patch (text/x-diff, 2.1K) downloaddiff --git a/contrib/amcheck/t/002_cic.pl b/contrib/amcheck/t/002_cic.plindex 0b14e66270..1f258dd59d 100644--- a/contrib/amcheck/t/002_cic.pl+++ b/contrib/amcheck/t/002_cic.pl@@ -9,7 +9,7 @@ use Config;
use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
-use Test::More tests => 4;+use Test::More tests => 3;
my ($node, $result);
@@ -25,32 +25,18 @@ $node->safe_psql('postgres', q(CREATE TABLE tbl(i int)));
$node->safe_psql('postgres', q(CREATE INDEX idx ON tbl(i)));
#
-# Stress CIC with pgbench+# Stress CIC with pgbench.+#+# pgbench might try to launch more than one instance of the CIC+# transaction concurrently. That would deadlock, so use an advisory+# lock to ensure only one CIC runs at a time.
#
--# Run background pgbench with CIC. We cannot mix-in this script into single-# pgbench: CIC will deadlock with itself occasionally.-my $pgbench_out = '';-my $pgbench_timer = IPC::Run::timeout(180);-my $pgbench_h = $node->background_pgbench(- '--no-vacuum --client=1 --transactions=200',- {- '002_pgbench_concurrent_cic' => q(- DROP INDEX CONCURRENTLY idx;- CREATE INDEX CONCURRENTLY idx ON tbl(i);- SELECT bt_index_check('idx',true);- )- },- \$pgbench_out,- $pgbench_timer);--# Run pgbench.
$node->pgbench(
'--no-vacuum --client=5 --transactions=200',
0,
[qr{actually processed}],
[qr{^$}],
- 'concurrent INSERTs',+ 'concurrent INSERTs and CIC',
{
'002_pgbench_concurrent_transaction' => q(
BEGIN;
@@ -62,17 +48,17 @@ $node->pgbench(
SAVEPOINT s1;
INSERT INTO tbl VALUES(0);
COMMIT;
+ ),+ '002_pgbench_concurrent_cic' => q(+ SELECT pg_try_advisory_lock(42)::integer AS gotlock \gset+ \if :gotlock+ DROP INDEX CONCURRENTLY idx;+ CREATE INDEX CONCURRENTLY idx ON tbl(i);+ SELECT bt_index_check('idx',true);+ SELECT pg_advisory_unlock(42);+ \endif
)
});
-$pgbench_h->pump_nb;-$pgbench_h->finish();-$result =- ($Config{osname} eq "MSWin32")- ? ($pgbench_h->full_results)[0]- : $pgbench_h->result(0);-is($result, 0, "pgbench with CIC works");--# done
$node->stop;
done_testing();
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: tgl@sss.pgh.pa.us, noah@leadboat.com, x4mmm@yandex-team.ru, pgsql-bugs@lists.postgresql.org, michael@paquier.xyz, pg@bowt.ie, andres@anarazel.de
Subject: Re: conchuela timeouts since 2021-10-09 system upgrade
In-Reply-To: <139687.1635277318@sss.pgh.pa.us>
* 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