summaryrefslogtreecommitdiff
path: root/src/include/replication
diff options
context:
space:
mode:
authorHeikki Linnakangas2012-10-11 14:39:52 +0000
committerHeikki Linnakangas2012-10-11 14:48:08 +0000
commit6f60fdd7015b032bf49273c99f80913d57eac284 (patch)
treeef9a5602c01617665815503a45dc1ea3b379e757 /src/include/replication
parent8521d131941be5a177270bc428fa8e684cd645b5 (diff)
Improve replication connection timeouts.
Rename replication_timeout to wal_sender_timeout, and add a new setting called wal_receiver_timeout that does the same at the walreceiver side. There was previously no timeout in walreceiver, so if the network went down, for example, the walreceiver could take a long time to notice that the connection was lost. Now with the two settings, both sides of a replication connection will detect a broken connection similarly. It is no longer necessary to manually set wal_receiver_status_interval to a value smaller than the timeout. Both wal sender and receiver now automatically send a "ping" message if more than 1/2 of the configured timeout has elapsed, and it hasn't received any messages from the other end. Amit Kapila, heavily edited by me.
Diffstat (limited to 'src/include/replication')
-rw-r--r--src/include/replication/walprotocol.h12
-rw-r--r--src/include/replication/walreceiver.h2
-rw-r--r--src/include/replication/walsender.h2
-rw-r--r--src/include/replication/walsender_private.h1
4 files changed, 15 insertions, 2 deletions
diff --git a/src/include/replication/walprotocol.h b/src/include/replication/walprotocol.h
index 0305fb7e59..396d006ea7 100644
--- a/src/include/replication/walprotocol.h
+++ b/src/include/replication/walprotocol.h
@@ -27,6 +27,12 @@ typedef struct
/* Sender's system clock at the time of transmission */
TimestampTz sendTime;
+
+ /*
+ * If replyRequested is set, the client should reply immediately to this
+ * message, to avoid a timeout disconnect.
+ */
+ bool replyRequested;
} WalSndrMessage;
@@ -80,6 +86,12 @@ typedef struct
/* Sender's system clock at the time of transmission */
TimestampTz sendTime;
+
+ /*
+ * If replyRequested is set, the server should reply immediately to this
+ * message, to avoid a timeout disconnect.
+ */
+ bool replyRequested;
} StandbyReplyMessage;
/*
diff --git a/src/include/replication/walreceiver.h b/src/include/replication/walreceiver.h
index 62b6d2d93f..4cf5a27e6d 100644
--- a/src/include/replication/walreceiver.h
+++ b/src/include/replication/walreceiver.h
@@ -17,7 +17,9 @@
#include "storage/spin.h"
#include "pgtime.h"
+/* user-settable parameters */
extern int wal_receiver_status_interval;
+extern int wal_receiver_timeout;
extern bool hot_standby_feedback;
/*
diff --git a/src/include/replication/walsender.h b/src/include/replication/walsender.h
index 78e8558299..df8e951478 100644
--- a/src/include/replication/walsender.h
+++ b/src/include/replication/walsender.h
@@ -24,7 +24,7 @@ extern bool wake_wal_senders;
/* user-settable parameters */
extern int max_wal_senders;
-extern int replication_timeout;
+extern int wal_sender_timeout;
extern void InitWalSender(void);
extern void exec_replication_command(const char *query_string);
diff --git a/src/include/replication/walsender_private.h b/src/include/replication/walsender_private.h
index 45cd7444cd..66234cd8b5 100644
--- a/src/include/replication/walsender_private.h
+++ b/src/include/replication/walsender_private.h
@@ -37,7 +37,6 @@ typedef struct WalSnd
XLogRecPtr sentPtr; /* WAL has been sent up to this point */
bool needreload; /* does currently-open file need to be
* reloaded? */
- bool sendKeepalive; /* do we send keepalives on this connection? */
/*
* The xlog locations that have been written, flushed, and applied by