Re: [JDBC] JDBC: logical replication and LSN feedback

Поиск
Список
Период
Сортировка
От Dave Cramer
Тема Re: [JDBC] JDBC: logical replication and LSN feedback
Дата
Msg-id CADK3HHLO3=J8Kq+i-cUC=x-YW=h87FmPBgfp-hA38Az4LkLj-Q@mail.gmail.com
обсуждение исходный текст
Ответ на [JDBC] JDBC: logical replication and LSN feedback  (Yason TR <tryasontr@gmail.com>)
Ответы Re: [JDBC] JDBC: logical replication and LSN feedback  (Yason TR <tryasontr@gmail.com>)
Список pgsql-jdbc




On 21 September 2017 at 06:50, Yason TR <tryasontr@gmail.com> wrote:
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();

Pretty sure you only need one of them. I have to check again which one. One if for binary replication and the other is for logical.

as for why you are getting the event twice. I don't know but am equally interested in finding out why. 

What version of postgres is this on ?

 

В списке pgsql-jdbc по дате отправления:

Предыдущее
От: Yason TR
Дата:
Сообщение: [JDBC] JDBC: logical replication and LSN feedback
Следующее
От: Dave Cramer
Дата:
Сообщение: Re: [JDBC] Reading and writing off-heap data