Permalink
Browse files

fix: advance lastReceiveLSN on keepalive messages (#1038)

Fix a bug with V3PGReplicationStream where the server may never
be able to send a CommandComplete message to the client because
the client's status update messages do not advance the received LSN.
This behavior can be reliably reproduced on a server where no
data changes are happening, so the only messages being sent from
the client are status updates and the only messages coming from
the server are keepalives. The LSN reported from the server keepalives
continues to advance, but the client reports a static
lastReceiveLSN, so the server never considers the client caught
up and never sends CommandComplete to trigger the client to shut down.
By updating lastReceiveLSN on keepalive messages, the expected
server CommandComplete and client Terminate messages are exchanged,
allowing the server to gracefully shut down.
  • Loading branch information...
jklukas authored and davecramer committed Jan 13, 2018
1 parent e6a1ecc commit 1be8a9ebafbfbcff118385a61a350745addcaf3d
@@ -222,6 +222,9 @@ private void updateStatusInternal(

private boolean processKeepAliveMessage(ByteBuffer buffer) {
lastServerLSN = LogSequenceNumber.valueOf(buffer.getLong());
if (lastServerLSN.asLong() > lastReceiveLSN.asLong()) {
lastReceiveLSN = lastServerLSN;
}

long lastServerClock = buffer.getLong();

0 comments on commit 1be8a9e

Please sign in to comment.