From: | Yason TR <tryasontr(at)gmail(dot)com> |
---|---|
To: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | JDBC: logical replication and LSN feedback |
Date: | 2017-09-21 13:50:44 |
Message-ID: | CANcxKGKg5eof4Zm1fj-8EhirX9ZT4gnZyNoVEXqp74wruJvg8A@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
Hi,
This is a follow-up from my previous question
(https://www.postgresql.org/message-id/trinity-903b9111-dde7-4901-8130-86924336c456-1505912478894%403c-app-mailcom-bs15)
I created a git to guide my question, see
https://github.com/yasontr/pg-jdbc-logical-decoding.
Please follow the install steps on this page. After this, you can run
the application with Maven. This application listens to a replication
slot. See https://github.com/yasontr/pg-jdbc-logical-decoding/blob/master/src/main/java/yasontr/pg_jdbc_logical_decoding/Main.java
for the code of the application.
The problem I am seeing can be reproduced as following:
1) start the application
2) insert a dummy row to the test table: insert into test(key, value)
values (1, 'test');
3) now you see in the console:
event: {"change":[{"kind":"insert","schema":"public","table":"test","columnnames":["key","value"],"columntypes":["int4","text"],"columnvalues":[1,"test"]}]}
last received LSN: LSN{1A/AD2EEB0}
4) close the application
5) start the application again
6) now you see again the same event again in the console:
event: {"change":[{"kind":"insert","schema":"public","table":"test","columnnames":["key","value"],"columntypes":["int4","text"],"columnvalues":[1,"test"]}]}
last received LSN: LSN{1A/AD2EEB0}
As you can see in the code, I am confirming the event with its LSN:
stream.setAppliedLSN(stream.getLastReceiveLSN());
stream.setFlushedLSN(stream.getLastReceiveLSN());
stream.forceUpdateStatus();
So I would expect that the event is marked, possibly removed from the
WAL and that it would not be resent to the consumer(s).
Could anyone explain why this is happening?
As a side-question, what is the difference between setAppliedLSN and
setFlushedLSN and why/when do I need both/just one? The javadocs are
not really helpful here.
Thanks and best regards,
Yason TR
From | Date | Subject | |
---|---|---|---|
Next Message | Dave Cramer | 2017-09-21 15:28:20 | Re: JDBC: logical replication and LSN feedback |
Previous Message | Tom Dunstan | 2017-09-21 05:43:08 | Reading and writing off-heap data |