model-writtenrun 3872 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Justin Pryzby reported and reproduced a tuple-concurrently-deleted error when DROP STATISTICS ran alongside ANALYZE on PostgreSQL 11–16 in #1.
- Tomas Vondra traced the race to ANALYZE deleting and replacing statistics data, explaining that updating instead would still fail under concurrency in #2; Tom Lane proposed having DROP STATISTICS lock the associated table against ANALYZE in #3.
- Tomas attached #4, moving statistics-data deletion after acquisition of an AccessExclusiveLock in RemoveStatisticsById() and retaining that lock until transaction end, while leaving ANALYZE's direct data-removal path unchanged.
- Tom judged the patch generally correct but recommended ShareUpdateExclusiveLock to avoid blocking ordinary readers and writers in #5, and Tomas accepted that correction in #6.
- Tomas committed the patch with the weaker lock and revised comments as 28f84f72fb, backpatched through PostgreSQL 12, and announced completion in #7, explaining that older branches also needed a static RemoveStatisticsDataById() helper because their statistics-storage implementation differed.