Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eLrrF-000588-EM for pgsql-bugs@arkaria.postgresql.org; Mon, 04 Dec 2017 14:36:33 +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 1eLrrE-0003E6-Ho for pgsql-bugs@arkaria.postgresql.org; Mon, 04 Dec 2017 14:36: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.84_2) (envelope-from ) id 1eLrrE-0003Dw-C7 for pgsql-bugs@lists.postgresql.org; Mon, 04 Dec 2017 14:36:32 +0000 Received: from mail-wr0-x22e.google.com ([2a00:1450:400c:c0c::22e]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1eLrrB-00052X-2H for pgsql-bugs@postgresql.org; Mon, 04 Dec 2017 14:36:31 +0000 Received: by mail-wr0-x22e.google.com with SMTP id o2so17537948wro.5 for ; Mon, 04 Dec 2017 06:36:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=YLLXqCjGXSUy4pWvsIFj/bP5McM0I6jqP/ufN1ehMg8=; b=tC52CHJXe708jx+JSt7wJKyXrbwtr9dwWYP3II+JKBdCYi3L9HZM4+wQAmJZtblzDH Ce3HAWY9uUWWArXrBAie3otP0BaeseL+9cT0AUiYoOolNxLIvZo6Ak2CuZZw6qooDQ8/ enT55s3wNMe/YthhIJ4JGMBlPa0vhxn40RBJLuXqS9/ZhQleXbr1+5eWQnCq3DAyHTtk i5ypOZsqDYBwX/dC48jhMdKA1dMQFO+2GJd8NpmX1/9o7Ygs10IQL9IY5Z2M2ilQvdMP WT26/a4WOtmDKXXD44Bt4iBDSxvxbI0TKiwEKyYwQMUdZ5Rw0865eaHEVYa+7zfsL/vk BW6A== 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:content-language :content-transfer-encoding; bh=YLLXqCjGXSUy4pWvsIFj/bP5McM0I6jqP/ufN1ehMg8=; b=lXsSHJmD+JNXPdHnoYjNBzJV8hvY0zVGHLDAKQC5VFeuDZ54O9aDlDvIEn+KPnMDh8 yGhWSrw7NHkC0nYVgrkVRTcmRpaMt38fUq409pzPX4Ryh8BnpxbP7L2Rzx0b2SldOuNq Ywhdne/o3TTMkrxtlUPOx6h6T4I012ik+hV2UZpQp2HABps1Hf6Y1YMxlKGSIpCcsNZv qNHD+kGeJ2e9ibs//yU4qLmuF+CDbGFklgWlHsirqsSpDRklowm6lW/3zO8WDxPneqbe 3vFj/pbgfiyTdCgV2dqltUaDNfWiDTYBxUdoju7j2O4ojseWkvslF+Ih758jD2rHft+9 BgBg== X-Gm-Message-State: AJaThX5pdPiimsxDTJ0Iujjn13ruFh9w2BsEwVw64gA6BAaIIVf2/YbL CvZnUmMyRvj3ncJeZ661fJXrQOKKC/6rMEf6XjvN4I9WEhaxKovYxr8zL3qVVnNmiA4jjIXP6Je rnFduFVLfNy87U/e2ccDTAoAibY2JI1OQ4K1g57+AmB04RWZCL5YCjrG9iMy/fkY+ulqPdnQDjz 9Rgb7n X-Google-Smtp-Source: AGs4zMZ1/zPa2OGWobNXAfTlA8o4KwpCDCUaN21jzPRgJDZsHAoizEU1xwSv6uaKZ6QLftT5B963PQ== X-Received: by 10.223.160.217 with SMTP id n25mr12804665wrn.27.1512398187093; Mon, 04 Dec 2017 06:36:27 -0800 (PST) Received: from [10.137.2.19] (ip-78-102-97-226.net.upcbroadband.cz. [78.102.97.226]) by smtp.gmail.com with ESMTPSA id c19sm8010558wmd.14.2017.12.04.06.36.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 Dec 2017 06:36:26 -0800 (PST) Subject: Re: BUG #14940: Duplicated records inspite of primary key and unique constraint To: =?UTF-8?B?0KHQtdGA0LPQtdC5INCQLiDQpNGA0L7Qu9C+0LI=?= , Alvaro Herrera Cc: pgsql-bugs@postgresql.org References: <20171201171513.if4pd67kh5sl7u53@alvherre.pgsql> <023c1715-3a10-1a4d-6efd-ccb8823fdfb8@smetarik.ru> From: Tomas Vondra Message-ID: <2e9f0483-f084-53e9-e80b-bf112f9a6053@2ndquadrant.com> Date: Mon, 4 Dec 2017 15:36:23 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <023c1715-3a10-1a4d-6efd-ccb8823fdfb8@smetarik.ru> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 12/04/2017 09:22 AM, Сергей А. Фролов wrote: > 1.  I'll try amcheck after I get system on Debian and if the problem > will remain after dump/restore. > > 2. Switthing off enable_indexscan enable_bitmapscan has no effect: > > set enable_indexscan = off; > set enable_bitmapscan  = off; > > select ctid,xmin,xmax, id, base_id, norm_id from nb.nb_basedtl where id = > 11658502; > > (0,49);364507;0;11658502;269;46203 > (0,49);370881;0;11658502;269;46203 > (0,49);370882;0;11658502;269;46203 > > > select ctid,xmin,xmax,id, base_id, norm_id from nb.nb_basedtl where id > in (select > id from nb.nb_basedtl  group by id having count(1) > 1 ) order by ctid,id > (0,1);364507;0;16101774;321;1239643 > (0,1);370881;0;16101774;321;1239643 > (0,1);370882;0;16101774;321;1239643 > (0,2);370882;0;20365934;425;2 > (0,2);370881;0;20365934;425;2 > (0,2);364507;0;20365934;425;2 > (0,3);370881;0;20365935;425;3 > (0,3);364507;0;20365935;425;3 > (0,3);370882;0;20365935;425;3 > (0,4);370881;0;20365936;425;4 > (0,4);364507;0;20365936;425;4 > ... > (0,49);370882;0;11658502;269;46203 > (0,49);370881;0;11658502;269;46203 > (0,49);364507;0;11658502;269;46203 > (0,50);364507;0;11658508;269;46204 > (0,50);370882;0;11658508;269;46204 > (0,50);370881;0;11658508;269;46204 > Interesting. All the duplicate records seem to be on the first page, and there are always three of them ... I wonder if those records are part of the same HOT chain, or something like that. Can you look at the page using pageinspect? Something like SELECT * FROM heap_page_items(get_raw_page('nb.nb_basedtl', 0)); regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services