Skip to content

Commit

Permalink
fix: advance lastReceiveLSN on keepalive messages
Browse files Browse the repository at this point in the history
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 committed Dec 19, 2017
1 parent 405f14e commit 5c802a3
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,9 @@ private byte[] prepareUpdateStatus(LogSequenceNumber received, LogSequenceNumber

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

long lastServerClock = buffer.getLong();

Expand Down

0 comments on commit 5c802a3

Please sign in to comment.