forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitbe504a3
committed
Fix corruption due to vacuum_defer_cleanup_age underflowing 64bit xids
When vacuum_defer_cleanup_age is bigger than the current xid, including theepoch, the subtraction of vacuum_defer_cleanup_age would lead to a wrappedaround xid. While that normally is not a problem, the subsequent conversion toa 64bit xid results in a 64bit-xid very far into the future. As that xid isused as a horizon to detect whether rows versions are old enough to beremoved, that allows removal of rows that are still visible (i.e. corruption).If vacuum_defer_cleanup_age was never changed from the default, there is nochance of this bug occurring.This bug was introduced indc7420c. A lesser version of it exists in12-13, introduced byfb5344c, affecting only GiST.The 12-13 version of the issue can, in rare cases, lead to pages in a gistindex getting recycled too early, potentially causing index entries to befound multiple times.The fix is fairly simple - don't allow vacuum_defer_cleanup_age to retreatfurther than FirstNormalTransactionId.Patches to make similar bugs easier to find, by adding asserts to the 64bitxid infrastructure, have been proposed, but are not suitable for backpatching.Currently there are no tests for vacuum_defer_cleanup_age. A patch introducinginfrastructure to make writing a test easier has been posted to the list.Reported-by: Michail Nikolaev <michail.nikolaev@gmail.com>Reviewed-by: Matthias van de Meent <boekewurm+postgres@gmail.com>Author: Andres Freund <andres@anarazel.de>Discussion:https://postgr.es/m/20230108002923.cyoser3ttmt63bfn@awork3.anarazel.deBackpatch: 12-, but impact/fix is smaller for 12-131 parenta4e0033 commitbe504a3
1 file changed
+73
-12
lines changedLines changed: 73 additions & 12 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
367 | 367 |
| |
368 | 368 |
| |
369 | 369 |
| |
| 370 | + | |
| 371 | + | |
| 372 | + | |
370 | 373 |
| |
371 | 374 |
| |
372 | 375 |
| |
| |||
1888 | 1891 |
| |
1889 | 1892 |
| |
1890 | 1893 |
| |
| 1894 | + | |
| 1895 | + | |
| 1896 | + | |
| 1897 | + | |
1891 | 1898 |
| |
1892 |
| - | |
1893 |
| - | |
1894 |
| - | |
1895 |
| - | |
1896 |
| - | |
1897 |
| - | |
1898 |
| - | |
1899 |
| - | |
1900 |
| - | |
1901 |
| - | |
| 1899 | + | |
| 1900 | + | |
| 1901 | + | |
| 1902 | + | |
| 1903 | + | |
| 1904 | + | |
| 1905 | + | |
| 1906 | + | |
| 1907 | + | |
| 1908 | + | |
| 1909 | + | |
| 1910 | + | |
| 1911 | + | |
| 1912 | + | |
| 1913 | + | |
| 1914 | + | |
| 1915 | + | |
| 1916 | + | |
| 1917 | + | |
| 1918 | + | |
| 1919 | + | |
| 1920 | + | |
| 1921 | + | |
| 1922 | + | |
1902 | 1923 |
| |
1903 | 1924 |
| |
1904 | 1925 |
| |
| |||
2470 | 2491 |
| |
2471 | 2492 |
| |
2472 | 2493 |
| |
2473 |
| - | |
2474 |
| - | |
| 2494 | + | |
| 2495 | + | |
| 2496 | + | |
| 2497 | + | |
2475 | 2498 |
| |
2476 | 2499 |
| |
2477 | 2500 |
| |
| |||
4295 | 4318 |
| |
4296 | 4319 |
| |
4297 | 4320 |
| |
| 4321 | + | |
| 4322 | + | |
| 4323 | + | |
| 4324 | + | |
| 4325 | + | |
| 4326 | + | |
| 4327 | + | |
| 4328 | + | |
| 4329 | + | |
| 4330 | + | |
| 4331 | + | |
| 4332 | + | |
| 4333 | + | |
| 4334 | + | |
| 4335 | + | |
| 4336 | + | |
| 4337 | + | |
| 4338 | + | |
| 4339 | + | |
| 4340 | + | |
| 4341 | + | |
| 4342 | + | |
| 4343 | + | |
| 4344 | + | |
| 4345 | + | |
| 4346 | + | |
| 4347 | + | |
| 4348 | + | |
| 4349 | + | |
| 4350 | + | |
| 4351 | + | |
| 4352 | + | |
| 4353 | + | |
| 4354 | + | |
| 4355 | + | |
| 4356 | + | |
| 4357 | + | |
| 4358 | + | |
4298 | 4359 |
| |
4299 | 4360 |
| |
4300 | 4361 |
| |
|
0 commit comments
Comments
(0)