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

Commit41fb35f

Browse files
committed
Fix possible crash due to incorrect allocation context.
Commitaf33039 aimed to reduceleakage from tqueue.c, which is good. Unfortunately, by changing thememory context in which all of gather_readnext() executes, it alsochanged the context in which ExecShutdownGatherWorkers executes, whichis not good, because that function eventually causes a call toExecParallelRetrieveInstrumentation, which proceeds to allocateplanstate->worker_instrument in a short-lived context, causing acrash.Rushabh Lathia, reviewed by Amit Kapila and by me.
1 parenta7b5573 commit41fb35f

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

‎src/backend/executor/execParallel.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,7 @@ ExecParallelRetrieveInstrumentation(PlanState *planstate,
500500
intn;
501501
intibytes;
502502
intplan_node_id=planstate->plan->plan_node_id;
503+
MemoryContextoldcontext;
503504

504505
/* Find the instumentation for this node. */
505506
for (i=0;i<instrumentation->num_plan_nodes;++i)
@@ -514,10 +515,19 @@ ExecParallelRetrieveInstrumentation(PlanState *planstate,
514515
for (n=0;n<instrumentation->num_workers;++n)
515516
InstrAggNode(planstate->instrument,&instrument[n]);
516517

517-
/* Also store the per-worker detail. */
518+
/*
519+
* Also store the per-worker detail.
520+
*
521+
* Worker instrumentation should be allocated in the same context as
522+
* the regular instrumentation information, which is the per-query
523+
* context. Switch into per-query memory context.
524+
*/
525+
oldcontext=MemoryContextSwitchTo(planstate->state->es_query_cxt);
518526
ibytes=mul_size(instrumentation->num_workers,sizeof(Instrumentation));
519527
planstate->worker_instrument=
520528
palloc(ibytes+ offsetof(WorkerInstrumentation,instrument));
529+
MemoryContextSwitchTo(oldcontext);
530+
521531
planstate->worker_instrument->num_workers=instrumentation->num_workers;
522532
memcpy(&planstate->worker_instrument->instrument,instrument,ibytes);
523533

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp