forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit0d1fe9f
committed
Move page initialization from RelationAddExtraBlocks() to use, take 2.
Previously we initialized pages when bulk extending inRelationAddExtraBlocks(). That has a major disadvantage: It tiesRelationAddExtraBlocks() to heap, as other types of storage are likelyto need different amounts of special space, have different amount offree space (previously determined by PageGetHeapFreeSpace()).That we're relying on initializing pages, but not WAL logging theinitialization, also means the risk for getting"WARNING: relation \"%s\" page %u is uninitialized --- fixing"style warnings in vacuums after crashes/immediate shutdowns, isconsiderably higher. The warning sounds much more serious than whatthey are.Fix those two issues together by not initializing pages inRelationAddExtraPages() (but continue to do so inRelationGetBufferForTuple(), which is linked much more closely toheap), and accepting uninitialized pages as normal invacuumlazy.c. When vacuumlazy encounters an empty page it now adds itto the FSM, but does nothing else. We chose to not issue a debugmessage, much less a warning in that case - it seems rarely useful,and quite likely to scare people unnecessarily.For now empty pages aren't added to the VM, because standbys would notre-discover such pages after a promotion. In contrast to other sourcesfor empty pages, there's no corresponding WAL records triggering FSMupdates during replay.Previously when extending the relation, there was a moment betweenextending the relation, and acquiring an exclusive lock on the newpage, in which another backend could lock the page. To avoid newcontent being put on that new page, vacuumlazy needed to acquire theextension lock for a brief moment when encountering a new page. Asecond corner case, only working somewhat by accident, was thatRelationGetBufferForTuple() sometimes checks the last page in arelation for free space, without consulting the FSM; that only workedbecause PageGetHeapFreeSpace() interprets the zero page header in anew page as no free space. The lack of handling this properlyrequired reverting the previous attempt in6842005.This issue can be solved by using RBM_ZERO_AND_LOCK when extending therelation, thereby avoiding this window. There's some added complexitywhen RelationGetBufferForTuple() is called with another buffer (forupdates), to avoid deadlocks, but that's rarely hit at runtime.Author: Andres FreundReviewed-By: Tom LaneDiscussion:https://postgr.es/m/20181219083945.6khtgm36mivonhva@alap3.anarazel.de1 parentac3a9af commit0d1fe9f
2 files changed
+126
-75
lines changedLines changed: 82 additions & 37 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
74 | 74 |
| |
75 | 75 |
| |
76 | 76 |
| |
77 |
| - | |
| 77 | + | |
78 | 78 |
| |
79 | 79 |
| |
80 | 80 |
| |
81 |
| - | |
| 81 | + | |
82 | 82 |
| |
83 | 83 |
| |
84 | 84 |
| |
85 | 85 |
| |
86 | 86 |
| |
87 |
| - | |
| 87 | + | |
| 88 | + | |
88 | 89 |
| |
89 | 90 |
| |
90 | 91 |
| |
91 | 92 |
| |
92 | 93 |
| |
93 | 94 |
| |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
94 | 102 |
| |
95 | 103 |
| |
96 | 104 |
| |
| |||
101 | 109 |
| |
102 | 110 |
| |
103 | 111 |
| |
104 |
| - | |
| 112 | + | |
105 | 113 |
| |
106 | 114 |
| |
107 | 115 |
| |
| |||
204 | 212 |
| |
205 | 213 |
| |
206 | 214 |
| |
207 |
| - | |
| 215 | + | |
| 216 | + | |
208 | 217 |
| |
209 |
| - | |
210 |
| - | |
211 |
| - | |
| 218 | + | |
212 | 219 |
| |
213 | 220 |
| |
214 | 221 |
| |
215 | 222 |
| |
216 | 223 |
| |
217 | 224 |
| |
218 | 225 |
| |
219 |
| - | |
220 |
| - | |
221 | 226 |
| |
222 |
| - | |
223 |
| - | |
224 |
| - | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
225 | 233 |
| |
226 |
| - | |
227 | 234 |
| |
228 | 235 |
| |
229 | 236 |
| |
230 |
| - | |
| 237 | + | |
231 | 238 |
| |
232 | 239 |
| |
233 | 240 |
| |
| |||
412 | 419 |
| |
413 | 420 |
| |
414 | 421 |
| |
415 |
| - | |
| 422 | + | |
416 | 423 |
| |
417 | 424 |
| |
418 | 425 |
| |
| |||
479 | 486 |
| |
480 | 487 |
| |
481 | 488 |
| |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
482 | 502 |
| |
483 | 503 |
| |
484 | 504 |
| |
| |||
571 | 591 |
| |
572 | 592 |
| |
573 | 593 |
| |
574 |
| - | |
| 594 | + | |
575 | 595 |
| |
576 | 596 |
| |
577 |
| - | |
578 |
| - | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
579 | 600 |
| |
580 |
| - | |
581 |
| - | |
| 601 | + | |
582 | 602 |
| |
583 |
| - | |
584 |
| - | |
585 |
| - | |
586 |
| - | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
587 | 610 |
| |
588 | 611 |
| |
589 | 612 |
| |
590 |
| - | |
591 |
| - | |
592 |
| - | |
| 613 | + | |
593 | 614 |
| |
594 | 615 |
| |
595 | 616 |
| |
596 | 617 |
| |
597 | 618 |
| |
598 |
| - | |
599 |
| - | |
600 |
| - | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
601 | 630 |
| |
602 |
| - | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
603 | 634 |
| |
604 |
| - | |
605 |
| - | |
606 |
| - | |
607 |
| - | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
608 | 640 |
| |
609 |
| - | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
610 | 655 |
| |
611 | 656 |
| |
612 | 657 |
| |
|
Lines changed: 44 additions & 38 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
860 | 860 |
| |
861 | 861 |
| |
862 | 862 |
| |
| 863 | + | |
| 864 | + | |
863 | 865 |
| |
864 |
| - | |
865 |
| - | |
866 |
| - | |
867 |
| - | |
868 |
| - | |
869 |
| - | |
870 |
| - | |
871 |
| - | |
872 |
| - | |
873 |
| - | |
874 |
| - | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
875 | 871 |
| |
876 |
| - | |
877 |
| - | |
878 |
| - | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
879 | 875 |
| |
880 |
| - | |
881 |
| - | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
882 | 882 |
| |
883 |
| - | |
884 |
| - | |
885 |
| - | |
886 |
| - | |
887 |
| - | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
888 | 892 |
| |
889 |
| - | |
890 |
| - | |
891 |
| - | |
892 |
| - | |
893 | 893 |
| |
894 |
| - | |
895 |
| - | |
896 |
| - | |
897 |
| - | |
898 | 894 |
| |
899 |
| - | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
900 | 903 |
| |
901 | 904 |
| |
902 | 905 |
| |
| |||
905 | 908 |
| |
906 | 909 |
| |
907 | 910 |
| |
908 |
| - | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
909 | 915 |
| |
910 | 916 |
| |
911 | 917 |
| |
| |||
1639 | 1645 |
| |
1640 | 1646 |
| |
1641 | 1647 |
| |
1642 |
| - | |
1643 |
| - | |
1644 |
| - | |
1645 |
| - | |
1646 |
| - | |
1647 |
| - | |
| 1648 | + | |
| 1649 | + | |
| 1650 | + | |
| 1651 | + | |
| 1652 | + | |
| 1653 | + | |
| 1654 | + | |
1648 | 1655 |
| |
1649 | 1656 |
| |
1650 | 1657 |
| |
| |||
2029 | 2036 |
| |
2030 | 2037 |
| |
2031 | 2038 |
| |
2032 |
| - | |
2033 | 2039 |
| |
2034 | 2040 |
| |
2035 | 2041 |
| |
|
0 commit comments
Comments
(0)