Author: Noah Misch Commit: Noah Misch diff --git a/contrib/amcheck/t/002_cic.pl b/contrib/amcheck/t/002_cic.pl index f6b91e8..831395f 100644 --- a/contrib/amcheck/t/002_cic.pl +++ b/contrib/amcheck/t/002_cic.pl @@ -21,8 +21,9 @@ $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))); +$node->safe_psql('postgres', q(CREATE TABLE tbl(k int, v int))); +$node->safe_psql('postgres', q(INSERT INTO tbl SELECT n, 0 FROM generate_series(0,9) t(n))); +$node->safe_psql('postgres', q(CREATE INDEX idx ON tbl(k))); # # Stress CIC with pgbench. @@ -32,33 +33,39 @@ $node->safe_psql('postgres', q(CREATE INDEX idx ON tbl(i))); # lock to ensure only one CIC runs at a time. # $node->pgbench( - '--no-vacuum --client=5 --transactions=100', + '--no-vacuum --client=5 --transactions=20000', 0, [qr{actually processed}], [qr{^$}], 'concurrent INSERTs and CIC', { - '002_pgbench_concurrent_transaction' => q( - BEGIN; - INSERT INTO tbl VALUES(0); - COMMIT; + 'hot_update_commit' => q( + UPDATE tbl SET v = v + 1 WHERE k = :client_id; ), - '002_pgbench_concurrent_transaction_savepoints' => q( + 'hot_update_rollback' => q( BEGIN; - SAVEPOINT s1; - INSERT INTO tbl VALUES(0); - COMMIT; + UPDATE tbl SET v = v + 1 WHERE k = :client_id; + ROLLBACK; + ), + 'vacuum' => q( + VACUUM FREEZE tbl; + ), + 'key_share' => q( + SELECT * FROM tbl FOR KEY SHARE; ), '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); + REINDEX INDEX CONCURRENTLY idx; SELECT bt_index_check('idx',true); SELECT pg_advisory_unlock(42); \endif ) }); +print $node->safe_psql('postgres', + q(SELECT * FROM pg_stat_all_tables where relname = 'tbl'), + extra_params => ['--expanded']); + $node->stop; done_testing();