Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gBzqA-00014l-9V for pgsql-admin@arkaria.postgresql.org; Mon, 15 Oct 2018 10:11:10 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gBzq7-0000Tk-H7 for pgsql-admin@arkaria.postgresql.org; Mon, 15 Oct 2018 10:11:07 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gBzq7-0000Tb-9q for pgsql-admin@lists.postgresql.org; Mon, 15 Oct 2018 10:11:07 +0000 Received: from n3.nabble.com ([162.255.23.22]) by magus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gBzq4-0005wr-Pw for pgsql-admin@postgresql.org; Mon, 15 Oct 2018 10:11:06 +0000 Received: from n3.nabble.com (localhost [127.0.0.1]) by n3.nabble.com (Postfix) with ESMTP id 89D7BFB8D42D for ; Mon, 15 Oct 2018 03:11:03 -0700 (MST) Date: Mon, 15 Oct 2018 03:11:03 -0700 (MST) From: pavan95 To: pgsql-admin@postgresql.org Message-ID: <1539598263562-0.post@n3.nabble.com> 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> Subject: Re: Hick ups in Postgresql Logical Replication MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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