Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gXFSi-0000Hg-5w for pgsql-general@arkaria.postgresql.org; Thu, 13 Dec 2018 01:06:48 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gXFSf-0005n7-QN for pgsql-general@arkaria.postgresql.org; Thu, 13 Dec 2018 01:06:45 +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_SHA1:256) (Exim 4.89) (envelope-from ) id 1gXFSe-0005n0-4c for pgsql-general@lists.postgresql.org; Thu, 13 Dec 2018 01:06:45 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gXFSU-0007EU-Q4 for pgsql-general@lists.postgresql.org; Thu, 13 Dec 2018 01:06:43 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 783C722028; Wed, 12 Dec 2018 20:06:32 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Wed, 12 Dec 2018 20:06:32 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:cc:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm1; bh=B 0VSAGoz7ydU1Tn9Hw6R1PYQfTE+wPqgplsg8joCJ4s=; b=5FXH9gjcRS2WwSxTZ JVu3o0joKWVAfX4+b69M/G2M0m3oLRQGMg8oFUUAESz+s3P80u8KnoVvDDT9ZV4y D7asxB6VQNpDKecF9U8QLA9eDi8f3RNBFMqA7ceM+Fjsq2h4TdEgfqP+8jtsS7pI 7OCZ48empcM81xcxrAAd8i6XMcKP6f6CivfPcvjJLJ6fhf/uk+YnGtDPbDBlbHwh wbll0oUwMeGWGFgvYMSONftcyVxBWoFXLMRvSCxe5bziR3RB2KAwo/Rz0Bl1M67D LFBVYrQrvzCkwGGmH9Eh9eyIDiVIxvAYbvQpNO/dm3F4m1qrHdZjMphwOx8r26SZ BIQsw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=B0VSAGoz7ydU1Tn9Hw6R1PYQfTE+wPqgplsg8joCJ 4s=; b=rn8SYyCofdts6AKC43Gx3qfSagVg/RM5WYA/wR4ON7fnTDre734xC58FX xsxX/o3crskaByqjn+k9+Ao8J0yCM1eAO1Xh8TpuNLobinH3NLcJGIwm8cetI5S/ bQ7hbwSanYYb1LQMfbDkG61KgSgfnrinOHnn6HX8WKmmDEbwSylsLrJyqVOE3bb/ L7q7vad7sHXxNpl7CzCiOaIb2ULbYiiBmJVypsI50EkbO1mZ/gjCFGkcNOjQ5+/2 KE0Z5RTcf1VdjNoi03A/CQ+aPiJddnWsyDxnYqMrzPy079w7JLbrqW4wd6yXAfxn /glIZP1yR2fN4c2jQpLyo+IkdPLeA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtkedrudehuddgfedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfquhhtnecuuegrihhlohhuthemucef tddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefuvfhfhffkff gfgggjtgfgsehtjeertddtfeejnecuhfhrohhmpeetughrihgrnhcumfhlrghvvghruceo rggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomheqnecuffhomhgrihhnpe hpohhsthhgrhgvshhqlhdrohhrghenucfkphepjedurddvuddvrddufeegrdefnecurfgr rhgrmhepmhgrihhlfhhrohhmpegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrd gtohhmnecuvehluhhsthgvrhfuihiivgeptd X-ME-Proxy: Received: from [192.168.1.3] (unknown [71.212.134.3]) by mail.messagingengine.com (Postfix) with ESMTPA id 5601DE4535; Wed, 12 Dec 2018 20:06:31 -0500 (EST) Subject: =?UTF-8?Q?Re=3a_Errors_with_schema_migration_and_logical_replicatio?= =?UTF-8?B?biDigJQgZXhwZWN0ZWQ/?= To: Mike Lissner Cc: pgsql-general@lists.postgresql.org References: <42bcb35c-9173-bb9e-bda6-ea5c5950119b@aklaver.com> <953748cf-7271-7230-9158-178c8e4f475e@aklaver.com> <76570a30-61f0-470a-ff4b-582eb3e33df9@aklaver.com> <2f98e0cb-0a41-fecb-0ef0-16f288d52e50@aklaver.com> From: Adrian Klaver Message-ID: <0dc10006-a214-c8d0-d59f-e6fceb6a1c27@aklaver.com> Date: Wed, 12 Dec 2018 17:06:30 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 12/12/18 3:19 PM, Mike Lissner wrote: > This sounds *very* plausible. So I think there are a few takeaways: > > 1. Should the docs mention that additive changes with NOT NULL > constraints are bad? It's not the NOT NULL it's the lack of a DEFAULT. In general a column with a NOT NULL and no DEFAULT is going to to bite you sooner or later:) At this point I have gathered enough of those bite marks to just make it my policy to always provide a DEFAULT for a NOT NULL column. > > 2. Is there a way this could work without completely breaking > replication? For example, should Postgresql realize replication can't > work in this instance and then stop it until schemas are back in sync, > like it does with other incompatible schema changes? That'd be better > than failing in this way and is what I'd expect to happen. Not sure as there is no requirement that a column has a specified DEFAULT. This is unlike PK and FK constraint violations where the relationship is spelled out. Trying to parse all the possible ways a user could get into trouble would require something on the order of an AI and I don't see that happening anytime soon. > > 3. Are there other edge cases like this that aren't well documented that > we can expect to creep up on us? If so, should we try to spell out > exactly *which* additive changes *are* OK? Not that I know of. By their nature edge cases are rare and often are dealt with in the moment and not pushed out to everybody. The only solution I know of is pretesting your schema change/replication setup on a dev installation. > > This feels like a major "gotcha" to me, and I'm trying to avoid those. I > feel like the docs are pretty lacking here and that others will find > themselves in similarly bad positions. Logical replication in core(not the pglogical extension) appeared for the first time in version 10. On the crawl/walk/run spectrum it is moving from crawl to walk. The docs will take some time to be more complete. Just for the record my previous post was sketching out a possible scenario not an ironclad answer. If you think the answer is plausible and a 'gotcha' I would file a bug: https://www.postgresql.org/account/login/?next=/account/submitbug/ > > Better schema migration docs would surely help, too. > > Mike > > -- Adrian Klaver adrian.klaver@aklaver.com