mirror of
https://github.com/postgres/postgres.git
synced 2025-11-09 06:21:09 +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:
@@ -119,6 +119,20 @@ WalRcvRunning(void)
|
|||||||
return false;
|
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,
|
* Is walreceiver running and streaming (or at least attempting to connect,
|
||||||
* or starting up)?
|
* or starting up)?
|
||||||
|
|||||||
@@ -495,6 +495,7 @@ extern void WalRcvShmemInit(void);
|
|||||||
extern void ShutdownWalRcv(void);
|
extern void ShutdownWalRcv(void);
|
||||||
extern bool WalRcvStreaming(void);
|
extern bool WalRcvStreaming(void);
|
||||||
extern bool WalRcvRunning(void);
|
extern bool WalRcvRunning(void);
|
||||||
|
extern WalRcvState WalRcvGetState(void);
|
||||||
extern void RequestXLogStreaming(TimeLineID tli, XLogRecPtr recptr,
|
extern void RequestXLogStreaming(TimeLineID tli, XLogRecPtr recptr,
|
||||||
const char *conninfo, const char *slotname,
|
const char *conninfo, const char *slotname,
|
||||||
bool create_temp_slot);
|
bool create_temp_slot);
|
||||||
|
|||||||
Reference in New Issue
Block a user