1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-07 19:06:32 +03:00

Add WalRcvGetState() to retrieve the state of a WAL receiver

This has come up as useful as an alternative of WalRcvStreaming(), to be
able to do sanity checks based on the state of a WAL receiver.  This
will be used in a follow-up commit.

Author: Xuneng Zhou <xunengzhou@gmail.com>
Discussion: https://postgr.es/m/19093-c4fff49a608f82a0@postgresql.org
This commit is contained in:
Michael Paquier
2025-11-04 12:57:36 +09:00
parent 17b2d5ec75
commit e0ca61e7c4
2 changed files with 15 additions and 0 deletions

View File

@@ -119,6 +119,20 @@ WalRcvRunning(void)
return false;
}
/* Return the state of the walreceiver. */
WalRcvState
WalRcvGetState(void)
{
WalRcvData *walrcv = WalRcv;
WalRcvState state;
SpinLockAcquire(&walrcv->mutex);
state = walrcv->walRcvState;
SpinLockRelease(&walrcv->mutex);
return state;
}
/*
* Is walreceiver running and streaming (or at least attempting to connect,
* or starting up)?

View File

@@ -495,6 +495,7 @@ extern void WalRcvShmemInit(void);
extern void ShutdownWalRcv(void);
extern bool WalRcvStreaming(void);
extern bool WalRcvRunning(void);
extern WalRcvState WalRcvGetState(void);
extern void RequestXLogStreaming(TimeLineID tli, XLogRecPtr recptr,
const char *conninfo, const char *slotname,
bool create_temp_slot);