News for hackers. Stuff that matters.
Re:When Sigterm Does Nothing: A Postgres Mystery by gpavanb on Tuesday July 15, 2025 @11:04PM (#44578286)
I'd be happy to make the changes to the codebase but there's definitely scope for improvement. Putting a sleep to avoid repeated lock acquisition should have raised an eyebrow or two when it was implemented.

As mentioned, there should be a read-replica specific code that works using event listeners. Repurposing the primary's code is what causes the issue.

The following pseudocode would give a better picture on the next steps

// Read replica specific implementation

void StandbyWaitForTransactionCompletion(TransactionId xid) {

// Register to receive WAL notifications about this transaction RegisterForWALNotification(xid);

    while (TransactionIdIsInProgress(xid)) {
        // Wait for WAL record indicating transaction completion
        WaitForWALEvent();
        CHECK_FOR_INTERRUPTS();
        
        // Process any incoming WAL records
        ProcessIncomingWAL();
    }
    
    UnregisterForWALNotification(xid);
}
Re:When Sigterm Does Nothing: A Postgres Mystery by anarazel on Wednesday July 16, 2025 @11:01AM (#44583087)
This has absolutely nothing to do with the problem at hand.