@@ -4,19 +4,18 @@ Walreceiver - libpqwalreceiver API
4
4
----------------------------------
5
5
6
6
The transport-specific part of walreceiver, responsible for connecting to
7
- the primary server and receiving WAL files, is loaded dynamically to avoid
8
- having to link the main server binary with libpq. The dynamically loaded
9
- module is in libpqwalreceiver subdirectory.
7
+ the primary server, receiving WAL files and sending messages, is loaded
8
+ dynamically to avoid having to link the main server binary with libpq.
9
+ The dynamically loaded module is in libpqwalreceiver subdirectory.
10
10
11
- The dynamically loaded module implements three functions:
11
+ The dynamically loaded module implements four functions:
12
12
13
13
14
14
bool walrcv_connect(char *conninfo, XLogRecPtr startpoint)
15
15
16
16
Establish connection to the primary, and starts streaming from 'startpoint'.
17
17
Returns true on success.
18
18
19
-
20
19
bool walrcv_receive(int timeout, unsigned char *type, char **buffer, int *len)
21
20
22
21
Retrieve any message available through the connection, blocking for
@@ -26,6 +25,10 @@ otherwise false. On success, a pointer to the message payload is stored in
26
25
returned buffer is valid until the next call to walrcv_* functions, the
27
26
caller should not attempt freeing it.
28
27
28
+ void walrcv_send(const char *buffer, int nbytes)
29
+
30
+ Send a message to XLOG stream.
31
+
29
32
void walrcv_disconnect(void);
30
33
31
34
Disconnect.
@@ -45,11 +48,15 @@ to fetch more WAL (if streaming replication is configured).
45
48
Walreceiver is a postmaster subprocess, so the startup process can't fork it
46
49
directly. Instead, it sends a signal to postmaster, asking postmaster to launch
47
50
it. Before that, however, startup process fills in WalRcvData->conninfo,
48
- and initializes the starting point in WalRcvData->receivedUpto .
51
+ and initializes the starting point in WalRcvData->receiveStart .
49
52
50
53
As walreceiver receives WAL from the master server, and writes and flushes
51
- it to disk (in pg_xlog), it updates WalRcvData->receivedUpto. Startup process
52
- polls that to know how far it can proceed with WAL replay.
54
+ it to disk (in pg_xlog), it updates WalRcvData->receivedUpto and signals
55
+ the startup process to know how far WAL replay can advance.
56
+
57
+ Walreceiver sends information about replication progress to the master server
58
+ whenever either it writes or flushes new WAL, or the specified interval elapses.
59
+ This is used for reporting purpose.
53
60
54
61
Walsender IPC
55
62
-------------
@@ -80,11 +87,9 @@ phase. A walsenders will look like a regular backends until it's done with the
80
87
initialization and has marked itself in PMSignal array, and at process
81
88
termination, after unmarking the PMSignal slot.
82
89
83
- Each walsender allocates an entry from the WalSndCtl array, and advertises
84
- there how far it has streamed WAL already. This is used at checkpoints, to
85
- avoid recycling WAL that hasn't been streamed to a slave yet. However,
86
- that doesn't stop such WAL from being recycled when the connection is not
87
- established.
90
+ Each walsender allocates an entry from the WalSndCtl array, and tracks
91
+ information about replication progress. User can monitor them via
92
+ statistics views.
88
93
89
94
90
95
Walsender - walreceiver protocol
0 commit comments