Re: BUG #17255: Server crashes in index_delete_sort_cmp() due to race condition with vacuum
Alexander Law <exclusion@gmail.com>
From: Alexander Lakhin <exclusion@gmail.com>
To: Dmitry Dolgov <9erthalion6@gmail.com>, Andres Freund
<andres@anarazel.de>, Peter Geoghegan <pg@bowt.ie>,
Matthias van de Meent <boekewurm+postgres@gmail.com>
Cc: pgsql-bugs@lists.postgresql.org
Date: 2021-11-07T18:00:00Z
Lists: pgsql-bugs
31.10.2021 22:20, Dmitry Dolgov wrote: >> >> I suspect this is the same bug as #17245. Could you check if it's fixed by >> https://www.postgresql.org/message-id/CAH2-WzkN5aESSLfK7-yrYgsXxYUi__VzG4XpZFwXm98LUtoWuQ%40mail.gmail.com >> >> The crash is somewhere in pg_class, which is also manually VACUUMed by the >> test, which could trigger the issue we found in the other thread. The likely >> reason the loop in the repro is needed is that that'll push one of the indexes >> on pg_class over the 512kb/min_parallel_index_scan_size boundary to start >> using paralell vacuum. > I've applied both patches from Peter, the fix itself and > index-points-to-LP_UNUSED-item assertions. Now it doesn't crash on > pg_unreachable, but hits those extra assertions in the second patch: Yes, the committed fix for the bug #17245 doesn't help here. I've also noticed that the server crash is not the only possible outcome. You can also get unexpected errors like: ERROR: relation "errtst_parent" already exists ERROR: relation "tmp_idx1" already exists ERROR: relation "errtst_child_plaindef" already exists or ERROR: could not open relation with OID 1033921 STATEMENT: DROP TABLE errtst_parent; in the server.log (and no crash). These strange errors and the crash inside index_delete_sort_cmp() can be seen starting from the commit dc7420c2. On the previous commit (b8443eae) the reproducing script completes without a crash or errors (triple-checked). Probably, the bug #17257 has the same root cause, but the patch [1] applied to REL_14_STABLE (b0f6bd48) doesn't prevent the crash. Initially I've thought that the infinite loop in vacuum is a problem itself, so I decided to separate that one, but maybe both bugs are too related to be discussed apart. Best regards, Alexander [1] https://www.postgresql.org/message-id/CAEze2Wj7O5tnM_U151Baxr5ObTJafwH%3D71_JEmgJV%2B6eBgjL7g%40mail.gmail.com
Commits
-
vacuumlazy.c: Standardize rel_pages terminology.
- e370f100f05d 15.0 landed
-
vacuumlazy.c: document vistest and OldestXmin.
- 73f6ec3d3c8d 15.0 landed
-
heap pruning: Only call BufferGetBlockNumber() once.
- c702d656a283 15.0 landed
-
Fix possible HOT corruption when RECENTLY_DEAD changes to DEAD while pruning.
- dad1539aec28 14.2 landed
- 18b87b201f73 15.0 landed
-
Assert redirect pointers are sensible after heap_page_prune().
- bb42bfb5ccb5 15.0 landed
-
Remove tupgone special case from vacuumlazy.c.
- 8523492d4e34 14.0 cited
-
Recycle nbtree pages deleted during same VACUUM.
- 9dd963ae2534 14.0 cited
-
snapshot scalability: Don't compute global horizons while building snapshots.
- dc7420c2c927 14.0 cited
-
Refactor heap_page_prune so that instead of changing item states on-the-fly,
- 6f10eb21118f 8.4.0 cited