-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
incorrect lastLsn #30
Comments
postgres does not send empty transactions anymore, so we need to use endLsn of PrimaryKeepaliveMessage to move slot position |
endLsn of PrimaryKeepaliveMessage goes ahead of XLogData lsn, but not further than commitLsn. So acking endLsn does not cause message loss, because replication restarts from transaction start. My problem is that I mistakenly thought that I can use confirmed_flush_lsn of slot to filter already handled messages in case of big transactions. But message lsn is not monotonic and not unique. |
I'm also running in the issue where On an idle instance on AWS RDS, the WAL grows by 64MB every 5 minutes. When it's idle, there are no messages received on the WAL other than the I've worked around this by periodically using |
Thanks, the change in the commit above solves this issue for me. FWIW, I only use this LSN when not inside a transaction, just to be safe. Something like the following: let inTx = false;
let ackedLsn = lastPersistedLsn;
for await (const chunk of replicationStream.pgoutputDecode()) {
await touch();
const { messages, lastLsn } = chunk;
for (const msg of messages) {
if (msg.tag == 'begin') {
inTx = true;
} else if (msg.tag == 'commit') {
inTx = false;
// (flush data here)
ackedLsn = msg.lsn!;
await replicationStream.ack(msg.lsn!);
} else {
// (write data here)
}
}
if (!inTx && lastLsn > ackedLsn) {
ackedLsn = lastLsn;
await replicationStream.ack(lastLsn);
}
} |
Yes, the issue is fixed for me. |
.endLsn of PrimaryKeepaliveMessage is greater than XLogData messages lsn. This causes replication slot moved to position before XLogData messages actually consumed
pgwire/mod.js
Line 1611 in 12826ad
The text was updated successfully, but these errors were encountered: