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

Commite208026

Browse files
committed
Fix race condition in TAP test 007_pre_auth
The authentication test added inc76db55 expects a backend to startand wait at the injection point "init-pre-auth". A query is used toretrieve the PID of the backend waiting at authentication, but its WHEREclause was too soft, checking only for a backend in a "starting" state.As proved by the CI, this WHERE clause is not enough. There is a smallwindow between the moment when the backend is reported as "starting" inits backend entry and the moment when it waits in its injection point,and it was possible for the test to return the PID of a backend processnot yet waiting in the injection point, causing spurious failures. Thisissue is fixed by tweaking the query retrieving the PID of the backendwaiting before authentication so as we check for "init-pre-auth" in itswait_event. An extra check based on the backend_type is added, based ona suggestion by Jacob, to be more cautious.Error spotted by the CI on Windows, but it could happen anywhere, aslong as the authentication path is slow enough compared to the TAP test.Reported-by: Andres Freund <andres@anarazel.de>Author: Jacob Champion <jacob.champion@enterprisedb.com>Co-authored-by: Michael Paquier <michael@paquier.xyz>Discussion:https://postgr.es/m/soexrl7oeyku24bj3czupxmv27ow35u6edymp5y3oyoysbe2kb@r3tgoos2xp2x
1 parent24503fa commite208026

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

‎src/test/authentication/t/007_pre_auth.pl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,16 @@
4343
# authentication. Use the $psql connection handle for server interaction.
4444
my$conn =$node->background_psql('postgres',wait=> 0);
4545

46-
# Wait for the connection to show up.
46+
# Wait for the connection to show up in pg_stat_activity, with the wait_event
47+
# of the injection point.
4748
my$pid;
4849
while (1)
4950
{
5051
$pid =$psql->query(
51-
"SELECT pid FROM pg_stat_activity WHERE state = 'starting';");
52+
qq{SELECT pid FROM pg_stat_activity
53+
WHERE backend_type = 'client backend'
54+
AND state = 'starting'
55+
AND wait_event = 'init-pre-auth';});
5256
lastif$pidne"";
5357

5458
usleep(100_000);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp