Re: server log inflates due to pg_logical_slot_peek_changes/pg_logical_slot_get_changes calls

From: Jeevan Ladhe <jeevanladhe(dot)os(at)gmail(dot)com>
To: Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: server log inflates due to pg_logical_slot_peek_changes/pg_logical_slot_get_changes calls
Date: 2023-03-20 11:18:20
Message-ID: CANm22Cg6daAozpAOMguGkoG5mhzzwf9CFoPXgek6e8tod2LSww@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Thanks, Ashutosh for the reply.

I think those messages are useful when debugging logical replication
> problems (imagine missing transaction or inconsistent data between
> publisher and subscriber). I don't think pg_logical_slot_get_changes()
> or pg_logical_slot_peek_changes() are expected to be called frequently
> in a loop.

Yeah right. But can you please shed some light on when these functions
should be called, or are they used only for testing purposes?

Instead you should open a replication connection to
> continue to receive logical changes ... forever.
>

Yes, this is what I have decided to resort to now.

Why do you need to call pg_logical_slot_peek_changes() and
> pg_logical_slot_get_changes() frequently?
>

I was just playing around to do something for logical replication and
thought
of doing this quick test where every time interval I read using
pg_logical_slot_peek_changes(), make sure to consume them to a consistent
state, and only then use pg_logical_slot_get_changes() to advance the slot.

Regards,
Jeevan Ladhe

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tomas Vondra 2023-03-20 11:43:04 Re: logical decoding and replication of sequences, take 2
Previous Message Amit Kapila 2023-03-20 11:00:56 Re: logical decoding and replication of sequences, take 2