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

Commit94b4f7e

Browse files
committed
Tighten up application of parallel mode checks.
Commit924bcf4 failed to enforceparallel mode checks during the commit of a parallel worker, becausewe exited parallel mode prior to ending the transaction so that wecould pop the active snapshot. Re-establish parallel mode duringparallel worker commit. Without this, it's far too easy for unsafeactions during the pre-commit sequence to crash the server instead ofhitting the error checks as intended.Just to be extra paranoid, adjust a couple of the sanity checks inxact.c to check not only IsInParallelMode() but alsoIsParallelWorker().
1 parent423ec08 commit94b4f7e

File tree

1 file changed

+7
-5
lines changed
  • src/backend/access/transam

1 file changed

+7
-5
lines changed

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ AssignTransactionId(TransactionState s)
497497
* Workers synchronize transaction state at the beginning of each parallel
498498
* operation, so we can't account for new XIDs at this point.
499499
*/
500-
if (IsInParallelMode())
500+
if (IsInParallelMode()||IsParallelWorker())
501501
elog(ERROR,"cannot assign XIDs during a parallel operation");
502502

503503
/*
@@ -931,7 +931,7 @@ CommandCounterIncrement(void)
931931
* parallel operation, so we can't account for new commands after that
932932
* point.
933933
*/
934-
if (IsInParallelMode())
934+
if (IsInParallelMode()||IsParallelWorker())
935935
elog(ERROR,"cannot start commands during a parallel operation");
936936

937937
currentCommandId+=1;
@@ -1927,6 +1927,10 @@ CommitTransaction(void)
19271927

19281928
is_parallel_worker= (s->blockState==TBLOCK_PARALLEL_INPROGRESS);
19291929

1930+
/* Enforce parallel mode restrictions during parallel worker commit. */
1931+
if (is_parallel_worker)
1932+
EnterParallelMode();
1933+
19301934
ShowTransactionState("CommitTransaction");
19311935

19321936
/*
@@ -1971,10 +1975,7 @@ CommitTransaction(void)
19711975

19721976
/* If we might have parallel workers, clean them up now. */
19731977
if (IsInParallelMode())
1974-
{
19751978
AtEOXact_Parallel(true);
1976-
s->parallelModeLevel=0;
1977-
}
19781979

19791980
/* Shut down the deferred-trigger manager */
19801981
AfterTriggerEndXact(true);
@@ -2013,6 +2014,7 @@ CommitTransaction(void)
20132014
* commit processing
20142015
*/
20152016
s->state=TRANS_COMMIT;
2017+
s->parallelModeLevel=0;
20162018

20172019
if (!is_parallel_worker)
20182020
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp