forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commita5736bf
committed
Fix traversal of half-frozen update chains
When some tuple versions in an update chain are frozen due to them beingolder than freeze_min_age, the xmax/xmin trail can become broken. Thisbreaks HOT (and probably other things). A subsequent VACUUM can breakthings in more serious ways, such as leaving orphan heap-only tupleswhose root HOT redirect items were removed. This can be seen becauseindex creation (or REINDEX) complain like ERROR: XX000: failed to find parent tuple for heap-only tuple at (0,7) in table "t"Because of relfrozenxid contraints, we cannot avoid the freezing of theearly tuples, so we must cope with the results: whenever we see an Xminof FrozenTransactionId, consider it a match for whatever the previousXmax value was.This problem seems to have appeared in 9.3 with multixact changes,though strictly speaking it seems unrelated.Since 9.4 we have commit37484ad "Change the way we mark tuples asfrozen", so the fix is simple: just compare the raw Xmin (still storedin the tuple header, since freezing merely set an infomask bit) to theXmax. But in 9.3 we rewrite the Xmin value to FrozenTransactionId, sothe original value is lost and we have nothing to compare the Xmax with.To cope with that case we need to compare the Xmin with FrozenXid,assume it's a match, and hope for the best. Sadly, since you canpg_upgrade a 9.3 instance containing half-frozen pages to newerreleases, we need to keep the old check in newer versions too, whichseems a bit brittle; I hope we can somehow get rid of that.I didn't optimize the new function for performance. The new coding isprobably a bit slower than before, since there is a function call ratherthan a straight comparison, but I'd rather have it work correctly thanbe fast but wrong.This is a followup after20b6552 fixed a few related problems.Apparently, in 9.6 and up there are more ways to get into trouble, butin 9.3 - 9.5 I cannot reproduce a problem anymore with this patch, sothere must be a separate bug.Reported-by: Peter GeogheganDiagnosed-by: Peter Geoghegan, Michael Paquier, Daniel Wood,Yi Wen Wong, ÁlvaroDiscussion:https://postgr.es/m/CAH2-Wznm4rCrhFAiwKPWTpEw2bXDtgROZK7jWWGucXeH3D1fmA@mail.gmail.com1 parentf49842d commita5736bf
File tree
4 files changed
+54
-11
lines changed- src
- backend
- access/heap
- executor
- include/access
4 files changed
+54
-11
lines changedLines changed: 47 additions & 5 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2074 | 2074 |
| |
2075 | 2075 |
| |
2076 | 2076 |
| |
2077 |
| - | |
2078 |
| - | |
| 2077 | + | |
2079 | 2078 |
| |
2080 | 2079 |
| |
2081 | 2080 |
| |
| |||
2261 | 2260 |
| |
2262 | 2261 |
| |
2263 | 2262 |
| |
2264 |
| - | |
| 2263 | + | |
2265 | 2264 |
| |
2266 | 2265 |
| |
2267 | 2266 |
| |
| |||
2293 | 2292 |
| |
2294 | 2293 |
| |
2295 | 2294 |
| |
| 2295 | + | |
| 2296 | + | |
| 2297 | + | |
| 2298 | + | |
| 2299 | + | |
| 2300 | + | |
| 2301 | + | |
| 2302 | + | |
| 2303 | + | |
| 2304 | + | |
| 2305 | + | |
| 2306 | + | |
| 2307 | + | |
| 2308 | + | |
| 2309 | + | |
| 2310 | + | |
| 2311 | + | |
| 2312 | + | |
| 2313 | + | |
| 2314 | + | |
| 2315 | + | |
| 2316 | + | |
| 2317 | + | |
| 2318 | + | |
| 2319 | + | |
| 2320 | + | |
| 2321 | + | |
| 2322 | + | |
| 2323 | + | |
| 2324 | + | |
| 2325 | + | |
| 2326 | + | |
| 2327 | + | |
| 2328 | + | |
| 2329 | + | |
| 2330 | + | |
| 2331 | + | |
| 2332 | + | |
| 2333 | + | |
| 2334 | + | |
| 2335 | + | |
| 2336 | + | |
| 2337 | + | |
| 2338 | + | |
2296 | 2339 |
| |
2297 | 2340 |
| |
2298 | 2341 |
| |
| |||
5712 | 5755 |
| |
5713 | 5756 |
| |
5714 | 5757 |
| |
5715 |
| - | |
5716 |
| - | |
| 5758 | + | |
5717 | 5759 |
| |
5718 | 5760 |
| |
5719 | 5761 |
| |
|
Lines changed: 2 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
473 | 473 |
| |
474 | 474 |
| |
475 | 475 |
| |
476 |
| - | |
| 476 | + | |
477 | 477 |
| |
478 | 478 |
| |
479 | 479 |
| |
| |||
813 | 813 |
| |
814 | 814 |
| |
815 | 815 |
| |
816 |
| - | |
| 816 | + | |
817 | 817 |
| |
818 | 818 |
| |
819 | 819 |
| |
|
Lines changed: 2 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2594 | 2594 |
| |
2595 | 2595 |
| |
2596 | 2596 |
| |
2597 |
| - | |
2598 |
| - | |
| 2597 | + | |
2599 | 2598 |
| |
2600 | 2599 |
| |
2601 | 2600 |
| |
| |||
2742 | 2741 |
| |
2743 | 2742 |
| |
2744 | 2743 |
| |
2745 |
| - | |
2746 |
| - | |
| 2744 | + | |
2747 | 2745 |
| |
2748 | 2746 |
| |
2749 | 2747 |
| |
|
Lines changed: 3 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
146 | 146 |
| |
147 | 147 |
| |
148 | 148 |
| |
| 149 | + | |
| 150 | + | |
| 151 | + | |
149 | 152 |
| |
150 | 153 |
| |
151 | 154 |
| |
|
0 commit comments
Comments
(0)