mirror of
https://github.com/postgres/postgres.git
synced 2025-06-26 12:21:12 +03:00
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.
This commit is contained in:
@ -195,9 +195,8 @@ SELECT gid FROM pg_prepared_xacts;
|
|||||||
|
|
||||||
-- pxtest3 should be locked because of the pending DROP
|
-- pxtest3 should be locked because of the pending DROP
|
||||||
begin;
|
begin;
|
||||||
set statement_timeout to 2000;
|
lock table pxtest3 in access share mode nowait;
|
||||||
SELECT * FROM pxtest3;
|
ERROR: could not obtain lock on relation "pxtest3"
|
||||||
ERROR: canceling statement due to statement timeout
|
|
||||||
rollback;
|
rollback;
|
||||||
-- Disconnect, we will continue testing in a different backend
|
-- Disconnect, we will continue testing in a different backend
|
||||||
\c -
|
\c -
|
||||||
@ -211,9 +210,8 @@ SELECT gid FROM pg_prepared_xacts;
|
|||||||
|
|
||||||
-- pxtest3 should still be locked because of the pending DROP
|
-- pxtest3 should still be locked because of the pending DROP
|
||||||
begin;
|
begin;
|
||||||
set statement_timeout to 2000;
|
lock table pxtest3 in access share mode nowait;
|
||||||
SELECT * FROM pxtest3;
|
ERROR: could not obtain lock on relation "pxtest3"
|
||||||
ERROR: canceling statement due to statement timeout
|
|
||||||
rollback;
|
rollback;
|
||||||
-- Commit table creation
|
-- Commit table creation
|
||||||
COMMIT PREPARED 'regress-one';
|
COMMIT PREPARED 'regress-one';
|
||||||
|
@ -199,12 +199,7 @@ SELECT gid FROM pg_prepared_xacts;
|
|||||||
|
|
||||||
-- pxtest3 should be locked because of the pending DROP
|
-- pxtest3 should be locked because of the pending DROP
|
||||||
begin;
|
begin;
|
||||||
set statement_timeout to 2000;
|
lock table pxtest3 in access share mode nowait;
|
||||||
SELECT * FROM pxtest3;
|
|
||||||
fff
|
|
||||||
-----
|
|
||||||
(0 rows)
|
|
||||||
|
|
||||||
rollback;
|
rollback;
|
||||||
-- Disconnect, we will continue testing in a different backend
|
-- Disconnect, we will continue testing in a different backend
|
||||||
\c -
|
\c -
|
||||||
@ -216,12 +211,7 @@ SELECT gid FROM pg_prepared_xacts;
|
|||||||
|
|
||||||
-- pxtest3 should still be locked because of the pending DROP
|
-- pxtest3 should still be locked because of the pending DROP
|
||||||
begin;
|
begin;
|
||||||
set statement_timeout to 2000;
|
lock table pxtest3 in access share mode nowait;
|
||||||
SELECT * FROM pxtest3;
|
|
||||||
fff
|
|
||||||
-----
|
|
||||||
(0 rows)
|
|
||||||
|
|
||||||
rollback;
|
rollback;
|
||||||
-- Commit table creation
|
-- Commit table creation
|
||||||
COMMIT PREPARED 'regress-one';
|
COMMIT PREPARED 'regress-one';
|
||||||
|
@ -123,8 +123,7 @@ SELECT gid FROM pg_prepared_xacts;
|
|||||||
|
|
||||||
-- pxtest3 should be locked because of the pending DROP
|
-- pxtest3 should be locked because of the pending DROP
|
||||||
begin;
|
begin;
|
||||||
set statement_timeout to 2000;
|
lock table pxtest3 in access share mode nowait;
|
||||||
SELECT * FROM pxtest3;
|
|
||||||
rollback;
|
rollback;
|
||||||
|
|
||||||
-- Disconnect, we will continue testing in a different backend
|
-- 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
|
-- pxtest3 should still be locked because of the pending DROP
|
||||||
begin;
|
begin;
|
||||||
set statement_timeout to 2000;
|
lock table pxtest3 in access share mode nowait;
|
||||||
SELECT * FROM pxtest3;
|
|
||||||
rollback;
|
rollback;
|
||||||
|
|
||||||
-- Commit table creation
|
-- Commit table creation
|
||||||
|
Reference in New Issue
Block a user