model-writtenrun 5906 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Alexey Ermakov reported missing TOAST chunks after concurrent reindexing of a TOAST index on PostgreSQL 13.4 #1; at Peter Geoghegan’s request, Maxim Boguk ran amcheck and confirmed missing index entries despite an intact B-tree structure #2 #3 #4.
- Application details supplied by Alexey helped Andres Freund reproduce the corruption on PostgreSQL 13 and development HEAD, then reduce the reproducer to ordinary inserts running alongside concurrent TOAST-index reindexing #10 #13 #14.
- Andres traced the failure to toast_save_datum() releasing its relation lock before transaction end, allowing concurrent reindexing to miss ongoing writes, and proposed either retaining that lock or making reindexing lock the parent table #15.
- Noah Misch favored retaining locks as the more future-proof solution, while Andres suggested considering both remedies and Michael Paquier raised the corresponding deletion path; Michael also clarified that concurrent reindexing permits TOAST indexes of ordinary tables, but not catalog tables #16 #18 #19 #23.
- Michael’s first patch implemented both remedies and introduced an isolation test that renamed TOAST relations using allow_system_table_mods, but he preferred retaining locks alone because the parent-table lookup added complexity and potential problems #24.
- Michael’s second patch removed parent-table locking, retained locks through transaction end for both saving and deleting TOAST values, and expanded testing across lock modes, commit, rollback, and table deletion after confirming that the deletion path also needed fixing #25.
- Nathan Bossart verified the corruption and its resolution, supported the simpler solution, and asked for comments explaining the retained locks #26; Michael added those comments and committed the second patch as f99870dd86, with no executable or test changes.
- Michael confirmed the fix was applied and backpatched through PostgreSQL 12, omitting the isolation test on that branch because allow_system_table_mods could not be changed at runtime #27; Nathan closed the thread with no concrete performance concern or further requested changes #28.