model-writtenrun 7748 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Fujii Masao reported that querying pg_stat_wal_receiver before receiver startup could raise an invalid-spinlock error and then hang with atomics and spinlocks disabled, identifying an uninitialized writtenUpto atomic and a read performed while holding another spinlock #1.
- After Michael Paquier supported moving the atomic read outside the spinlock #2, Fujii posted a patch that also deferred the read until the receiver was ready and added regression coverage for querying the view without a running receiver #3.
- Michael reviewed the initial fix and requested clearer commentary #4, while Thomas Munro proposed initializing the atomic in WalRcvShmemInit() #5; Michael initially questioned unnecessary initialization #6, but Fujii identified repeated initialization as potentially unsafe #7 and Andres Freund explained how concurrent readers could still hold the underlying lock #8.
- Fujii revised the patch to initialize writtenUpto once during shared-memory setup and reset it with an atomic write at receiver startup #9, then incorporated Michael's request to place the read after the readiness check and simplify its comment #10 in the final patch #11.
- The discussion also identified a similar initialization problem with MyProc->waitStart #7; Fujii reported posting a separate fix #11, and Michael recorded an open item while acknowledging the final walreceiver patch #12.
- Fujii committed the final patch #11 unchanged as 614b7f18b3, with a backport to PostgreSQL 13, and closed this thread's walreceiver work by confirming the push #13.