aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2017-03-13 16:46:32 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2017-03-13 16:46:32 -0400
commit1c7a66a8e9378aeb092d7ed26890134d17fdd691 (patch)
tree8aaf2591d947e0f056d3174c9cb1363c534e9772 /src
parent9ca5c8721dfa2413e910531373395c6e18062ddf (diff)
downloadpostgresql-1c7a66a8e9378aeb092d7ed26890134d17fdd691.tar.gz
postgresql-1c7a66a8e9378aeb092d7ed26890134d17fdd691.zip
Remove unnecessary dependency on statement_timeout in prepared_xacts test.
Rather than waiting around for statement_timeout to expire, we can just try to take the table's lock in nowait mode. This saves some fraction under 4 seconds when running this test with prepared xacts available, and it guards against timeout-expired-anyway failures on very slow machines when prepared xacts are not available, as seen in a recent failure on axolotl for instance. This approach could fail if autovacuum were to take an exclusive lock on the test table concurrently, but there's no reason for it to do so. Since the main point here is to improve stability in the buildfarm, back-patch to all supported branches.
Diffstat (limited to 'src')
-rw-r--r--src/test/regress/expected/prepared_xacts.out10
-rw-r--r--src/test/regress/expected/prepared_xacts_1.out14
-rw-r--r--src/test/regress/sql/prepared_xacts.sql6
3 files changed, 8 insertions, 22 deletions
diff --git a/src/test/regress/expected/prepared_xacts.out b/src/test/regress/expected/prepared_xacts.out
index 3a2c533f789..eb77c18788e 100644
--- a/src/test/regress/expected/prepared_xacts.out
+++ b/src/test/regress/expected/prepared_xacts.out
@@ -195,9 +195,8 @@ SELECT gid FROM pg_prepared_xacts;
-- pxtest3 should be locked because of the pending DROP
begin;
-set statement_timeout to 2000;
-SELECT * FROM pxtest3;
-ERROR: canceling statement due to statement timeout
+lock table pxtest3 in access share mode nowait;
+ERROR: could not obtain lock on relation "pxtest3"
rollback;
-- Disconnect, we will continue testing in a different backend
\c -
@@ -211,9 +210,8 @@ SELECT gid FROM pg_prepared_xacts;
-- pxtest3 should still be locked because of the pending DROP
begin;
-set statement_timeout to 2000;
-SELECT * FROM pxtest3;
-ERROR: canceling statement due to statement timeout
+lock table pxtest3 in access share mode nowait;
+ERROR: could not obtain lock on relation "pxtest3"
rollback;
-- Commit table creation
COMMIT PREPARED 'regress-one';
diff --git a/src/test/regress/expected/prepared_xacts_1.out b/src/test/regress/expected/prepared_xacts_1.out
index 5078bf6ba98..0857d259e07 100644
--- a/src/test/regress/expected/prepared_xacts_1.out
+++ b/src/test/regress/expected/prepared_xacts_1.out
@@ -199,12 +199,7 @@ SELECT gid FROM pg_prepared_xacts;
-- pxtest3 should be locked because of the pending DROP
begin;
-set statement_timeout to 2000;
-SELECT * FROM pxtest3;
- fff
------
-(0 rows)
-
+lock table pxtest3 in access share mode nowait;
rollback;
-- Disconnect, we will continue testing in a different backend
\c -
@@ -216,12 +211,7 @@ SELECT gid FROM pg_prepared_xacts;
-- pxtest3 should still be locked because of the pending DROP
begin;
-set statement_timeout to 2000;
-SELECT * FROM pxtest3;
- fff
------
-(0 rows)
-
+lock table pxtest3 in access share mode nowait;
rollback;
-- Commit table creation
COMMIT PREPARED 'regress-one';
diff --git a/src/test/regress/sql/prepared_xacts.sql b/src/test/regress/sql/prepared_xacts.sql
index dfb20a18e7c..d8249a27dc2 100644
--- a/src/test/regress/sql/prepared_xacts.sql
+++ b/src/test/regress/sql/prepared_xacts.sql
@@ -123,8 +123,7 @@ SELECT gid FROM pg_prepared_xacts;
-- pxtest3 should be locked because of the pending DROP
begin;
-set statement_timeout to 2000;
-SELECT * FROM pxtest3;
+lock table pxtest3 in access share mode nowait;
rollback;
-- Disconnect, we will continue testing in a different backend
@@ -135,8 +134,7 @@ SELECT gid FROM pg_prepared_xacts;
-- pxtest3 should still be locked because of the pending DROP
begin;
-set statement_timeout to 2000;
-SELECT * FROM pxtest3;
+lock table pxtest3 in access share mode nowait;
rollback;
-- Commit table creation