Hi,

The recent discussion about reachedConsistency in [1] mentioned a
separate EXEC_BACKEND issue. When a connection is rejected after
recovery has reached consistency but before a hot standby snapshot is
ready, backend startup uses reachedConsistency to select the error
detail. On Unix systems using fork(), the backend inherits
reachedConsistency from the postmaster. In EXEC_BACKEND builds, this
process-local variable is not inherited by the backend. Consequently,
it reports:

DETAIL:  Consistent recovery state has not been yet reached.

instead of:

DETAIL:  Recovery snapshot is not yet ready for hot standby.

It also omits the associated hint about transactions with more than 64
subtransactions.

The attached patch passes reachedConsistency through
BackendStartupData, alongside canAcceptConnections, and uses the
captured value when choosing the connection error detail. This only
changes the reported DETAIL and HINT; connection acceptance and
recovery behavior are unaffected.

I tested this on Linux with both normal and EXEC_BACKEND builds. The
core regression tests passed under EXEC_BACKEND, and manual testing
confirmed the expected DETAIL and HINT. I have not tested it on
Windows.

Please review and share your feedback.

[1]: 
https://www.postgresql.org/message-id/flat/CA%2BUBoq2n2Zg9rKgMfUtUohzGssisF9cDeyjKqPrnRNFprEyX1Q%40mail.gmail.com

Best Regards,
Nitin Jadhav
Microsoft

Attachment: v1-0001-fix-recovery-connection-detail-in-exec-backend-builds.patch
Description: Binary data

Reply via email to