Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eSOpv-0004aA-V6 for pgsql-general@arkaria.postgresql.org; Fri, 22 Dec 2017 15:02:12 +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 1eSOpv-0004pO-BY for pgsql-general@arkaria.postgresql.org; Fri, 22 Dec 2017 15:02:11 +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 1eSOpu-0004pE-RB for pgsql-general@lists.postgresql.org; Fri, 22 Dec 2017 15:02:11 +0000 Received: from smtp46.i.mail.ru ([94.100.177.106]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1eSOpn-0006Be-Vt for pgsql-general@postgresql.org; Fri, 22 Dec 2017 15:02:09 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mail.ru; s=mail2; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:MIME-Version:Date:Message-ID:From:References:Cc:To:Subject; bh=vLU6m+S7bl9JOq8eZ6nxxY1pqGcYPAv9zRhc6db71ag=; b=T+EvZV2UXQtzvgXAXpI7LaAFy0+YIASjVMLVgoDk15ijw/GISg2zlA7AwizpaAO6kIgD0kycZQgif9edUllKe+OEC8kop3HrHUpZ7KjOo7nfGEQTeuIxStzj0YKVMTUh5tAxSPpSJ9JvQVHOHGKv//tMZXH0VyBgHCVPwB7ihgQ=; Received: by smtp46.i.mail.ru with esmtpa (envelope-from ) id 1eSOpk-00042x-UW; Fri, 22 Dec 2017 18:02:01 +0300 Subject: Re: pg_upgrading to 10.1 corrupts (varchar,varchar) UNIQUE indices To: Peter Geoghegan Cc: pgsql-general General References: From: rihad Message-ID: <36a1c887-cfdd-14f2-9b65-d2ac5440eed0@mail.ru> Date: Fri, 22 Dec 2017 19:01:58 +0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Authentication-Results: smtp46.i.mail.ru; auth=pass smtp.auth=rihad@mail.ru smtp.mailfrom=rihad@mail.ru X-7FA49CB5: 0D63561A33F958A5FD2608C4BD86496EB985C3FBFC698E3C96984A4E6061034F725E5C173C3A84C3C8F21CEC4765490DD733BD1646CDD9B5B344165809136645C4224003CC836476C0CAF46E325F83A50BF2EBBBDD9D6B0F2AF38021CC9F462D574AF45C6390F7469DAA53EE0834AAEE X-Mailru-Sender: B19AB4DAF1EA2FB58A8BBB454389F7B480688CC36C18F234E39612165CA9D91746A0A24852759D85ABBFE0CF075BC50BFB559BB5D741EB96004FA9CEFBA991DA3A5DB60FBEB33A8A0DA7A0AF5A3A8387 X-Mras: OK List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 12/22/2017 05:32 PM, Peter Geoghegan wrote: > On Fri, Dec 22, 2017 at 11:56 AM, rihad wrote: >> I forgot to mention the real problem: the mentioned unique constraint didn't >> work and allowed duplicate rows to get inserted into the table until the >> duplicates were manually removed the the index was rebuilt. > You should run amcheck functions on both environments, against all > indexes, to see where the inconsistency arose, and to isolate any > other inconsistencies that may have been missed. While amcheck is > available from contrib in Postgres 10, you can get a version that will > work on other versions through OS packages for most major Linux > distributions. See: > > https://github.com/petergeoghegan/amcheck > > Note also that only this external version has the "heapallindexed" check. > Hm, interesting. It doesn't look like FreeBSD ports include the amcheck extension, but I could still use the versions bundled with postgres 10.1-contrib. Also, the version included doesn't allow a second boolean argument. I first ran it on a reindexed index, which didn't show any problems, as expected. Then I ran it on an unfixed broken index. foo=# create extension amcheck; CREATE EXTENSION foo=# select bt_index_check('index_translations_on_locale_and_key');  bt_index_check ---------------- (1 row) foo=# select bt_index_check('index_users_on_email_and_type'); ERROR:  item order invariant violated for index "index_users_on_email_and_type" DETAIL:  Lower index tid=(3,25) (points to index tid=(26,1)) higher index tid=(3,26) (points to index tid=(27,1)) page lsn=0/0.