RS_EPHEMERAL vs RS_TEMPORARY

Started by Antonin Houskaover 6 years ago3 messageshackers
Beta feature

Hackorum builds and tests every patch posted to the lists, not only commitfest submissions. This is Hackorum's own CI rather than the PostgreSQL project's, and it is still under testing - please report anything that looks wrong.

never appliedCI history
Jump to latest
#1Antonin Houska
ah@cybertec.at

I'm trying to figure out what's specific about RS_EPHEMERAL and RS_TEMPORARY
slot kinds. The following comment (see definition of the
ReplicationSlotPersistency enumeration) tells when each kind is dropped

* Slots marked as PERSISTENT are crash-safe and will not be dropped when
* released. Slots marked as EPHEMERAL will be dropped when released or after
* restarts. Slots marked TEMPORARY will be dropped at the end of a session
* or on error.
...
typedef enum ReplicationSlotPersistency

However I don't see the actual difference: whenever ReplicationSlotCleanup()
is called (on error or session end), ReplicationSlotRelease() has already been
called too. And as for server restart, I see that RestoreSlotFromDisk()
discards both EPHEMERAL and TEMPORARY. Do we really need both of them?

--
Antonin Houska
Web: https://www.cybertec-postgresql.com

#2Peter Eisentraut
peter_e@gmx.net
In reply to: Antonin Houska (#1)
Re: RS_EPHEMERAL vs RS_TEMPORARY

On 2020-02-25 08:30, Antonin Houska wrote:

I'm trying to figure out what's specific about RS_EPHEMERAL and RS_TEMPORARY
slot kinds. The following comment (see definition of the
ReplicationSlotPersistency enumeration) tells when each kind is dropped

The general idea is that an "ephemeral" slot is a future persistent slot
that is not completely initialized yet. If there is a crash and you
find an ephemeral slot, you can clean it up. The name is perhaps a bit
odd, you can think of it as an uninitialized one. A temporary slot is
one that behaves like a temporary table: It is removed at the end of a
session.

Perhaps the implementation differences are not big or are none, but it's
relevant for reporting. For example, the pg_replication_slots view
shows which slots are temporary. You wouldn't want to show an ephemeral
slot as temporary.

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

#3Antonin Houska
ah@cybertec.at
In reply to: Peter Eisentraut (#2)
Re: RS_EPHEMERAL vs RS_TEMPORARY

Peter Eisentraut <peter.eisentraut@2ndquadrant.com> wrote:

On 2020-02-25 08:30, Antonin Houska wrote:

I'm trying to figure out what's specific about RS_EPHEMERAL and RS_TEMPORARY
slot kinds. The following comment (see definition of the
ReplicationSlotPersistency enumeration) tells when each kind is dropped

The general idea is that an "ephemeral" slot is a future persistent slot that
is not completely initialized yet. If there is a crash and you find an
ephemeral slot, you can clean it up. The name is perhaps a bit odd, you can
think of it as an uninitialized one. A temporary slot is one that behaves
like a temporary table: It is removed at the end of a session.

Perhaps the implementation differences are not big or are none, but it's
relevant for reporting. For example, the pg_replication_slots view shows
which slots are temporary. You wouldn't want to show an ephemeral slot as
temporary.

ok, so only comments seem to be the problem.

Anyway, the reason I started to think about it was that I noticed an Assert()
statement I considered inaccurate. Does this patch make sense?

--
Antonin Houska
Web: https://www.cybertec-postgresql.com

Attachments:

repl_slot_persist_assert.patchtext/plainDownload+1-1