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

Commit8749d85

Browse files
committed
Make postgres_fdw's query_cancel test less flaky.
This test occasionally shows+WARNING: could not get result of cancel request due to timeoutwhich appears to be because the cancel request is sometimes unluckilysent to the remote session between queries, and then it's ignored.This patch tries to make that less probable in three ways:1. Use a test query that does not involve remote estimates, so thatno EXPLAINs are sent.2. Make sure that the remote session is ready-to-go (transactionstarted, SET commands sent) before we start the timer.3. Increase the statement_timeout to 100ms, to give the localsession enough time to plan and issue the query.We might have to go higher than 100ms to make this adequatelystable in the buildfarm, but let's see how it goes.Back-patch to v17 where this test was introduced.Jelte Fennema-Nio and Tom LaneDiscussion:https://postgr.es/m/578934.1725045685@sss.pgh.pa.us
1 parentb431108 commit8749d85

File tree

2 files changed

+32
-12
lines changed

2 files changed

+32
-12
lines changed

‎contrib/postgres_fdw/expected/query_cancel.out

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,31 @@ SELECT version() ~ 'cygwin' AS skip_test \gset
22
\if :skip_test
33
\quit
44
\endif
5-
-- Make sure this big CROSS JOIN query is pushed down
6-
EXPLAIN (VERBOSE, COSTS OFF) SELECT count(*) FROM ft1 CROSS JOIN ft2 CROSS JOIN ft4 CROSS JOIN ft5;
5+
-- Let's test canceling a remote query. Use a table that does not have
6+
-- remote_estimate enabled, else there will be multiple queries to the
7+
-- remote and we might unluckily send the cancel in between two of them.
8+
-- First let's confirm that the query is actually pushed down.
9+
EXPLAIN (VERBOSE, COSTS OFF)
10+
SELECT count(*) FROM ft1 a CROSS JOIN ft1 b CROSS JOIN ft1 c CROSS JOIN ft1 d;
711
QUERY PLAN
812
---------------------------------------------------------------------------------------------------------------------------------------------------------------------
913
Foreign Scan
1014
Output: (count(*))
11-
Relations: Aggregate on ((((public.ft1) INNER JOIN (public.ft2)) INNER JOIN (public.ft4)) INNER JOIN (public.ft5))
12-
Remote SQL: SELECT count(*) FROM ((("S 1"."T 1" r1 INNER JOIN "S 1"."T 1" r2 ON (TRUE)) INNER JOIN "S 1"."T3" r4 ON (TRUE)) INNER JOIN "S 1"."T4" r6 ON (TRUE))
15+
Relations: Aggregate on ((((public.ft1 a) INNER JOIN (public.ft1 b)) INNER JOIN (public.ft1 c)) INNER JOIN (public.ft1 d))
16+
Remote SQL: SELECT count(*) FROM ((("S 1"."T 1" r1 INNER JOIN "S 1"."T 1" r2 ON (TRUE)) INNER JOIN "S 1"."T1" r4 ON (TRUE)) INNER JOIN "S 1"."T1" r6 ON (TRUE))
1317
(4 rows)
1418

15-
-- Make sure query cancellation works
1619
BEGIN;
17-
SET LOCAL statement_timeout = '10ms';
18-
select count(*) from ft1 CROSS JOIN ft2 CROSS JOIN ft4 CROSS JOIN ft5; -- this takes very long
20+
-- Make sure that connection is open and set up.
21+
SELECT count(*) FROM ft1 a;
22+
count
23+
-------
24+
822
25+
(1 row)
26+
27+
-- Timeout needs to be long enough to be sure that we've sent the slow query.
28+
SET LOCAL statement_timeout = '100ms';
29+
-- This would take very long if not canceled:
30+
SELECT count(*) FROM ft1 a CROSS JOIN ft1 b CROSS JOIN ft1 c CROSS JOIN ft1 d;
1931
ERROR: canceling statement due to statement timeout
2032
COMMIT;

‎contrib/postgres_fdw/sql/query_cancel.sql

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,18 @@ SELECT version() ~ 'cygwin' AS skip_test \gset
33
\quit
44
\endif
55

6-
-- Make sure this big CROSS JOIN query is pushed down
7-
EXPLAIN (VERBOSE, COSTS OFF)SELECTcount(*)FROM ft1CROSS JOIN ft2CROSS JOIN ft4CROSS JOIN ft5;
8-
-- Make sure query cancellation works
6+
-- Let's test canceling a remote query. Use a table that does not have
7+
-- remote_estimate enabled, else there will be multiple queries to the
8+
-- remote and we might unluckily send the cancel in between two of them.
9+
-- First let's confirm that the query is actually pushed down.
10+
EXPLAIN (VERBOSE, COSTS OFF)
11+
SELECTcount(*)FROM ft1 aCROSS JOIN ft1 bCROSS JOIN ft1 cCROSS JOIN ft1 d;
12+
913
BEGIN;
10-
SET LOCAL statement_timeout='10ms';
11-
selectcount(*)from ft1CROSS JOIN ft2CROSS JOIN ft4CROSS JOIN ft5;-- this takes very long
14+
-- Make sure that connection is open and set up.
15+
SELECTcount(*)FROM ft1 a;
16+
-- Timeout needs to be long enough to be sure that we've sent the slow query.
17+
SET LOCAL statement_timeout='100ms';
18+
-- This would take very long if not canceled:
19+
SELECTcount(*)FROM ft1 aCROSS JOIN ft1 bCROSS JOIN ft1 cCROSS JOIN ft1 d;
1220
COMMIT;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp