forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitd8adfc1
committed
Avoid parallel nbtree index scan hangs with SAOPs.
Commit5bf748b, which enhanced nbtree ScalarArrayOp execution, madeparallel index scans work with the new design for arrays via explicitscheduling of primitive index scans. A backend that successfullyscheduled the scan's next primitive index scan saved its backend localarray keys in shared memory. Any backend could pick up the scheduledprimitive scan within _bt_first. This scheme decouples scheduling aprimitive scan from starting the scan (by performing another descent ofthe index via a _bt_search call from _bt_first) to make things robust.The scheme had a deadlock hazard, at least when the leader processparticipated in the scan. _bt_parallel_seize had a code path that madebackends that were not in an immediate position to start a scheduledprimitive index scan wait for some other backend to do so instead.Under the right circumstances, the leader process could wait hereforever: the leader would wait for any other backend to start theprimitive scan, while every worker was busy waiting on the leader toconsume tuples from the scan's tuple queue.To fix, don't wait for a scheduled primitive index scan to be started bysome other eligible backend from within _bt_parallel_seize (when thecalling backend isn't in a position to do so itself). Return falseinstead, while recording that the scan has a scheduled primitive indexscan in backend local state. This leaves the backend in the same stateas the existing case where a backend schedules (or tries to schedule)another primitive index scan from within _bt_advance_array_keys, beforecalling _bt_parallel_seize. _bt_parallel_seize already handles thatcase by returning false without waiting, and without unsetting thebackend local state. Leaving the backend in this state enables it tostart a previously scheduled primitive index scan once it gets back to_bt_first.Oversight in commit5bf748b, which enhanced nbtree ScalarArrayOpexecution.Matthias van de Meent, with tweaks by me.Author: Matthias van de Meent <boekewurm+postgres@gmail.com>Reported-By: Tomas Vondra <tomas@vondra.me>Reviewed-By: Peter Geoghegan <pg@bowt.ie>Discussion:https://postgr.es/m/CAH2-WzmMGaPa32u9x_FvEbPTUkP5e95i=QxR8054nvCRydP-sw@mail.gmail.comBackpatch: 17-, where nbtree SAOP execution was enhanced.1 parent89f908a commitd8adfc1
1 file changed
+33
-20
lines changedLines changed: 33 additions & 20 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
584 | 584 |
| |
585 | 585 |
| |
586 | 586 |
| |
587 |
| - | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
588 | 591 |
| |
589 | 592 |
| |
590 | 593 |
| |
| |||
595 | 598 |
| |
596 | 599 |
| |
597 | 600 |
| |
598 |
| - | |
599 |
| - | |
600 |
| - | |
601 |
| - | |
602 | 601 |
| |
603 | 602 |
| |
604 | 603 |
| |
| |||
615 | 614 |
| |
616 | 615 |
| |
617 | 616 |
| |
618 |
| - | |
619 |
| - | |
620 |
| - | |
621 |
| - | |
622 |
| - | |
623 |
| - | |
624 |
| - | |
| 617 | + | |
625 | 618 |
| |
626 | 619 |
| |
627 | 620 |
| |
628 | 621 |
| |
629 | 622 |
| |
630 | 623 |
| |
631 | 624 |
| |
632 |
| - | |
633 |
| - | |
| 625 | + | |
| 626 | + | |
634 | 627 |
| |
635 | 628 |
| |
636 | 629 |
| |
| |||
652 | 645 |
| |
653 | 646 |
| |
654 | 647 |
| |
655 |
| - | |
656 |
| - | |
657 |
| - | |
658 |
| - | |
659 | 648 |
| |
660 | 649 |
| |
| 650 | + | |
661 | 651 |
| |
662 | 652 |
| |
663 | 653 |
| |
| |||
667 | 657 |
| |
668 | 658 |
| |
669 | 659 |
| |
670 |
| - | |
671 |
| - | |
672 | 660 |
| |
673 | 661 |
| |
674 | 662 |
| |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
675 | 679 |
| |
676 | 680 |
| |
677 | 681 |
| |
| |||
730 | 734 |
| |
731 | 735 |
| |
732 | 736 |
| |
| 737 | + | |
733 | 738 |
| |
734 | 739 |
| |
735 | 740 |
| |
| |||
738 | 743 |
| |
739 | 744 |
| |
740 | 745 |
| |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
741 | 753 |
| |
742 | 754 |
| |
743 | 755 |
| |
| |||
746 | 758 |
| |
747 | 759 |
| |
748 | 760 |
| |
| 761 | + | |
749 | 762 |
| |
750 | 763 |
| |
751 | 764 |
| |
|
0 commit comments
Comments
(0)