forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitd004147
committed
Fix nbtree metapage cache upgrade bug.
Commit857f9c3, which taught nbtree VACUUM to avoid unnecessaryindex scans, bumped the nbtree version number from 2 to 3, while addingthe ability for nbtree indexes to be upgraded on-the-fly. Variousassertions that assumed that an nbtree index was always on version 2 hadto be changed to accept any supported version (version 2 or 3 onPostgres 11).However, a few assertions were missed in the initial commit, all ofwhich were in code paths that cache a local copy of the metapagemetadata, where the index had been expected to be on the current version(no longer version 2) as a generic sanity check. Rather than simplyupdate the assertions, follow-up commit0a64b45 intentionally madethe metapage caching code update the per-backend cached metadata versionwithout changing the on-disk version at the same time. This could evenhappen when the planner needed to determine the height of a B-Tree forcosting purposes. The assertions only fail on Postgres v12 whenupgrading from v10, because they were adjusted to use the authoritativeshared memory metapage by v12's commitdd299df.To fix, remove the cache-only upgrade mechanism entirely, and update theassertions themselves to accept any supported version (go back to usingthe cached version in v12). The fix is almost a full revert of commit0a64b45 on the v11 branch.VACUUM only considers the authoritative metapage, and never bothers witha locally cached version, whereas everywhere else isn't interested inthe metapage fields that were added by commit857f9c3. It seemsunlikely that this bug has affected any user on v11.Reported-By: Christoph BergBug: #15896Discussion:https://postgr.es/m/15896-5b25e260fdb0b081%40postgresql.orgBackpatch: 11-, where VACUUM was taught to avoid unnecessary index scans.1 parentbc8393c commitd004147
3 files changed
+40
-77
lines changedLines changed: 36 additions & 75 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
33 | 33 |
| |
34 | 34 |
| |
35 | 35 |
| |
36 |
| - | |
37 | 36 |
| |
38 | 37 |
| |
39 | 38 |
| |
| |||
109 | 108 |
| |
110 | 109 |
| |
111 | 110 |
| |
112 |
| - | |
113 |
| - | |
114 |
| - | |
115 |
| - | |
116 |
| - | |
117 |
| - | |
118 |
| - | |
119 |
| - | |
120 |
| - | |
121 |
| - | |
122 |
| - | |
123 |
| - | |
124 |
| - | |
125 |
| - | |
126 |
| - | |
127 |
| - | |
128 |
| - | |
129 |
| - | |
130 |
| - | |
131 |
| - | |
132 |
| - | |
133 |
| - | |
134 |
| - | |
135 |
| - | |
136 |
| - | |
137 |
| - | |
138 |
| - | |
139 |
| - | |
140 |
| - | |
141 |
| - | |
142 |
| - | |
143 |
| - | |
144 |
| - | |
145 |
| - | |
146 |
| - | |
147 |
| - | |
148 |
| - | |
149 |
| - | |
150 |
| - | |
151 | 111 |
| |
152 | 112 |
| |
153 |
| - | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
154 | 118 |
| |
155 | 119 |
| |
156 | 120 |
| |
| |||
291 | 255 |
| |
292 | 256 |
| |
293 | 257 |
| |
294 |
| - | |
295 |
| - | |
296 | 258 |
| |
297 | 259 |
| |
298 | 260 |
| |
| |||
345 | 307 |
| |
346 | 308 |
| |
347 | 309 |
| |
348 |
| - | |
349 |
| - | |
350 |
| - | |
351 |
| - | |
352 |
| - | |
353 |
| - | |
354 |
| - | |
355 |
| - | |
356 |
| - | |
357 |
| - | |
358 |
| - | |
359 |
| - | |
360 |
| - | |
361 |
| - | |
362 |
| - | |
363 |
| - | |
364 |
| - | |
365 |
| - | |
366 |
| - | |
367 |
| - | |
| 310 | + | |
368 | 311 |
| |
369 | 312 |
| |
370 | 313 |
| |
371 | 314 |
| |
| 315 | + | |
| 316 | + | |
372 | 317 |
| |
373 | 318 |
| |
374 | 319 |
| |
| |||
410 | 355 |
| |
411 | 356 |
| |
412 | 357 |
| |
| 358 | + | |
| 359 | + | |
413 | 360 |
| |
414 | 361 |
| |
415 | 362 |
| |
| |||
471 | 418 |
| |
472 | 419 |
| |
473 | 420 |
| |
474 |
| - | |
| 421 | + | |
475 | 422 |
| |
476 | 423 |
| |
477 | 424 |
| |
| |||
483 | 430 |
| |
484 | 431 |
| |
485 | 432 |
| |
486 |
| - | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
487 | 436 |
| |
488 | 437 |
| |
489 | 438 |
| |
| |||
657 | 606 |
| |
658 | 607 |
| |
659 | 608 |
| |
660 |
| - | |
661 |
| - | |
662 |
| - | |
663 |
| - | |
664 |
| - | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
665 | 612 |
| |
666 | 613 |
| |
667 | 614 |
| |
668 | 615 |
| |
669 | 616 |
| |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
670 | 622 |
| |
671 | 623 |
| |
672 | 624 |
| |
| |||
707 | 659 |
| |
708 | 660 |
| |
709 | 661 |
| |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
710 | 668 |
| |
711 |
| - | |
712 |
| - | |
713 |
| - | |
714 |
| - | |
715 |
| - | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
716 | 672 |
| |
717 | 673 |
| |
718 | 674 |
| |
719 | 675 |
| |
720 | 676 |
| |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
721 | 682 |
| |
722 | 683 |
| |
723 | 684 |
| |
|
Lines changed: 2 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
107 | 107 |
| |
108 | 108 |
| |
109 | 109 |
| |
| 110 | + | |
| 111 | + | |
110 | 112 |
| |
111 | 113 |
| |
112 | 114 |
| |
|
Lines changed: 2 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
97 | 97 |
| |
98 | 98 |
| |
99 | 99 |
| |
100 |
| - | |
| 100 | + | |
101 | 101 |
| |
102 | 102 |
| |
103 | 103 |
| |
104 | 104 |
| |
105 |
| - | |
| 105 | + | |
106 | 106 |
| |
107 | 107 |
| |
108 | 108 |
| |
|
0 commit comments
Comments
(0)