Dirtying replication slots when confirm_lsn is updated (trivial, 9.7)

From: Craig Ringer <craig(at)2ndquadrant(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Andres Freund <andres(at)anarazel(dot)de>
Subject: Dirtying replication slots when confirm_lsn is updated (trivial, 9.7)
Date: 2016-05-02 11:50:50
Message-ID: CAMsr+YFvuhSG8T8rSLHZDN2tmBF4K2g-MRjmdjavOy6mwm9XFQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi all

Currently replication slots are not dirtied when the client sends
confirmation of replay. So when we checkpoint we don't bother writing out
the updated slot state unless the restart_lsn has also changed as a result
of the replay confirmation.

That's pretty fuss free for the walsender interface, but for the SQL
interface it means that pg_logical_slot_get_changes() will repeat changes
you've already seen after a restart. Even if you did a clean shutdown.

I think that's a bit ugly, and I propose a trivial change to dirty the
replication slot from pg_logical_slot_get_changes_guts(...) if called in
get mode not peek mode. That way it'll get written out next time we
checkpoint the slot state.

The current behaviour isn't a data loss risk, and apps have to be prepared
for this to happen anyway on unclean exit. So this is mostly
convenience/cosmetic; I'll add it to the first 9.7 CF.

--
Craig Ringer http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

Attachment Content-Type Size
0001-Dirty-replication-slots-from-SQL-decoding-interface.patch text/x-patch 940 bytes

Browse pgsql-hackers by date

  From Date Subject
Next Message Craig Ringer 2016-05-02 11:54:37 Re: what does function EmitWarningsOnPlaceholders?
Previous Message Pavel Stehule 2016-05-02 10:51:37 what does function EmitWarningsOnPlaceholders?