pg-logical-replication icon indicating copy to clipboard operation
pg-logical-replication copied to clipboard

Is there a way to tell PG not to send messages after the one I acknowledged last ?

Open lorenzofox3 opened this issue 10 months ago • 2 comments

I understand that acknowledge is more an instruction for PG to clean the related WALs, but I was wondering if there is a way to tell postgres to stop sending me messages until I have acknowledged the one I am currently processing ?

lorenzofox3 avatar Feb 05 '25 17:02 lorenzofox3

I don't see a way. I think this package needs to expose the pg connection in the data event handler args. Without this, I don't see a way to control back pressure. With it, you can pause the connection's stream and flush the current message before taking on the next. This work would need to be done within the wal_sender_timeout to avoid a connection close. I wonder if we could also just make this lib pause the stream until acknowledge is called.

jpdsteno avatar Mar 03 '25 16:03 jpdsteno

I ended up stopping the service and going back to listening mode on demand. It may not be the most efficient, but after conducting some tests, it does the job.

I wrote a blog post about my experiments

lorenzofox3 avatar Mar 03 '25 18:03 lorenzofox3