Skip to content

Commit 9ed16cb

Browse files
espadolinijackc
authored andcommitted
Fix clientXLogPos handling in pglogrepl_demo
1 parent d0818e1 commit 9ed16cb

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

example/pglogrepl_demo/main.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,9 @@ func main() {
125125
log.Fatalln("ParsePrimaryKeepaliveMessage failed:", err)
126126
}
127127
log.Println("Primary Keepalive Message =>", "ServerWALEnd:", pkm.ServerWALEnd, "ServerTime:", pkm.ServerTime, "ReplyRequested:", pkm.ReplyRequested)
128-
128+
if pkm.ServerWALEnd > clientXLogPos {
129+
clientXLogPos = pkm.ServerWALEnd
130+
}
129131
if pkm.ReplyRequested {
130132
nextStandbyMessageDeadline = time.Time{}
131133
}
@@ -147,7 +149,9 @@ func main() {
147149
}
148150
}
149151

150-
clientXLogPos = xld.WALStart + pglogrepl.LSN(len(xld.WALData))
152+
if xld.WALStart > clientXLogPos {
153+
clientXLogPos = xld.WALStart
154+
}
151155
}
152156
}
153157
}

0 commit comments

Comments
 (0)