Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef _WALRECEIVER_H
00013 #define _WALRECEIVER_H
00014
00015 #include "access/xlog.h"
00016 #include "access/xlogdefs.h"
00017 #include "storage/latch.h"
00018 #include "storage/spin.h"
00019 #include "pgtime.h"
00020
00021
00022 extern int wal_receiver_status_interval;
00023 extern int wal_receiver_timeout;
00024 extern bool hot_standby_feedback;
00025
00026
00027
00028
00029
00030
00031 #define MAXCONNINFO 1024
00032
00033
00034 #define AllowCascadeReplication() (EnableHotStandby && max_wal_senders > 0)
00035
00036
00037
00038
00039 typedef enum
00040 {
00041 WALRCV_STOPPED,
00042 WALRCV_STARTING,
00043
00044 WALRCV_STREAMING,
00045 WALRCV_WAITING,
00046 WALRCV_RESTARTING,
00047 WALRCV_STOPPING
00048 } WalRcvState;
00049
00050
00051 typedef struct
00052 {
00053
00054
00055
00056
00057
00058 pid_t pid;
00059 WalRcvState walRcvState;
00060 pg_time_t startTime;
00061
00062
00063
00064
00065
00066
00067
00068 XLogRecPtr receiveStart;
00069 TimeLineID receiveStartTLI;
00070
00071
00072
00073
00074
00075
00076
00077
00078 XLogRecPtr receivedUpto;
00079 TimeLineID receivedTLI;
00080
00081
00082
00083
00084
00085
00086
00087 XLogRecPtr latestChunkStart;
00088
00089
00090
00091
00092 TimestampTz lastMsgSendTime;
00093 TimestampTz lastMsgReceiptTime;
00094
00095
00096
00097
00098 XLogRecPtr latestWalEnd;
00099 TimestampTz latestWalEndTime;
00100
00101
00102
00103
00104 char conninfo[MAXCONNINFO];
00105
00106 slock_t mutex;
00107
00108
00109
00110
00111
00112
00113 Latch latch;
00114 } WalRcvData;
00115
00116 extern WalRcvData *WalRcv;
00117
00118
00119 typedef void (*walrcv_connect_type) (char *conninfo);
00120 extern PGDLLIMPORT walrcv_connect_type walrcv_connect;
00121
00122 typedef void (*walrcv_identify_system_type) (TimeLineID *primary_tli);
00123 extern PGDLLIMPORT walrcv_identify_system_type walrcv_identify_system;
00124
00125 typedef void (*walrcv_readtimelinehistoryfile_type) (TimeLineID tli, char **filename, char **content, int *size);
00126 extern PGDLLIMPORT walrcv_readtimelinehistoryfile_type walrcv_readtimelinehistoryfile;
00127
00128 typedef bool (*walrcv_startstreaming_type) (TimeLineID tli, XLogRecPtr startpoint);
00129 extern PGDLLIMPORT walrcv_startstreaming_type walrcv_startstreaming;
00130
00131 typedef void (*walrcv_endstreaming_type) (TimeLineID *next_tli);
00132 extern PGDLLIMPORT walrcv_endstreaming_type walrcv_endstreaming;
00133
00134 typedef int (*walrcv_receive_type) (int timeout, char **buffer);
00135 extern PGDLLIMPORT walrcv_receive_type walrcv_receive;
00136
00137 typedef void (*walrcv_send_type) (const char *buffer, int nbytes);
00138 extern PGDLLIMPORT walrcv_send_type walrcv_send;
00139
00140 typedef void (*walrcv_disconnect_type) (void);
00141 extern PGDLLIMPORT walrcv_disconnect_type walrcv_disconnect;
00142
00143
00144 extern void WalReceiverMain(void) __attribute__((noreturn));
00145
00146
00147 extern Size WalRcvShmemSize(void);
00148 extern void WalRcvShmemInit(void);
00149 extern void ShutdownWalRcv(void);
00150 extern bool WalRcvStreaming(void);
00151 extern bool WalRcvRunning(void);
00152 extern void RequestXLogStreaming(TimeLineID tli, XLogRecPtr recptr, const char *conninfo);
00153 extern XLogRecPtr GetWalRcvWriteRecPtr(XLogRecPtr *latestChunkStart, TimeLineID *receiveTLI);
00154 extern int GetReplicationApplyDelay(void);
00155 extern int GetReplicationTransferLatency(void);
00156
00157 #endif