Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kAXDQ-0002cv-Ta for pgsql-admin@arkaria.postgresql.org; Tue, 25 Aug 2020 11:34:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kAXDP-00073W-O3 for pgsql-admin@arkaria.postgresql.org; Tue, 25 Aug 2020 11:34:11 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kAXDP-00073P-EF for pgsql-admin@lists.postgresql.org; Tue, 25 Aug 2020 11:34:11 +0000 Received: from mout.gmx.net ([212.227.15.15]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kAXDN-0007ju-CT for pgsql-admin@lists.postgresql.org; Tue, 25 Aug 2020 11:34:11 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1598355247; bh=xsMS5X8qRxyGhkI9STVzC8nnFgBk9/ogG4HivPWgK2E=; h=X-UI-Sender-Class:Subject:To:References:From:Date:In-Reply-To; b=L5ErmCUs+wTghSA6Y9vPNhYAAB3BF2YaJl1871692ZzxMYJ8J9u9mA9ofB02h3X4O ASu0nGw0mrKVygnct2+oilhUM7kxKIl5nABhs+fwXyTDyiMBgJ2F+1B2TVlZ65NwCi DNY7YvZqYOBQbZYTtOl0Hhpy5y890Wpn4zmpCfzY= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [10.1.35.214] ([185.40.248.10]) by mail.gmx.com (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1Mt75H-1kUPVm013B-00tS2t for ; Tue, 25 Aug 2020 13:34:07 +0200 Subject: Re: How to debug logical replication error "columns are missing" if they are not To: pgsql-admin@lists.postgresql.org References: <6d2d142f-58b4-d2db-b271-700182b68b55@gmx.net> From: Thomas Kellerer Message-ID: Date: Tue, 25 Aug 2020 13:34:05 +0200 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.23) Gecko/20090812 Thunderbird/2.0.0.23 Mnenhy/0.7.6.666 MIME-Version: 1.0 In-Reply-To: <6d2d142f-58b4-d2db-b271-700182b68b55@gmx.net> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:WLcN74XepiqKO0psr3+JneayavG/0WogRexyCNvf9wdXfmvXyM1 dEil177Fu1jn6UKlH/W3e6TAzBu9ljvoZdpW7HO7vCHu+UJf/btpgAHHcpJTwMOAUgRmATN aQxIWAM6VMP82rg+1KVoOCXntOr4KVjmpv43s3yQLpdxa/hkLdDfjKPe7wEYDB9k/tcSx8K NdHAjKo0Z0DB6321cKh1g== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:D+h+vhlxjwY=:dyn859/fmR2SyqYFtQyMNO 6++/NRQcSOQgvSZblZ2GEo31R9de/tAgDAZx3kbukoRjJhcXgC3A0r/mDguMby488pycduD8P z7m1VKLPiTbB461yAi8ikap4Psp7n1KSFUAyFgBFkIWBQ/+BsAse6TnnIC2DslPKIg34fajqJ TPNjEskhHrGlBLUfXFY7rglMnby4ty8TMgA1a0kv/Irgrh4hcEzhqVZDYGXdIoALMtxqku+bK /wMk5VI1eFNdFy4FnysrX+nvzTmS0wMkH1cuQWJAWjZgqH5+RctDGUl1R2wiPrUvLDVfUG1JE YjeCHHWpgBW63SDMGvwiXmiUuHU7j1cPzXBCTknrm53lhndU4lZRcalFj9Pr3R4Z7q0RMTdaW UyNAjE8CYI5aeGzuXSMGqU9u1EA/Fr1giOd4hHCqU5FxdGKd0fODQYSvkDfu/EJitctd3gKeC DCyV2UdBiIx/5M2lwkXVqLbPH1/CJtaXGcVtvN9/eT7oHEhBJMJ4+wgEPgw3H08GD40KR7V8h EKWqy8OGaXugFOi8I0aLU5nOUwik3XENYFME0XSza8uVYrt9KS6Rq9BqCYgaFXqqa5etLKH3j DYsroRS6ilznrLbl2mlDhNfxT1vNI7OwmTbgTnx9EaxDPRjujXMbCY9y2A3/m8Md0Jy8IaCT8 oElzbfQOE9FPWZMJPIS1ibT7usBV10kprDAgkT52F7EwRsSicBR8EEvephfGcMySq0U7zM2Kg bG0JRJa+KJnaM+ZS1f7XqxfY7RzExbUGASVpM3/JHA6e3PZltbb6E+vSjBoxJeV8Jguz2hyKk 0vcsBbdrE1v+ci/R7tae0provNJXHNp/QMn7rA4zB8nHkd37GaZZXN8ZLJg0cvqMnSCMaGEMI LByWsaQco7vY44FhsHi7Y38/KVI3CelEOcv2CjejYV8SDZXuOIYKsR9ZJ3vpRXUOwmfKBg2WL CuRL5Cfeyxc2664uSJXlKSss64tyS6LJaulf0XWEMhiN+DNDrIq1dgjc5xF2J2oJSjZpsQc/j 489bteLNU8I/g843lmarmXYBYUFLbEcFujclx+p9VCCM16r2TNUB2X1ngkAMKC0Fe2Wv1M0Lv 7rpjq6maLJkHVPjVbq63Eq7yyFtIa1sqUNRuj9VzI+32NFpu6nrCiTgJK40YwU6QzZwHpsxBw Fjb/3p87QlkA7Ez7LcM3GpZ+jr9pDZ404qZfDQFD6VUv3bkf4P6Kr+oncRrMC2TdF5x+nDnO4 ZsziCDQ0H0ycevhH6 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Thomas Kellerer schrieb am 25.08.2020 um 07:32: > we have a a logical replication from Postgres 11 to Postgres 12. > > We did some structural changes to the published tables. The changes > to the subscriber where applied about 60 minutes later then those on > the publisher. Obviously before the subscriber's tables where synced > the replication failed. > But even though the tables are now completely identical, the subscriber = still claims: > logical replication target relation "public.employee" is missing some = replicated columns So - as explained by Samed - the problem boils down to a setup like this: The initial table looked like this (on both sides) create table test_table (id integer primary key, valid_from date, vali= d_to date); Replication is running fine, then we run the following on the publisher begin transaction; ALTER TABLE test_table ADD COLUMN start_end_date daterange; UPDATE test_table SET start_end_date =3D daterange(valid_from, valid_t= o, '[]'); ALTER TABLE test_table ALTER COLUMN start_end_date SET NOT NULL; ALTER TABLE test_table DROP COLUMN valid_from, DROP COLUMN valid_to; commit; If the UPDATE part is removed from the change, everything works smoothly. So, the UPDATE sends the complete modified row including the to be dropped= columns to the subscriber. As I ran the same steps on the subscriber, the columns were dropped on the= subscriber before the UPDATE could be replayed and thus it kept failing. I do understand now why this happens, and that it is a limitation of the c= urrent implementation. However, what I don't understand is, why removing the table from the repli= cation doesn't fix this. It seems, that if the table is re-added later, the old WAL segments are st= ill considered valid and Postgres tries to replay them. Which seems a rather strange thing to do to me. Could anyone enlighten me on that? Is there a way to mark the no longer needed WAL segments as obsolete? Regards Thomas