Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1c7a66a

Browse files
committed
Remove unnecessary dependency on statement_timeout in prepared_xacts test.
Rather than waiting around for statement_timeout to expire, we can justtry to take the table's lock in nowait mode. This saves some fractionunder 4 seconds when running this test with prepared xacts available,and it guards against timeout-expired-anyway failures on very slowmachines when prepared xacts are not available, as seen in a recentfailure on axolotl for instance.This approach could fail if autovacuum were to take an exclusive lockon 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.
1 parent9ca5c87 commit1c7a66a

File tree

3 files changed

+8
-22
lines changed

3 files changed

+8
-22
lines changed

‎src/test/regress/expected/prepared_xacts.out

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,8 @@ SELECT gid FROM pg_prepared_xacts;
195195

196196
-- pxtest3 should be locked because of the pending DROP
197197
begin;
198-
set statement_timeout to 2000;
199-
SELECT * FROM pxtest3;
200-
ERROR: canceling statement due to statement timeout
198+
lock table pxtest3 in access share mode nowait;
199+
ERROR: could not obtain lock on relation "pxtest3"
201200
rollback;
202201
-- Disconnect, we will continue testing in a different backend
203202
\c -
@@ -211,9 +210,8 @@ SELECT gid FROM pg_prepared_xacts;
211210

212211
-- pxtest3 should still be locked because of the pending DROP
213212
begin;
214-
set statement_timeout to 2000;
215-
SELECT * FROM pxtest3;
216-
ERROR: canceling statement due to statement timeout
213+
lock table pxtest3 in access share mode nowait;
214+
ERROR: could not obtain lock on relation "pxtest3"
217215
rollback;
218216
-- Commit table creation
219217
COMMIT PREPARED 'regress-one';

‎src/test/regress/expected/prepared_xacts_1.out

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -199,12 +199,7 @@ SELECT gid FROM pg_prepared_xacts;
199199

200200
-- pxtest3 should be locked because of the pending DROP
201201
begin;
202-
set statement_timeout to 2000;
203-
SELECT * FROM pxtest3;
204-
fff
205-
-----
206-
(0 rows)
207-
202+
lock table pxtest3 in access share mode nowait;
208203
rollback;
209204
-- Disconnect, we will continue testing in a different backend
210205
\c -
@@ -216,12 +211,7 @@ SELECT gid FROM pg_prepared_xacts;
216211

217212
-- pxtest3 should still be locked because of the pending DROP
218213
begin;
219-
set statement_timeout to 2000;
220-
SELECT * FROM pxtest3;
221-
fff
222-
-----
223-
(0 rows)
224-
214+
lock table pxtest3 in access share mode nowait;
225215
rollback;
226216
-- Commit table creation
227217
COMMIT PREPARED 'regress-one';

‎src/test/regress/sql/prepared_xacts.sql

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,7 @@ SELECT gid FROM pg_prepared_xacts;
123123

124124
-- pxtest3 should be locked because of the pending DROP
125125
begin;
126-
set statement_timeout to2000;
127-
SELECT*FROM pxtest3;
126+
lock table pxtest3in access share mode nowait;
128127
rollback;
129128

130129
-- Disconnect, we will continue testing in a different backend
@@ -135,8 +134,7 @@ SELECT gid FROM pg_prepared_xacts;
135134

136135
-- pxtest3 should still be locked because of the pending DROP
137136
begin;
138-
set statement_timeout to2000;
139-
SELECT*FROM pxtest3;
137+
lock table pxtest3in access share mode nowait;
140138
rollback;
141139

142140
-- Commit table creation

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp