forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit1db5667
committed
Avoid sharing PARAM_EXEC slots between different levels of NestLoop.
Up to now, createplan.c attempted to share PARAM_EXEC slots forNestLoopParams across different plan levels, if the same underlying Varwas being fed down to different righthand-side subplan trees by differentNestLoops. This was, I think, more of an artifact of using subselect.c'sPlannerParamItem infrastructure than an explicit design goal, but anywaythat was the end result.This works well enough as long as the plan tree is executing synchronously,but the feature whereby Gather can execute the parallelized subplan locallybreaks it. An upper NestLoop node might execute for a row retrieved froma parallel worker, and assign a value for a PARAM_EXEC slot from that row,while the leader's copy of the parallelized subplan is suspended with adifferent active value of the row the Var comes from. When controleventually returns to the leader's subplan, it gets the wrong answers ifthe same PARAM_EXEC slot is being used within the subplan, as reportedin bug #15577 from Bartosz Polnik.This is pretty reminiscent of the problem fixed in commit46c508f, andthe proper fix seems to be the same: don't try to share PARAM_EXEC slotsacross different levels of controlling NestLoop nodes.This requires decoupling NestLoopParam handling from PlannerParamItemhandling, although the logic remains somewhat similar. To avoid bizarredivision of labor between subselect.c and createplan.c, I decided to moveall the param-slot-assignment logic for both cases out of those filesand put it into a new file paramassign.c. Hopefully it's a bit betterdocumented now, too.A regression test case for this might be nice, but we don't know atest case that triggers the problem with a suitably small amountof data.Back-patch to 9.6 where we added Gather nodes. It's conceivable thatrelated problems exist in older branches; but without some evidencefor that, I'll leave the older branches alone.Discussion:https://postgr.es/m/15577-ca61ab18904af852@postgresql.org1 parent8b89a88 commit1db5667
File tree
7 files changed
+678
-553
lines changed- src
- backend/optimizer
- plan
- util
- include/optimizer
7 files changed
+678
-553
lines changedLines changed: 10 additions & 172 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
19 | 19 |
| |
20 | 20 |
| |
21 | 21 |
| |
22 |
| - | |
23 | 22 |
| |
24 | 23 |
| |
25 | 24 |
| |
| |||
29 | 28 |
| |
30 | 29 |
| |
31 | 30 |
| |
| 31 | + | |
32 | 32 |
| |
33 | 33 |
| |
34 | 34 |
| |
35 | 35 |
| |
36 |
| - | |
37 | 36 |
| |
38 | 37 |
| |
39 | 38 |
| |
| |||
151 | 150 |
| |
152 | 151 |
| |
153 | 152 |
| |
154 |
| - | |
155 |
| - | |
156 | 153 |
| |
157 | 154 |
| |
158 | 155 |
| |
| |||
310 | 307 |
| |
311 | 308 |
| |
312 | 309 |
| |
313 |
| - | |
| 310 | + | |
314 | 311 |
| |
315 | 312 |
| |
316 | 313 |
| |
| |||
1554 | 1551 |
| |
1555 | 1552 |
| |
1556 | 1553 |
| |
1557 |
| - | |
| 1554 | + | |
1558 | 1555 |
| |
1559 | 1556 |
| |
1560 | 1557 |
| |
| |||
1590 | 1587 |
| |
1591 | 1588 |
| |
1592 | 1589 |
| |
1593 |
| - | |
| 1590 | + | |
1594 | 1591 |
| |
1595 | 1592 |
| |
1596 | 1593 |
| |
| |||
3774 | 3771 |
| |
3775 | 3772 |
| |
3776 | 3773 |
| |
3777 |
| - | |
3778 |
| - | |
3779 |
| - | |
3780 | 3774 |
| |
3781 | 3775 |
| |
3782 | 3776 |
| |
| |||
3820 | 3814 |
| |
3821 | 3815 |
| |
3822 | 3816 |
| |
3823 |
| - | |
| 3817 | + | |
3824 | 3818 |
| |
3825 | 3819 |
| |
3826 |
| - | |
3827 |
| - | |
3828 |
| - | |
3829 |
| - | |
3830 |
| - | |
3831 |
| - | |
3832 |
| - | |
3833 |
| - | |
3834 |
| - | |
3835 |
| - | |
3836 |
| - | |
3837 |
| - | |
3838 |
| - | |
3839 |
| - | |
3840 |
| - | |
3841 |
| - | |
3842 |
| - | |
3843 |
| - | |
3844 |
| - | |
3845 |
| - | |
3846 |
| - | |
3847 |
| - | |
3848 |
| - | |
3849 |
| - | |
3850 |
| - | |
3851 |
| - | |
3852 |
| - | |
3853 |
| - | |
3854 |
| - | |
| 3820 | + | |
3855 | 3821 |
| |
3856 | 3822 |
| |
3857 | 3823 |
| |
| |||
4351 | 4317 |
| |
4352 | 4318 |
| |
4353 | 4319 |
| |
4354 |
| - | |
4355 |
| - | |
4356 |
| - | |
4357 | 4320 |
| |
4358 | 4321 |
| |
4359 | 4322 |
| |
4360 | 4323 |
| |
4361 | 4324 |
| |
4362 | 4325 |
| |
4363 |
| - | |
4364 |
| - | |
4365 |
| - | |
4366 |
| - | |
4367 |
| - | |
4368 |
| - | |
4369 |
| - | |
4370 |
| - | |
4371 |
| - | |
4372 |
| - | |
4373 |
| - | |
4374 |
| - | |
4375 |
| - | |
4376 |
| - | |
4377 |
| - | |
4378 |
| - | |
4379 |
| - | |
4380 |
| - | |
4381 |
| - | |
4382 |
| - | |
| 4326 | + | |
| 4327 | + | |
4383 | 4328 |
| |
4384 | 4329 |
| |
4385 | 4330 |
| |
4386 | 4331 |
| |
4387 |
| - | |
4388 |
| - | |
4389 |
| - | |
4390 | 4332 |
| |
4391 | 4333 |
| |
4392 | 4334 |
| |
| |||
4423 | 4365 |
| |
4424 | 4366 |
| |
4425 | 4367 |
| |
4426 |
| - | |
4427 |
| - | |
4428 |
| - | |
4429 |
| - | |
4430 |
| - | |
4431 |
| - | |
4432 |
| - | |
4433 |
| - | |
4434 |
| - | |
4435 |
| - | |
4436 |
| - | |
4437 |
| - | |
4438 |
| - | |
4439 |
| - | |
4440 |
| - | |
4441 |
| - | |
4442 |
| - | |
4443 |
| - | |
4444 |
| - | |
4445 |
| - | |
| 4368 | + | |
| 4369 | + | |
4446 | 4370 |
| |
4447 | 4371 |
| |
4448 | 4372 |
| |
4449 | 4373 |
| |
4450 | 4374 |
| |
4451 | 4375 |
| |
4452 |
| - | |
4453 |
| - | |
4454 |
| - | |
4455 |
| - | |
4456 |
| - | |
4457 |
| - | |
4458 |
| - | |
4459 |
| - | |
4460 |
| - | |
4461 |
| - | |
4462 |
| - | |
4463 |
| - | |
4464 |
| - | |
4465 |
| - | |
4466 |
| - | |
4467 |
| - | |
4468 |
| - | |
4469 |
| - | |
4470 |
| - | |
4471 |
| - | |
4472 |
| - | |
4473 |
| - | |
4474 |
| - | |
4475 |
| - | |
4476 |
| - | |
4477 |
| - | |
4478 |
| - | |
4479 |
| - | |
4480 |
| - | |
4481 |
| - | |
4482 |
| - | |
4483 |
| - | |
4484 |
| - | |
4485 |
| - | |
4486 |
| - | |
4487 |
| - | |
4488 |
| - | |
4489 |
| - | |
4490 |
| - | |
4491 |
| - | |
4492 |
| - | |
4493 |
| - | |
4494 |
| - | |
4495 |
| - | |
4496 |
| - | |
4497 |
| - | |
4498 |
| - | |
4499 |
| - | |
4500 |
| - | |
4501 |
| - | |
4502 |
| - | |
4503 |
| - | |
4504 |
| - | |
4505 |
| - | |
4506 |
| - | |
4507 |
| - | |
4508 |
| - | |
4509 |
| - | |
4510 |
| - | |
4511 |
| - | |
4512 |
| - | |
4513 |
| - | |
4514 |
| - | |
4515 |
| - | |
4516 |
| - | |
4517 |
| - | |
4518 |
| - | |
4519 |
| - | |
4520 |
| - | |
4521 |
| - | |
4522 |
| - | |
4523 |
| - | |
4524 |
| - | |
4525 |
| - | |
4526 |
| - | |
4527 |
| - | |
4528 |
| - | |
4529 |
| - | |
4530 |
| - | |
4531 |
| - | |
4532 |
| - | |
4533 |
| - | |
4534 |
| - | |
4535 |
| - | |
4536 |
| - | |
4537 |
| - | |
4538 | 4376 |
| |
4539 | 4377 |
| |
4540 | 4378 |
| |
|
Lines changed: 5 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
41 | 41 |
| |
42 | 42 |
| |
43 | 43 |
| |
| 44 | + | |
44 | 45 |
| |
45 | 46 |
| |
46 | 47 |
| |
| |||
635 | 636 |
| |
636 | 637 |
| |
637 | 638 |
| |
638 |
| - | |
| 639 | + | |
639 | 640 |
| |
640 | 641 |
| |
641 | 642 |
| |
| |||
1616 | 1617 |
| |
1617 | 1618 |
| |
1618 | 1619 |
| |
1619 |
| - | |
| 1620 | + | |
1620 | 1621 |
| |
1621 | 1622 |
| |
1622 | 1623 |
| |
| |||
2131 | 2132 |
| |
2132 | 2133 |
| |
2133 | 2134 |
| |
2134 |
| - | |
| 2135 | + | |
2135 | 2136 |
| |
2136 | 2137 |
| |
2137 | 2138 |
| |
| |||
2204 | 2205 |
| |
2205 | 2206 |
| |
2206 | 2207 |
| |
2207 |
| - | |
| 2208 | + | |
2208 | 2209 |
| |
2209 | 2210 |
| |
2210 | 2211 |
| |
|
0 commit comments
Comments
(0)