Use of snapshot in logical replication

Started by sanyam jainover 8 years ago4 messages
#1sanyam jain
sanyamjain22@live.in

Hi,

Can someone explain the usage of exporting snapshot when a logical replication slot is created?

Thanks,

Sanyam Jain

#2Craig Ringer
craig@2ndquadrant.com
In reply to: sanyam jain (#1)
Re: Use of snapshot in logical replication

On 7 June 2017 at 18:16, sanyam jain <sanyamjain22@live.in> wrote:

Hi,

Can someone explain the usage of exporting snapshot when a logical
replication slot is created?

It's used to pg_dump the schema at a consistent point in history where
all xacts are known to be in the snapshot (and thus dumped) or known
not to be (so they'll be streamed out on the slot).

See snapbuild.c etc.

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

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#3Petr Jelinek
petr.jelinek@2ndquadrant.com
In reply to: Craig Ringer (#2)
Re: Use of snapshot in logical replication

On 08/06/17 03:08, Craig Ringer wrote:

On 7 June 2017 at 18:16, sanyam jain <sanyamjain22@live.in> wrote:

Hi,

Can someone explain the usage of exporting snapshot when a logical
replication slot is created?

It's used to pg_dump the schema at a consistent point in history where
all xacts are known to be in the snapshot (and thus dumped) or known
not to be (so they'll be streamed out on the slot).

Not just schema, it can also be used to get existing data at consistent
point in history so that changes will follow without gaps or duplicates.

That being said, the built-in logical replication isn't using the
exported snapshots at all.

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

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#4Andres Freund
andres@anarazel.de
In reply to: Petr Jelinek (#3)
Re: Use of snapshot in logical replication

On 2017-06-08 03:14:55 +0200, Petr Jelinek wrote:

On 08/06/17 03:08, Craig Ringer wrote:

On 7 June 2017 at 18:16, sanyam jain <sanyamjain22@live.in> wrote:

Hi,

Can someone explain the usage of exporting snapshot when a logical
replication slot is created?

It's used to pg_dump the schema at a consistent point in history where
all xacts are known to be in the snapshot (and thus dumped) or known
not to be (so they'll be streamed out on the slot).

Not just schema, it can also be used to get existing data at consistent
point in history so that changes will follow without gaps or duplicates.

That being said, the built-in logical replication isn't using the
exported snapshots at all.

Just because it uses them in the same session doesn't really change the
picture, that's more or less just an optimization. It's essentially
just a cheaper version of importing a snapshot that'd have to be
exported in same session.

- Andres

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers