pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Marco Nenciarini <marco.nenciarini@2ndquadrant.it>
To: Petr Jelinek <petr.jelinek@2ndquadrant.com>
To: Simon Riggs <simon@2ndquadrant.com>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Subject: Re: [PATCH] Logical decoding of TRUNCATE
Date: Tue, 23 Jan 2018 18:19:36 +0100
Message-ID: <0361327b-5d59-32b0-cb13-e844acf0f0d0@2ndquadrant.it> (raw)
In-Reply-To: <ffb116ef-a072-2b9b-dd92-e288dbfa0f6c@2ndquadrant.com>
References: <269bf0d2-6ac4-c032-6979-22aad6a9f5fb@2ndquadrant.it>
	<20171229195536.cdzmgllfkln6wo6t@alap3.anarazel.de>
	<CANP8+jKe2MxtH4Ck70tUY6wP=OnkkkXRt8Xkx1u6+50HM2wHvQ@mail.gmail.com>
	<35a1d60b-f66d-4001-499b-2336ca81fc6c@2ndquadrant.it>
	<fd058540-657f-7c2d-93a2-b70c4974513b@2ndquadrant.it>
	<1a4ace10-1997-6644-d17a-5a17bf250270@2ndquadrant.it>
	<28a59551-b1f5-8ed4-65cf-76d17e7ee7e6@2ndquadrant.it>
	<f45ec6eb-1dda-9b7f-6fb8-85deb40ff968@2ndquadrant.com>
	<CANP8+jJzf-K0AnN2X=xpoaFq+Ncdjzbk6b4=JrMJoiMbgO39YQ@mail.gmail.com>
	<fdd6d0ec-ab81-af7b-aaf6-595c2ac88af9@2ndquadrant.it>
	<1cb9bd52-9e3a-21bf-0c0c-afa90f463629@2ndquadrant.com>
	<f6352c33-f3e3-0e35-dbd2-29949b9c2b59@2ndquadrant.com>
	<de2a9d73-1e25-797c-03f8-9faa57f75e85@2ndquadrant.it>
	<ffb116ef-a072-2b9b-dd92-e288dbfa0f6c@2ndquadrant.com>

Il 23/01/18 18:13, Petr Jelinek ha scritto:
> Hi,
> 
> On 23/01/18 15:38, Marco Nenciarini wrote:
>> Il 22/01/18 23:18, Petr Jelinek ha scritto:
>>> On 22/01/18 19:45, Petr Jelinek wrote:
>>>
>>> Actually on second look, I don't like the new boolean parameter much.
>>> I'd rather we didn't touch the input list and always close only
>>> relations opened inside the ExecuteTruncateGuts().
>>>
>>> It may mean more list(s) but the current interface is still not clean.
>>>
>>
>> Now ExecuteTruncateGuts unconditionally closes the relations that it
>> opens. The caller has now always the responsibility to close the
>> relations passed with the explicit_rels list.
> 
> This looks good.
> 
>>
>> Version 15 attached.
>>
> 
> I see you still do CASCADE on the subscriber though.
> 

No it doesn't. The following code in worker.c prevents that.


+ 	/*
+ 	 * Even if we used CASCADE on the upstream master we explicitly
+ 	 * default to replaying changes without further cascading.
+ 	 * This might be later changeable with a user specified option.
+ 	 */
+ 	cascade = false;

There is also a test that check it works as intended:

+ # should not cascade on replica
+ $node_publisher->safe_psql('postgres', "TRUNCATE tab_rep CASCADE");
+
+ $node_publisher->wait_for_catchup($appname);
+
+ $result = $node_subscriber->safe_psql('postgres',
+ 	"SELECT count(*), min(a), max(a) FROM tab_notrep_fk");
+ is($result, qq(1|-1|-1),
+ 	'check replicated truncate does not cascade on replica');
+
+ $result = $node_subscriber->safe_psql('postgres',
+ 	"SELECT nextval('seq_notrep')");
+ is($result, qq(102),
+ 	'check replicated truncate does not restart identities');
+

Regards,
Marco

-- 
Marco Nenciarini - 2ndQuadrant Italy
PostgreSQL Training, Services and Support
marco.nenciarini@2ndQuadrant.it | www.2ndQuadrant.it

Attachments:

  signature.asc (application/pgp-signature, 832B) download

view thread (48+ messages)  latest in thread

Message-ID: <0361327b-5d59-32b0-cb13-e844acf0f0d0@2ndquadrant.it>
Permalink:  ../0361327b-5d59-32b0-cb13-e844acf0f0d0@2ndquadrant.it/
Also on:    postgresql.org/message-id/0361327b-5d59-32b0-cb13-e844acf0f0d0@2ndquadrant.it

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: marco.nenciarini@2ndquadrant.it, petr.jelinek@2ndquadrant.com, simon@2ndquadrant.com, pgsql-hackers@postgresql.org
  Subject: Re: [PATCH] Logical decoding of TRUNCATE
  In-Reply-To: <0361327b-5d59-32b0-cb13-e844acf0f0d0@2ndquadrant.it>
  References: <269bf0d2-6ac4-c032-6979-22aad6a9f5fb@2ndquadrant.it> <20171229195536.cdzmgllfkln6wo6t@alap3.anarazel.de> <CANP8+jKe2MxtH4Ck70tUY6wP=OnkkkXRt8Xkx1u6+50HM2wHvQ@mail.gmail.com> <35a1d60b-f66d-4001-499b-2336ca81fc6c@2ndquadrant.it> <fd058540-657f-7c2d-93a2-b70c4974513b@2ndquadrant.it> <1a4ace10-1997-6644-d17a-5a17bf250270@2ndquadrant.it> <28a59551-b1f5-8ed4-65cf-76d17e7ee7e6@2ndquadrant.it> <f45ec6eb-1dda-9b7f-6fb8-85deb40ff968@2ndquadrant.com> <CANP8+jJzf-K0AnN2X=xpoaFq+Ncdjzbk6b4=JrMJoiMbgO39YQ@mail.gmail.com> <fdd6d0ec-ab81-af7b-aaf6-595c2ac88af9@2ndquadrant.it> <1cb9bd52-9e3a-21bf-0c0c-afa90f463629@2ndquadrant.com> <f6352c33-f3e3-0e35-dbd2-29949b9c2b59@2ndquadrant.com> <de2a9d73-1e25-797c-03f8-9faa57f75e85@2ndquadrant.it> <ffb116ef-a072-2b9b-dd92-e288dbfa0f6c@2ndquadrant.com> <0361327b-5d59-32b0-cb13-e844acf0f0d0@2ndquadrant.it>

* 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