model-writtenrun 6332 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Neha Sharma reported that re-clustering an empty table crashed with CLOBBER_CACHE_ALWAYS enabled, with a stack trace showing a null storage-manager handle during heap-rewrite completion #1.
- Amul Sul traced the failure to cache invalidation clearing rd_smgr and supplied a patch reopening the handle before the final synchronization #2; Amit Langote endorsed the fix and raised the possibility of similar hazards elsewhere #3.
- Michael Paquier reproduced and bisected the failure #6 #7, but Tom Lane explained that the apparent regression merely changed the planner's choice and exposed an existing empty-table path missing from regression coverage #8.
- Tom Lane committed Amul Sul's targeted fix as 9d523119fd, adding comments and an empty-table regression test and backpatching to PostgreSQL 13; he identified the underlying mistake as replacing heap_sync() with a direct smgrimmedsync() call lacking the opening safeguard #9.
- Tom Lane then proposed preventing this class of bug by replacing direct rd_smgr access with RelationGetSmgr() #11, choosing an inline function to avoid macro multiple-evaluation hazards #13; Amul Sul implemented the broader conversion #15.
- Michael Paquier requested removal of the remaining heap.c call and the obsolete RelationOpenSmgr() macro #17, and Amul Sul incorporated both changes #18.
- Kyotaro Horiguchi objected to cumbersome repeated accessor expressions and proposed temporary variables #19 #25, which Amul Sul introduced for nearby calls and loops #26.
- The release discussion distinguished the already-fixed crash from the preventive refactoring: Michael Paquier opposed treating the latter as an open bug #22, and Tom Lane favored deferring it to PostgreSQL 15 because the details lacked consensus #23.
- After the gap to July, Anastasia Lubennikova reported successful testing and a favorable review of the temporary-variable version #27.
- Tom Lane then warned that retaining accessor results across other operations could recreate the same dangling-pointer hazard the refactoring aimed to prevent #28; Amul Sul agreed and submitted a revision restoring repeated accessor calls in many callers #29 #30.
- Alvaro Herrera requested an explanation of the accessor's purpose #31, and Amul Sul added guidance against retaining its result #32.
- Tom Lane committed the final attachment with further local safety edits and expanded comments as f10f0ae420, including fresh accessor calls in truncation paths and defensive error-path handling in RelationCopyStorage(); his announcement emphasized that RelationCopyStorage() must continue avoiding operations that could flush the relcache #33.
- The thread ended with Amul Sul's thanks #34, with both the crash fix and preventive refactoring committed and no attached patch left pending, while the documented RelationCopyStorage() lifetime constraint remained a maintenance concern #33.