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

Commita5fe66b

Browse files
committed
isolationtester: append session name to application_name.
When writing / debugging an isolation test it sometimes is useful to see whichsession holds what lock etc. To make it easier, both as part of spec files andinteractively, append the session name to application_name. Sinceb1907d6application_name already contains the test name, this appends the session'sname to that.insert-conflict-specconflict did something like this manually, which can nowbe removed.As we have done lately with other test infrastructure improvements, backpatchthis change, to make it easier to backpatch tests.Author: Andres Freund <andres@anarazel.de>Reviewed-By: Michael Paquier <michael@paquier.xyz>Reviewed-By: Andrew Dunstan <andrew@dunslane.net>Discussion:https://postgr.es/m/20211211012052.2blmzcmxnxqawd2z@alap3.anarazel.deBackpatch: 10-, to make backpatching of tests easier.
1 parentfe490f9 commita5fe66b

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

‎src/test/isolation/isolationtester.c

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,14 @@ main(int argc, char **argv)
155155

156156
for (i=0;i<nconns;i++)
157157
{
158+
constchar*sessionname;
159+
158160
if (i==0)
159-
conns[i].sessionname="control connection";
161+
sessionname="control connection";
160162
else
161-
conns[i].sessionname=testspec->sessions[i-1]->name;
163+
sessionname=testspec->sessions[i-1]->name;
164+
165+
conns[i].sessionname=sessionname;
162166

163167
conns[i].conn=PQconnectdb(conninfo);
164168
if (PQstatus(conns[i].conn)!=CONNECTION_OK)
@@ -183,6 +187,26 @@ main(int argc, char **argv)
183187
blackholeNoticeProcessor,
184188
NULL);
185189

190+
/*
191+
* Similarly, append the session name to application_name to make it
192+
* easier to map spec file sessions to log output and
193+
* pg_stat_activity. The reason to append instead of just setting the
194+
* name is that we don't know the name of the test currently running.
195+
*/
196+
res=PQexecParams(conns[i].conn,
197+
"SELECT set_config('application_name',\n"
198+
" current_setting('application_name') || '/' || $1,\n"
199+
" false)",
200+
1,NULL,
201+
&sessionname,
202+
NULL,NULL,0);
203+
if (PQresultStatus(res)!=PGRES_TUPLES_OK)
204+
{
205+
fprintf(stderr,"setting of application name failed: %s",
206+
PQerrorMessage(conns[i].conn));
207+
exit(1);
208+
}
209+
186210
/* Save each connection's backend PID for subsequent use. */
187211
conns[i].backend_pid=PQbackendPID(conns[i].conn);
188212
conns[i].backend_pid_str=psprintf("%d",conns[i].backend_pid);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp