forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit9358297
committed
freespace: Don't return blocks past the end of the main fork.
GetPageWithFreeSpace() callers assume the returned block exists in themain fork, failing with "could not read block" errors if that doesn'thold. Make that assumption reliable now. It hadn't been guaranteed,due to the weak WAL and data ordering of participating components. Mostoperations on the fsm fork are not WAL-logged. Relation extension isnot WAL-logged. Hence, an fsm-fork block on disk can reference amain-fork block that no WAL record has initialized. That could happenafter an OS crash, a replica promote, or a PITR restore. wal_log_hintsmakes the trouble easier to hit; a replica promote or PITR ending justafter a relevant fsm-fork FPI_FOR_HINT may yield this broken state. Thev16 RelationAddBlocks() mechanism also makes the trouble easier to hit,since it bulk-extends even without extension lock waiters. Commit917dc7d stopped trouble aroundtruncation, but vectors involving PageIsNew() pages remained.This implementation adds a RelationGetNumberOfBlocks() call when thecached relation size doesn't confirm a block exists. We've been unableto identify a benchmark that slows materially, but this may show up asadditional time in lseek(). An alternative without that overhead wouldbe a new ReadBufferMode such that ReadBufferExtended() returns NULLafter a 0-byte read, with all other errors handled normally. However,each GetFreeIndexPage() caller would then need code for the return-NULLcase. Back-patch to v14, due to earlier versions not caching relationsize and the absence of a pre-v16 problem report.Ronan Dunklau. Reported by Ronan Dunklau.Discussion:https://postgr.es/m/1878547.tdWV9SEqCh%40aivenlaptop1 parent68ba46d commit9358297
File tree
4 files changed
+112
-20
lines changed- src
- backend/storage
- freespace
- smgr
- test/recovery/t
4 files changed
+112
-20
lines changedLines changed: 13 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
169 | 169 |
| |
170 | 170 |
| |
171 | 171 |
| |
172 |
| - | |
173 |
| - | |
174 |
| - | |
| 172 | + | |
175 | 173 |
| |
176 | 174 |
| |
177 | 175 |
| |
| |||
188 | 186 |
| |
189 | 187 |
| |
190 | 188 |
| |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
191 | 201 |
| |
192 | 202 |
| |
193 | 203 |
| |
|
Lines changed: 94 additions & 12 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
112 | 112 |
| |
113 | 113 |
| |
114 | 114 |
| |
| 115 | + | |
115 | 116 |
| |
116 | 117 |
| |
117 | 118 |
| |
| |||
128 | 129 |
| |
129 | 130 |
| |
130 | 131 |
| |
| 132 | + | |
| 133 | + | |
| 134 | + | |
131 | 135 |
| |
132 | 136 |
| |
133 | 137 |
| |
| |||
166 | 170 |
| |
167 | 171 |
| |
168 | 172 |
| |
169 |
| - | |
170 |
| - | |
171 |
| - | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
172 | 184 |
| |
173 | 185 |
| |
174 | 186 |
| |
| |||
297 | 309 |
| |
298 | 310 |
| |
299 | 311 |
| |
300 |
| - | |
301 |
| - | |
302 |
| - | |
303 |
| - | |
304 |
| - | |
305 |
| - | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
306 | 317 |
| |
307 | 318 |
| |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
308 | 331 |
| |
309 | 332 |
| |
310 | 333 |
| |
| |||
674 | 697 |
| |
675 | 698 |
| |
676 | 699 |
| |
| 700 | + | |
677 | 701 |
| |
678 |
| - | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
679 | 709 |
| |
680 | 710 |
| |
681 | 711 |
| |
| |||
687 | 717 |
| |
688 | 718 |
| |
689 | 719 |
| |
690 |
| - | |
691 |
| - | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
692 | 751 |
| |
693 | 752 |
| |
694 | 753 |
| |
| |||
856 | 915 |
| |
857 | 916 |
| |
858 | 917 |
| |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + |
Lines changed: 3 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
679 | 679 |
| |
680 | 680 |
| |
681 | 681 |
| |
682 |
| - | |
683 |
| - | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
684 | 685 |
| |
685 | 686 |
| |
686 | 687 |
| |
|
Lines changed: 2 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1 | 1 |
| |
2 | 2 |
| |
3 | 3 |
| |
4 |
| - | |
5 |
| - | |
6 |
| - | |
| 4 | + | |
| 5 | + | |
7 | 6 |
| |
8 | 7 |
| |
9 | 8 |
| |
|
0 commit comments
Comments
(0)