Add WALRCV_CONNECTING state to walreceiver
| От | Xuneng Zhou |
|---|---|
| Тема | Add WALRCV_CONNECTING state to walreceiver |
| Дата | |
| Msg-id | CABPTF7X_Jgmyk1FBVNf3tyAOKqU55LLpLMzWkGtEAb_jQWVN=g@mail.gmail.com обсуждение исходный текст |
| Ответы |
Re: Add WALRCV_CONNECTING state to walreceiver
|
| Список | pgsql-hackers |
Hi Hackers, Bug #19093 [1] reported that pg_stat_wal_receiver.status = 'streaming' does not accurately reflect streaming health. In that discussion, Noah noted that even before the reported regression, status = 'streaming' was unreliable because walreceiver sets it during early startup, before attempting a connection. He suggested: "Long-term, in master only, perhaps we should introduce another status like 'connecting'. Perhaps enact the connecting->streaming status transition just before tendering the first byte of streamed WAL to the startup process. Alternatively, enact that transition when the startup process accepts the first streamed byte." Michael and I also thought this could be a useful addition. This patch implements that suggestion by adding a new WALRCV_CONNECTING state. == Background == Currently, walreceiver transitions directly from STARTING to STREAMING early in WalReceiverMain(), before any WAL data has been received. This means status = 'streaming' can be observed even when: - The connection to the primary has not been established - No WAL data has actually been received or flushed This makes it difficult for monitoring tools to distinguish between a healthy streaming replica and one that is merely attempting to stream. == Proposal == Introduce WALRCV_CONNECTING as an intermediate state between STARTING and STREAMING: - When walreceiver starts, it enters CONNECTING (instead of going directly to STREAMING). - The transition to STREAMING occurs in XLogWalRcvFlush(), inside the existing spinlock-protected block that updates flushedUpto. Feedbacks welcome. [1] https://www.postgresql.org/message-id/flat/19093-c4fff49a608f82a0%40postgresql.org -- Best, Xuneng
Вложения
В списке pgsql-hackers по дате отправления: