Improve contrib/amcheck's tests for CREATE INDEX CONCURRENTLY.
authorTom Lane <[email protected]>
Thu, 28 Oct 2021 15:45:14 +0000 (11:45 -0400)
committerTom Lane <[email protected]>
Thu, 28 Oct 2021 15:45:14 +0000 (11:45 -0400)
commit7f580aa5d88a9b03d66fcb9a1d7c4fcd69d9e126
treee48465514b802cd233456ca22378a9d8aab0dbde
parent46dea2419ee7895a4eb3d048317682e6f18a17e1
Improve contrib/amcheck's tests for CREATE INDEX CONCURRENTLY.

Commits fdd965d07 and 3cd9c3b92 tested CREATE INDEX CONCURRENTLY by
launching two separate pgbench runs concurrently.  This was needed so
that only a single client thread would run CREATE INDEX CONCURRENTLY,
avoiding deadlock between two CICs.  However, there's a better way,
which is to use an advisory lock to prevent concurrent CICs.  That's
better in part because the test code is shorter and more readable, but
mostly because it automatically scales things to launch an appropriate
number of CICs relative to the number of INSERT transactions.
As committed, typically half to three-quarters of the CIC transactions
were pointless because the INSERT transactions had already stopped.

In passing, remove background_pgbench, which was added to support
these tests and isn't needed anymore.  We can always put it back
if we find a use for it later.

Back-patch to v12; older pgbench versions lack the
conditional-execution features needed for this method.

Tom Lane and Andrey Borodin

Discussion: https://postgr.es/m/139687.1635277318@sss.pgh.pa.us
contrib/amcheck/t/002_cic.pl
contrib/amcheck/t/003_cic_2pc.pl
src/test/perl/PostgreSQL/Test/Cluster.pm