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 1g9wkE-0005uM-9V for pgsql-novice@arkaria.postgresql.org; Tue, 09 Oct 2018 18:28:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1g9wkC-00070j-VZ for pgsql-novice@arkaria.postgresql.org; Tue, 09 Oct 2018 18:28:32 +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 1g9wkC-00070X-PD; Tue, 09 Oct 2018 18:28:32 +0000 Received: from mx1.mailbox.org ([80.241.60.212]) by magus.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1g9wkA-0002F7-9E; Tue, 09 Oct 2018 18:28:32 +0000 Received: from smtp1.mailbox.org (unknown [IPv6:2001:67c:2050:105:465:1:1:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.mailbox.org (Postfix) with ESMTPS id B0213499D4; Tue, 9 Oct 2018 20:28:28 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp1.mailbox.org ([80.241.60.240]) by spamfilter01.heinlein-hosting.de (spamfilter01.heinlein-hosting.de [80.241.56.115]) (amavisd-new, port 10030) with ESMTP id 2Gs5dSGA77S8; Tue, 9 Oct 2018 20:28:27 +0200 (CEST) Message-ID: <47175ca8aea768568fb51e1a91c94d436ef79d97.camel@cybertec.at> Subject: Re: pg_dumpall and restore From: Laurenz Albe To: "Rossi, Maria" , "'pgsql-sql@lists.postgresql.org'" , "'pgsql-novice@lists.postgresql.org'" Date: Tue, 09 Oct 2018 20:28:25 +0200 In-Reply-To: <323742d3468543f590fc081c7fba0c7a@DC03PXMBP003.jacksonnational.com> References: <323742d3468543f590fc081c7fba0c7a@DC03PXMBP003.jacksonnational.com> Organization: Cybertec Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Rossi, Maria wrote: > I upgraded our postgres database from V9.3 to V10.5. Used pg_dumpall then restore it to the new instance. > After the restore, we notice that 1 table had duplicate rows, such that it was not able to create the primary key. > I checked the old database, it does not have the dups. > Has anyone encountered having dups rows loaded? Any idea what caused this and how to prevent? > > Your help would be much appreciated. I don't believe that pg_dumpall miraculously duplicated the row. You probably *do* have a duplicate row, and hence table corruption, but I suspect that one of the rows is not in the index you used to look for the row. If you query: SELECT * FROM tab WHERE id = 42; the query will likely use the index on "id" and find only one of the rows. You should SET enable_indexscan = off; SET enable_indexonlyscan = off; and then repeat the query, so that a sequential scan is used. To fix, delete one of the rows and reindex. You can identify a row by its tuple id: SELECT ctid, * FROM tab WHERE id = 42; Yours, Laurenz Albe -- Cybertec | https://www.cybertec-postgresql.com