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

Commit6b3678d

Browse files
committed
Put libpq_pipeline cancel test back
I disabled it incc6e64a because it was unstable; hopefully thechanges here make it more stable. (Jelte proposed to submit the queriesusing simple query protocol, but I chose to instead make the monitorconnection wait until the PgSleep wait event is seen. This is probablynot a terribly meaningful increase in coverage ...)Discussion:https://postgr.es/m/CAGECzQRQh_5tSy+5cndgv08eNJ2O0Zpwn2YddJtSsmC=Wpy1BQ@mail.gmail.com
1 parent0960ae1 commit6b3678d

File tree

1 file changed

+22
-15
lines changed

1 file changed

+22
-15
lines changed

‎src/test/modules/libpq_pipeline/libpq_pipeline.c

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -116,27 +116,37 @@ confirm_query_canceled_impl(int line, PGconn *conn)
116116

117117
/*
118118
* Using monitorConn, query pg_stat_activity to see that the connection with
119-
* the given PID is in the given state. We never stop until it does.
119+
* the given PID is either in the given state, or waiting on the given event
120+
* (only one of them can be given).
120121
*/
121122
staticvoid
122-
wait_for_connection_state(intline,PGconn*monitorConn,intprocpid,char*state)
123+
wait_for_connection_state(intline,PGconn*monitorConn,intprocpid,
124+
char*state,char*event)
123125
{
124126
constOidparamTypes[]= {INT4OID,TEXTOID};
125127
constchar*paramValues[2];
126128
char*pidstr=psprintf("%d",procpid);
127129

130+
Assert((state==NULL) ^ (event==NULL));
131+
128132
paramValues[0]=pidstr;
129-
paramValues[1]=state;
133+
paramValues[1]=state ?state :event;
130134

131135
while (true)
132136
{
133137
PGresult*res;
134138
char*value;
135139

136-
res=PQexecParams(monitorConn,
137-
"SELECT count(*) FROM pg_stat_activity WHERE "
138-
"pid = $1 AND state = $2",
139-
2,paramTypes,paramValues,NULL,NULL,1);
140+
if (state!=NULL)
141+
res=PQexecParams(monitorConn,
142+
"SELECT count(*) FROM pg_stat_activity WHERE "
143+
"pid = $1 AND state = $2",
144+
2,paramTypes,paramValues,NULL,NULL,0);
145+
else
146+
res=PQexecParams(monitorConn,
147+
"SELECT count(*) FROM pg_stat_activity WHERE "
148+
"pid = $1 AND wait_event = $2",
149+
2,paramTypes,paramValues,NULL,NULL,0);
140150

141151
if (PQresultStatus(res)!=PGRES_TUPLES_OK)
142152
pg_fatal_impl(line,"could not query pg_stat_activity: %s",PQerrorMessage(monitorConn));
@@ -145,7 +155,7 @@ wait_for_connection_state(int line, PGconn *monitorConn, int procpid, char *stat
145155
if (PQnfields(res)!=1)
146156
pg_fatal_impl(line,"unexpected number of columns received: %d",PQnfields(res));
147157
value=PQgetvalue(res,0,0);
148-
if (value[0]!='0')
158+
if (strcmp(value,"0")!=0)
149159
{
150160
PQclear(res);
151161
break;
@@ -172,7 +182,7 @@ send_cancellable_query_impl(int line, PGconn *conn, PGconn *monitorConn)
172182
* connection below is reliable, instead of possibly seeing an outdated
173183
* state.
174184
*/
175-
wait_for_connection_state(line,monitorConn,PQbackendPID(conn),"idle");
185+
wait_for_connection_state(line,monitorConn,PQbackendPID(conn),"idle",NULL);
176186

177187
env_wait=getenv("PG_TEST_TIMEOUT_DEFAULT");
178188
if (env_wait==NULL)
@@ -183,10 +193,10 @@ send_cancellable_query_impl(int line, PGconn *conn, PGconn *monitorConn)
183193
pg_fatal_impl(line,"failed to send query: %s",PQerrorMessage(conn));
184194

185195
/*
186-
* Wait for thequery tostart, because if the query is not running yet
187-
* the cancel request that we send won't have any effect.
196+
* Wait for thesleep tobe active, because if the query is not running
197+
*yet,the cancel request that we send won't have any effect.
188198
*/
189-
wait_for_connection_state(line,monitorConn,PQbackendPID(conn),"active");
199+
wait_for_connection_state(line,monitorConn,PQbackendPID(conn),NULL,"PgSleep");
190200
}
191201

192202
/*
@@ -2098,10 +2108,7 @@ usage(const char *progname)
20982108
staticvoid
20992109
print_test_list(void)
21002110
{
2101-
#if0
2102-
/* Commented out until further stabilized */
21032111
printf("cancel\n");
2104-
#endif
21052112
printf("disallowed_in_pipeline\n");
21062113
printf("multi_pipelines\n");
21072114
printf("nosync\n");

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp