Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ee2Fc-0002Gs-C4 for pgsql-hackers@arkaria.postgresql.org; Tue, 23 Jan 2018 17:20:48 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ee2Fb-0005px-U8 for pgsql-hackers@arkaria.postgresql.org; Tue, 23 Jan 2018 17:20:47 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ee2Fb-0005pj-7B for pgsql-hackers@lists.postgresql.org; Tue, 23 Jan 2018 17:20:47 +0000 Received: from mail-wr0-f182.google.com ([209.85.128.182]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ee2FY-0001vR-4O for pgsql-hackers@postgresql.org; Tue, 23 Jan 2018 17:20:46 +0000 Received: by mail-wr0-f182.google.com with SMTP id f11so1392269wre.4 for ; Tue, 23 Jan 2018 09:20:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant.it; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to; bh=4D/RKJkgp1jp4suexkAxMsWX37JkP2a3ssq3d73tav4=; b=KlB0Q/86dV438osUmHEs+8VIX3eN+kakXu0gAwHX5jEUBBZbMf1zjXopJKIdVyhGqG YpZOX56ZAxafU5ibmZ3N6YVuM1nGxyMuhcwh7nAdcoOCZr9WJnFfkScJtwgZRoCY41FI 4N+xPCrMjXEeQDe7XvI3wB3/zcNOpIuc9nPws= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to; bh=4D/RKJkgp1jp4suexkAxMsWX37JkP2a3ssq3d73tav4=; b=BJjHPbsFeds+oJjMWoJ3F/JFRkdtmiZZIjs2ZDjiJ9OFGnhfn56a7EHjGnd/2++ujQ gifyR4PXsAlBVbuCMg+98ATCmK9ERdIuNZ45S6or70sIIHX+aS+KfBa8hGnPPZwQx+G7 07LB0jHiSF+Ahg0wtWyyI+bz3mIqE6EfeRRKlYx8AM1IBdLq5hNo7p48hmwh9Q17WGxt yJ8S5iAYlAV/ElwHCRI7FhfZjNLe/CXAaW+i3EmqY6e2iPGIh9izzs9667D0HgiSvNyo XfMoGHIKTaz586r6WwkcmasTI0Z+8E8QGMEbYSUqweMPktPQ75FlZLnllO7LX7zRVq+x q5LQ== X-Gm-Message-State: AKwxytecq4ZItEgETWUFsVv2iPWdRfCDzx29m35sukfeTTfmOVTh7mMN cQLiWpbMf2OTyfsIYeyczkmd5qSjrbKg52bW4gdUzuOqNxAWw7c4SrFJ1Knx+spXnWCSG+QQdBp 31xeFZONdT8XVPGy7b+P2M+zbWLmokBQI3EPnAnGPU0FuaiP61X4U08MHmOncpAIvTcLIq4pFXf V463YUd+DezFZHziX/2w== X-Google-Smtp-Source: AH8x227yJS/J4xdl27nAu7LrD/ExN9MUcGP2S0l0ep/YSU2hCdNerVe9Nqhk4P3A6rhQC8b15LyzPQ== X-Received: by 10.223.165.25 with SMTP id i25mr3176340wrb.127.1516727981464; Tue, 23 Jan 2018 09:19:41 -0800 (PST) Received: from titanium.local (net-37-182-231-222.cust.vodafonedsl.it. [37.182.231.222]) by smtp.googlemail.com with ESMTPSA id a62sm7821634wmh.3.2018.01.23.09.19.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Jan 2018 09:19:40 -0800 (PST) Subject: Re: [PATCH] Logical decoding of TRUNCATE To: Petr Jelinek , Simon Riggs Cc: PostgreSQL-development References: <269bf0d2-6ac4-c032-6979-22aad6a9f5fb@2ndquadrant.it> <20171229195536.cdzmgllfkln6wo6t@alap3.anarazel.de> <35a1d60b-f66d-4001-499b-2336ca81fc6c@2ndquadrant.it> <1a4ace10-1997-6644-d17a-5a17bf250270@2ndquadrant.it> <28a59551-b1f5-8ed4-65cf-76d17e7ee7e6@2ndquadrant.it> <1cb9bd52-9e3a-21bf-0c0c-afa90f463629@2ndquadrant.com> From: Marco Nenciarini Message-ID: <0361327b-5d59-32b0-cb13-e844acf0f0d0@2ndquadrant.it> Date: Tue, 23 Jan 2018 18:19:36 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="TX0eeUQUx8EFECTpdxC9DR0eOU2lIXFxL" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --TX0eeUQUx8EFECTpdxC9DR0eOU2lIXFxL Content-Type: multipart/mixed; boundary="ThAWcgTt3Y9urtH9AhJH0XIWAa7HyQAbG"; protected-headers="v1" From: Marco Nenciarini To: Petr Jelinek , Simon Riggs Cc: PostgreSQL-development Message-ID: <0361327b-5d59-32b0-cb13-e844acf0f0d0@2ndquadrant.it> Subject: Re: [PATCH] Logical decoding of TRUNCATE References: <269bf0d2-6ac4-c032-6979-22aad6a9f5fb@2ndquadrant.it> <20171229195536.cdzmgllfkln6wo6t@alap3.anarazel.de> <35a1d60b-f66d-4001-499b-2336ca81fc6c@2ndquadrant.it> <1a4ace10-1997-6644-d17a-5a17bf250270@2ndquadrant.it> <28a59551-b1f5-8ed4-65cf-76d17e7ee7e6@2ndquadrant.it> <1cb9bd52-9e3a-21bf-0c0c-afa90f463629@2ndquadrant.com> In-Reply-To: --ThAWcgTt3Y9urtH9AhJH0XIWAa7HyQAbG Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable Il 23/01/18 18:13, Petr Jelinek ha scritto: > Hi, >=20 > 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= =2E >>> >> >> 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. >=20 > This looks good. >=20 >> >> Version 15 attached. >> >=20 > I see you still do CASCADE on the subscriber though. >=20 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 =3D 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 =3D $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 =3D $node_subscriber->safe_psql('postgres', + "SELECT nextval('seq_notrep')"); + is($result, qq(102), + 'check replicated truncate does not restart identities'); + Regards, Marco --=20 Marco Nenciarini - 2ndQuadrant Italy PostgreSQL Training, Services and Support marco.nenciarini@2ndQuadrant.it | www.2ndQuadrant.it --ThAWcgTt3Y9urtH9AhJH0XIWAa7HyQAbG-- --TX0eeUQUx8EFECTpdxC9DR0eOU2lIXFxL Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEfCO4BD5l0pgKIbbiWJ8D8BulUDgFAlpnbqgACgkQWJ8D8Bul UDjCQw//WhRZLVvQbFnYpwUqfE75GZ2Z14rUqYggup2LEETupLmE42H5YkzsM8JS 5Xg4q61ZtnKPIdXgDgKxWCYdo/ccCRbbBSan5ViRGkxI+UiSQmcUHTKWQ+irOsCq 17M/r560rPIC7M/+zUQY5+pOTb1Qftgp1QDQ+NpzHkir5yD7HLO4OfiRU3m5+jKP a0J+EvleA+Tsy0XEZov6y5Vtzn6bzN492HvpMmdewcOrK2krag2lpAiuelKDdSTw qBCAaWCaxgZysGSMOW0sGfKzlFlgR0bnRLTQjtcvIId/1wsnb3BEmwv3mTZEgEXE lkkRaCFw5QuWRH7BnbvVX+WdZX7+WLHIFn2ew4kyEJYTaLRUj0KpdqK4wgz6wAQU MYUXIkkLvSPNC9811gheXjw4sxbOzP2STuiJw8xRsUASuotDEKDelhKdODPmEqDp +6j/eB8Ds/OwsQB+F79FnXhUkFCyaTeCYQ3mDuJR8M1jcvNlaQ7qBiU59EFlUQAQ rLbNoFLkmIh881pks00wkbwMIxN9NTtlB+EK/0Bmn1OoGiKPNRRODd94uwu8Rl3h gMsRwn0spkeSaO2LVncIsZXMgbR4ERB8vW4N8cFg/qoS12YV6rUTYNXS1uWF3C6i SSH2fYEveZYJ61dGxS+ShbhWLKcOjtXBPfIaD4yv0tzxQPYPARo= =2HHl -----END PGP SIGNATURE----- --TX0eeUQUx8EFECTpdxC9DR0eOU2lIXFxL--