model-writtenrun 6840 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Virender Singla reported that index-scan reorder queues could lose a tuple's ctid, producing wrong results and potentially corrupting a table during row locking, and proposed restoring tts_tid in the buffer-slot branch of ExecForceStoreHeapTuple() in #1.
- Greg Burd reported an independently developed equivalent fix in #3, and Dilip Kumar endorsed the missing-assignment diagnosis in #4; Greg then combined the work in #5, replacing ineffective LIMIT 1 tests with polygon-based LIMIT 5 checks that actually exercised queued tuples.
- Andres Freund recommended materializing test results, checking execution plans, simplifying the test data, and adding protection against invalid-TID locking in #6; Greg expanded the patch into a fix, a reorder-queue assertion, and a table-AM locking guard in #7, while leaving a suspected slot-copy issue untouched because he could not demonstrate it.
- Virender verified the expanded series in #8, but Nikolay Samokhvalov found that the promised NOT EXISTS test was absent and that the guard missed invalid block numbers with nonzero offsets in #10; Greg corrected the test and moved the guard into heapam_tuple_lock() in #11.
- Andres pointed out that virtual slots also needed their TID maintained in #13 and supplied a routed foreign-table INSERT RETURNING reproducer in #14, while also reporting a separate concern about cross-partition updates and partition constraints.
- Greg generalized the fix to all slot types by saving the incoming TID before any tuple freeing and assigning it at function exit in #15; he dropped the auxiliary checks after finding that non-heap table AMs could legitimately produce queued heap tuples without valid TIDs, and reduced the GiST tests.
- Greg corrected his earlier claim that the FDW reproducer required another fix in #16, confirmed that the generalized assignment already solved it, and added postgres_fdw regression coverage; the separate cross-partition update concern remained unreproduced.
- Shihao Zhong reproduced actual table corruption after restart on a non-assert build and verified that the patch prevented it in #17; Greg incorporated that explanation and testing credit into #18 and reported successful testing across supported branches.
- Nathan Bossart posted the staged fix without regression tests in #19, explaining that tests and additional checks could wait so the essential repair would reach the November releases.
- Heikki Linnakangas questioned the staged comment and saved TID in #21; Greg demonstrated in #22 that reading the original tuple at function exit could access freed memory and explained why the saved copy was necessary for that implementation.
- Nathan instead placed direct TID assignments inside the buffer and virtual branches before tuple freeing, removed the comment, and committed the two-line fix as 4e9a5dc1f5, with backports through PostgreSQL 14, confirming the final adjustment in #24; the source is this thread's staged patch #19, which superseded the earlier contribution in thread #253715.
- Greg accepted the final implementation in #25; the main fix had landed, while regression tests and defensive checks remained outside the commit and the separate cross-partition update concern had no resolution in this thread.