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

Commita53c06a

Browse files
committed
Prohibit parallel query when the isolation level is serializable.
In order for this to be safe, the code which hands true serializabilitywill need to taught that the SIRead locks taken by a parallel workerpertain to the same transaction as those taken by the parallel leader.Some further changes may be needed as well. Until the necessaryadaptations are made, don't generate parallel plans in serializablemode, and if a previously-generated parallel plan is used afterserializable mode has been activated, run it serially.This fixes a bug in commit7aea8e4.
1 parentbfc78d7 commita53c06a

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

‎src/backend/access/transam/parallel.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,14 @@ CreateParallelContext(parallel_worker_main_type entrypoint, int nworkers)
135135
if (dynamic_shared_memory_type==DSM_IMPL_NONE)
136136
nworkers=0;
137137

138+
/*
139+
* If we are running under serializable isolation, we can't use
140+
* parallel workers, at least not until somebody enhances that mechanism
141+
* to be parallel-aware.
142+
*/
143+
if (IsolationIsSerializable())
144+
nworkers=0;
145+
138146
/* We might be running in a short-lived memory context. */
139147
oldcontext=MemoryContextSwitchTo(TopTransactionContext);
140148

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
#include"access/htup_details.h"
2222
#include"access/parallel.h"
23+
#include"access/xact.h"
2324
#include"executor/executor.h"
2425
#include"executor/nodeAgg.h"
2526
#include"foreign/fdwapi.h"
@@ -210,11 +211,20 @@ standard_planner(Query *parse, int cursorOptions, ParamListInfo boundParams)
210211
* a parallel worker. We might eventually be able to relax this
211212
* restriction, but for now it seems best not to have parallel workers
212213
* trying to create their own parallel workers.
214+
*
215+
* We can't use parallelism in serializable mode because the predicate
216+
* locking code is not parallel-aware. It's not catastrophic if someone
217+
* tries to run a parallel plan in serializable mode; it just won't get
218+
* any workers and will run serially. But it seems like a good heuristic
219+
* to assume that the same serialization level will be in effect at plan
220+
* time and execution time, so don't generate a parallel plan if we're
221+
* in serializable mode.
213222
*/
214223
glob->parallelModeOK= (cursorOptions&CURSOR_OPT_PARALLEL_OK)!=0&&
215224
IsUnderPostmaster&&dynamic_shared_memory_type!=DSM_IMPL_NONE&&
216225
parse->commandType==CMD_SELECT&& !parse->hasModifyingCTE&&
217226
parse->utilityStmt==NULL&& !IsParallelWorker()&&
227+
!IsolationIsSerializable()&&
218228
!contain_parallel_unsafe((Node*)parse);
219229

220230
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp