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

Commitac04aa8

Browse files
committed
Don't enter parallel mode when holding interrupts.
Doing so caused the leader to hang in wait_event=ParallelFinish, whichrequired an immediate shutdown to resolve. Back-patch to v12 (allsupported versions).Francesco DegrassiDiscussion:https://postgr.es/m/CAC-SaSzHUKT=vZJ8MPxYdC_URPfax+yoA1hKTcF4ROz_Q6z0_Q@mail.gmail.com
1 parent933848d commitac04aa8

File tree

3 files changed

+61
-0
lines changed

3 files changed

+61
-0
lines changed

‎src/backend/optimizer/plan/planner.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,11 @@ standard_planner(Query *parse, const char *query_string, int cursorOptions,
342342
* we want to allow parallel inserts in general; updates and deletes have
343343
* additional problems especially around combo CIDs.)
344344
*
345+
* We don't try to use parallel mode unless interruptible. The leader
346+
* expects ProcessInterrupts() calls to reach HandleParallelMessages().
347+
* Even if we called HandleParallelMessages() another way, starting a
348+
* parallel worker is too delay-prone to be prudent when uncancellable.
349+
*
345350
* For now, we don't try to use parallel mode if we're running inside a
346351
* parallel worker. We might eventually be able to relax this
347352
* restriction, but for now it seems best not to have parallel workers
@@ -352,6 +357,7 @@ standard_planner(Query *parse, const char *query_string, int cursorOptions,
352357
parse->commandType==CMD_SELECT&&
353358
!parse->hasModifyingCTE&&
354359
max_parallel_workers_per_gather>0&&
360+
INTERRUPTS_CAN_BE_PROCESSED()&&
355361
!IsParallelWorker())
356362
{
357363
/* all the cheap tests pass, so scan the query tree */

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1386,3 +1386,27 @@ reset debug_parallel_query;
13861386
drop function set_and_report_role();
13871387
drop function set_role_and_error(int);
13881388
drop role regress_parallel_worker;
1389+
-- don't freeze in ParallelFinish while holding an LWLock
1390+
BEGIN;
1391+
CREATE FUNCTION my_cmp (int4, int4)
1392+
RETURNS int LANGUAGE sql AS
1393+
$$
1394+
SELECT
1395+
CASE WHEN $1 < $2 THEN -1
1396+
WHEN $1 > $2 THEN 1
1397+
ELSE 0
1398+
END;
1399+
$$;
1400+
CREATE TABLE parallel_hang (i int4);
1401+
INSERT INTO parallel_hang
1402+
(SELECT * FROM generate_series(1, 400) gs);
1403+
CREATE OPERATOR CLASS int4_custom_ops FOR TYPE int4 USING btree AS
1404+
OPERATOR 1 < (int4, int4), OPERATOR 2 <= (int4, int4),
1405+
OPERATOR 3 = (int4, int4), OPERATOR 4 >= (int4, int4),
1406+
OPERATOR 5 > (int4, int4), FUNCTION 1 my_cmp(int4, int4);
1407+
CREATE UNIQUE INDEX parallel_hang_idx
1408+
ON parallel_hang
1409+
USING btree (i int4_custom_ops);
1410+
SET debug_parallel_query = on;
1411+
DELETE FROM parallel_hang WHERE 380 <= i AND i <= 420;
1412+
ROLLBACK;

‎src/test/regress/sql/select_parallel.sql

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,3 +543,34 @@ reset debug_parallel_query;
543543
dropfunction set_and_report_role();
544544
dropfunction set_role_and_error(int);
545545
drop role regress_parallel_worker;
546+
547+
-- don't freeze in ParallelFinish while holding an LWLock
548+
BEGIN;
549+
550+
CREATEFUNCTIONmy_cmp (int4, int4)
551+
RETURNSint LANGUAGE sqlAS
552+
$$
553+
SELECT
554+
CASE WHEN $1< $2 THEN-1
555+
WHEN $1> $2 THEN1
556+
ELSE0
557+
END;
558+
$$;
559+
560+
CREATETABLEparallel_hang (i int4);
561+
INSERT INTO parallel_hang
562+
(SELECT*FROM generate_series(1,400) gs);
563+
564+
CREATEOPERATOR CLASSint4_custom_ops FOR TYPE int4 USING btreeAS
565+
OPERATOR1< (int4, int4), OPERATOR2<= (int4, int4),
566+
OPERATOR3= (int4, int4), OPERATOR4>= (int4, int4),
567+
OPERATOR5> (int4, int4), FUNCTION1 my_cmp(int4, int4);
568+
569+
CREATEUNIQUE INDEXparallel_hang_idx
570+
ON parallel_hang
571+
USING btree (i int4_custom_ops);
572+
573+
SET debug_parallel_query=on;
574+
DELETEFROM parallel_hangWHERE380<= iAND i<=420;
575+
576+
ROLLBACK;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp