pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: pavan95 <pavan.postgresdba@gmail.com>
To: pgsql-admin@postgresql.org
Subject: Re: Hick ups in Postgresql Logical Replication
Date: Mon, 15 Oct 2018 03:11:03 -0700 (MST)
Message-ID: <1539598263562-0.post@n3.nabble.com> (raw)
In-Reply-To: <20427d4e-98a5-0cda-bddc-070989015cca@catalyst.net.nz>
References: <1539447741900-0.post@n3.nabble.com>
	<20427d4e-98a5-0cda-bddc-070989015cca@catalyst.net.nz>

Hi Mark,

Thanks for your response.

> We'd probably need to see how you actually did your set up, and also how
> you are deducing that there is a lag (e.g pg_stat_subscription)? 
  
*Setup*:

*Publisher *:

Out of n number of tables n-1 tables are opted for replication of DML
changes.

*Subscriber *:

Subscription is created on the subscriber for the corresponding publication.

*At times, I find(developer complains) about difference in records between
some of the published tables.*

For example, after successful configuration of replication, say it was
configured successfully on Oct 1'st 2018 and verified that it is
replicating. Then some n days in future, a developer complains a table named
abc is not getting replicated(meaning the data inserted/updated/deleted for
that table abc on publisher is not getting synced with subscriber).

*Findings*:

Here I found that for 1 of the published table the row count is not same on
both publisher and subscriber:

Publisher :  select count(*) from table_A;       No.of Rows= 3598

Subscriber: select count(*) from table_A:       No.of Rows= 3590

*Then my analysis will go like* :

1) Check the error log for any kind of errors-----------*No errors found*

2) Validate that the table structure(no.of.columns) on both primary and
subscriber.

As it is production, I need to to restore the data with minimum time. So I
will go for methods:

1). Truncate the table with cascade option--------which truncates the
records and resyncs the table and sometimes it will not work out.

2). If first approach will not work out, then I will go with dropping the
subscription and again configure the replication with copy_data=false
option.-----It works out.


As this can't be the baselined approach to be followed whenever this
complaint arises, a doubt raised in my head. 

1) Can we restore that only 3 records(or more from other tables) on the
online subscriber???

In this case LSN's on both the primary and secondary are different. So how
to identify the difference LSN's for that 3 records in that table? 

Assuming for 3 records there are 3 different LSN's, is there a way to
restore that only 3 LSN's data??

Can we list what all the LSN's are present in a single archive log
segment(000000010000000200000003). And how can I restore that archive
segment alone on the subscriber.

To be in specific, 

1) Can I get List of LSN's in an archive WAL segment file?
2) How to find that 3 records are in which archive file based on the LSN?
3) How can I restore that 3 records alone, in this case ?

Please ask if there is something which I needed to explain on my part.

Looking forward to hear from you. Thanks in Advance.





--
Sent from: http://www.postgresql-archive.org/PostgreSQL-admin-f2076596.html




view thread (6+ messages)  latest in thread

Message-ID: <1539598263562-0.post@n3.nabble.com>
Permalink:  ../1539598263562-0.post@n3.nabble.com/
Also on:    postgresql.org/message-id/1539598263562-0.post@n3.nabble.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-admin@postgresql.org
  Cc: pavan.postgresdba@gmail.com
  Subject: Re: Hick ups in Postgresql Logical Replication
  In-Reply-To: <1539598263562-0.post@n3.nabble.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox