Skip to content

Commit 95d1b41

Browse files
Reset hot standby xmin after restart
Hot_standby_feedback could be reset by reload and worked correctly, but if the server was restarted rather than reloaded the xmin was not reset. Force reset always if hot_standby_feedback is enabled at startup. Ants Aasma, Craig Ringer Reported-by: Ants Aasma
1 parent 2dfc126 commit 95d1b41

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

src/backend/replication/walreceiver.c

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,7 +1154,10 @@ XLogWalRcvSendReply(bool force, bool requestReply)
11541154
* in case they don't have a watch.
11551155
*
11561156
* If the user disables feedback, send one final message to tell sender
1157-
* to forget about the xmin on this standby.
1157+
* to forget about the xmin on this standby. We also send this message
1158+
* on first connect because a previous connection might have set xmin
1159+
* on a replication slot. (If we're not using a slot it's harmless to
1160+
* send a feedback message explicitly setting InvalidTransactionId).
11581161
*/
11591162
static void
11601163
XLogWalRcvSendHSFeedback(bool immed)
@@ -1164,7 +1167,8 @@ XLogWalRcvSendHSFeedback(bool immed)
11641167
uint32 nextEpoch;
11651168
TransactionId xmin;
11661169
static TimestampTz sendTime = 0;
1167-
static bool master_has_standby_xmin = false;
1170+
/* initially true so we always send at least one feedback message */
1171+
static bool master_has_standby_xmin = true;
11681172

11691173
/*
11701174
* If the user doesn't want status to be reported to the master, be sure
@@ -1189,14 +1193,17 @@ XLogWalRcvSendHSFeedback(bool immed)
11891193
}
11901194

11911195
/*
1192-
* If Hot Standby is not yet active there is nothing to send. Check this
1193-
* after the interval has expired to reduce number of calls.
1196+
* If Hot Standby is not yet accepting connections there is nothing to
1197+
* send. Check this after the interval has expired to reduce number of
1198+
* calls.
1199+
*
1200+
* Bailing out here also ensures that we don't send feedback until we've
1201+
* read our own replication slot state, so we don't tell the master to
1202+
* discard needed xmin or catalog_xmin from any slots that may exist
1203+
* on this replica.
11941204
*/
11951205
if (!HotStandbyActive())
1196-
{
1197-
Assert(!master_has_standby_xmin);
11981206
return;
1199-
}
12001207

12011208
/*
12021209
* Make the expensive call to get the oldest xmin once we are certain

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy