mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-08-24 06:47:18 +02:00
b3b4d8e68a
The five modules in our TAP test framework all had names in the top level namespace. This is unwise because, even though we're not exporting them to CPAN, the names can leak, for example if they are exported by the RPM build process. We therefore move the modules to the PostgreSQL::Test namespace. In the process PostgresNode is renamed to Cluster, and TestLib is renamed to Utils. PostgresVersion becomes simply PostgreSQL::Version, to avoid possible confusion about what it's the version of. Discussion: https://postgr.es/m/aede93a4-7d92-ef26-398f-5094944c2504@dunslane.net Reviewed by Erik Rijkers and Michael Paquier
79 lines
1.7 KiB
Perl
79 lines
1.7 KiB
Perl
|
|
# Copyright (c) 2021, PostgreSQL Global Development Group
|
|
|
|
# Test CREATE INDEX CONCURRENTLY with concurrent modifications
|
|
use strict;
|
|
use warnings;
|
|
|
|
use Config;
|
|
use PostgreSQL::Test::Cluster;
|
|
use PostgreSQL::Test::Utils;
|
|
|
|
use Test::More tests => 4;
|
|
|
|
my ($node, $result);
|
|
|
|
#
|
|
# Test set-up
|
|
#
|
|
$node = PostgreSQL::Test::Cluster->new('CIC_test');
|
|
$node->init;
|
|
$node->append_conf('postgresql.conf', 'lock_timeout = 180000');
|
|
$node->start;
|
|
$node->safe_psql('postgres', q(CREATE EXTENSION amcheck));
|
|
$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
|
|
#
|
|
|
|
# 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',
|
|
{
|
|
'002_pgbench_concurrent_transaction' => q(
|
|
BEGIN;
|
|
INSERT INTO tbl VALUES(0);
|
|
COMMIT;
|
|
),
|
|
'002_pgbench_concurrent_transaction_savepoints' => q(
|
|
BEGIN;
|
|
SAVEPOINT s1;
|
|
INSERT INTO tbl VALUES(0);
|
|
COMMIT;
|
|
)
|
|
});
|
|
|
|
$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();
|