model-writtenrun 8385 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Kyotaro Horiguchi reported that UpdateSpillStats() logged while holding a spinlock even though the logged reorder-buffer fields did not require that protection, and supplied a patch moving the logging outside the locked section #1.
- Amit Kapila and Fujii Masao approved the patch, and Fujii committed it unchanged as caa3c4242c #2 #3 #4.
- Michael Paquier found a separate longstanding violation in LogicalIncreaseRestartDecodingForSlot() and supplied a patch releasing the mutex before logging, copying shared values into locals where necessary #6.
- Tom Lane posted an experimental runtime checker that tracked the held spinlock and asserted against unsafe operations; check-world found no additional problems initially, but limited test coverage and expanded header dependencies remained concerns, and Tom supported backpatching Michael's fix because older elog implementations were more hazardous #8.
- Extending the checker to allocation routines exposed pstrdup() calls inside copy_replication_slot() spinlocks; Tom proposed copying whole ReplicationSlot structures into local variables, flagged namecpy() calls in pg_get_replication_slots(), and then identified another allocation in InvalidateObsoleteReplicationSlots() #11 #14.
- Kyotaro audited 224 spinlock acquisition sites and listed additional string-copy operations; Tom's subsequent assessment accepted bounded memcpy() and strlcpy() operations, left a cosmetic StrNCpy() concern unchanged, suggested documenting the no-error requirement for proclist helpers, and moved atomic-operation concerns to a separate discussion #15 #16.
- Tom committed the allocation repairs without an attached implementation patch as f88bd3139f, using local slot snapshots in slotfuncs.c and a stack NameData value in slot.c, also eliminating a leaked allocation and cleaning up related code discussed in #11 and #14.
- Michael committed his logical-decoding logging patch with only whitespace differences as c1669fd581 and confirmed backpatching through PostgreSQL 9.5 #6 #17.
- To reduce the runtime checker's header dependencies, Tom proposed declaring an assertion-only void pointer in a central header and making the check a no-op for frontend or non-assert builds, but no revised attachment or landing followed in this thread #18.
- Robert Haas proposed replacing some spinlocks with LWLocks; Tom highlighted the long pg_stat_statements critical section and suggested pooled LWLocks, then reconsidered per-entry LWLocks after Robert explained their current size, efficiency, contention behavior, and wait-event visibility #19 #20 #21 #22.
- Andres Freund discussed LWLock acquisition and release costs, possible spinning and fast-path optimizations, and optional size reductions; Robert considered the size reductions unnecessary and warned about determining lock information across dynamic shared-memory mappings #23 #24 #25.
- The thread ended with Andres experimenting with Clang annotations to detect unsafe calls without runtime coverage, but unannotated intermediary functions escaped detection and he could not enforce Tom's proposed ban on unannotated calls; the three targeted fixes had landed, while automated enforcement and broader lock replacement remained unresolved #26 #27 #28.