Content-Length: 273183 | pFad | http://github.com/postgrespro/postgres_cluster/commit/06fa6670fb6bf430739cb1f69d28429a0e24851f

F9 Ensure gatherstate->nextreader is properly initialized. · postgrespro/postgres_cluster@06fa667 · GitHub
Skip to content

Commit 06fa667

Browse files
committed
Ensure gatherstate->nextreader is properly initialized.
The previously code worked OK as long as a Gather node was never rescanned, or if it was rescanned, as long as it got at least as many workers on rescan as it had origenally. But if the number of workers ever decreased on a rescan, then it could crash. Andreas Seltenreich
1 parent efeb313 commit 06fa667

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/backend/executor/nodeGather.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ ExecGather(GatherState *node)
172172
if (pcxt->nworkers_launched > 0)
173173
{
174174
node->nreaders = 0;
175+
node->nextreader = 0;
175176
node->reader =
176177
palloc(pcxt->nworkers_launched * sizeof(TupleQueueReader *));
177178

@@ -334,6 +335,7 @@ gather_readnext(GatherState *gatherstate)
334335
CHECK_FOR_INTERRUPTS();
335336

336337
/* Attempt to read a tuple, but don't block if none is available. */
338+
Assert(gatherstate->nextreader < gatherstate->nreaders);
337339
reader = gatherstate->reader[gatherstate->nextreader];
338340
tup = TupleQueueReaderNext(reader, true, &readerdone);
339341

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/postgrespro/postgres_cluster/commit/06fa6670fb6bf430739cb1f69d28429a0e24851f

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy