Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id A075768DFC for ; Wed, 16 May 2012 08:15:08 -0300 (ADT) Received: from exprod7og110.obsmtp.com ([64.18.2.173]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SUcCA-0003R4-Ju for pgsql-bugs@postgresql.org; Wed, 16 May 2012 11:15:08 +0000 Received: from mail-lpp01m010-f42.google.com ([209.85.215.42]) (using TLSv1) by exprod7ob110.postini.com ([64.18.6.12]) with SMTP ID DSNKT7OMLQq7scLjk3h2DwC/EtZlcmI7N1G1@postini.com; Wed, 16 May 2012 04:15:06 PDT Received: by lagy4 with SMTP id y4so427092lag.29 for ; Wed, 16 May 2012 04:14:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding :x-gm-message-state; bh=mP2sxdrwg0wSpwSrZmV2LxX90UJznCXUkDPmwMfb4T0=; b=TnkYqnAPlroZx8qIku1u5U4uBukxwJ4S8cFsuN/ZhUqjzWIQnv4sZrRzRFjZquLqbs zTyax92ja/hrI3zZwtQWzumhNdAhleiP4Gy6qPzF8oSFnnDpo3plHc1tQPjOHg3+UfD1 yxUcGWRuM6NAo8H3xk7D+9Z38bsGJHHNQFn6QLZX/65jrQCIPH9BjMNDD1Ft15ggiY07 nr8nHiCxGLMIsyM0KJWQtGUl8kRdcEoLece21xLWjB/wT4gOQMxitvQ9vPwDU+ceTtGC Hr/xvu7fMn6vvRIS2v4xuBfWP9Du/ktA688dlyCYPc7znpho7w4G7KSuQjg0iAxmwGzZ sueA== Received: by 10.152.106.9 with SMTP id gq9mr2581777lab.14.1337166891742; Wed, 16 May 2012 04:14:51 -0700 (PDT) Received: from [192.168.1.102] (dsl-hkibrasgw2-ff6cc300-200.dhcp.inet.fi. [88.195.108.200]) by mx.google.com with ESMTPS id j3sm3139055lbh.0.2012.05.16.04.14.50 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 16 May 2012 04:14:50 -0700 (PDT) Message-ID: <4FB38C29.8070009@enterprisedb.com> Date: Wed, 16 May 2012 14:14:49 +0300 From: Heikki Linnakangas User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.4) Gecko/20120510 Icedove/10.0.4 MIME-Version: 1.0 To: katsumata.tomonari@po.ntts.co.jp CC: pgsql-bugs@postgresql.org Subject: Re: BUG #6643: [PostgreSQL9.2beta1] COPY after changing fillfactor gets a PANIC. References: <4FB385C9.8050001@enterprisedb.com> In-Reply-To: <4FB385C9.8050001@enterprisedb.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Gm-Message-State: ALoCoQn7qMr7fbZLEmfkYFYUlWg5AN5A236bdYUH4cNZadjQ+q0fzvv76/Y2jsuzdII0JjeCvKvF X-Pg-Spam-Score: -4.2 (----) X-Archive-Number: 201205/91 X-Sequence-Number: 33062 On 16.05.2012 13:47, Heikki Linnakangas wrote: > This sounds like a bug in the new page-at-a-time behavior in COPY. Can > you send me a self-contained test, including the test data? Never mind. After staring at the code for a while, I spotted the bug, and was able to reproduce with a simpler case. It's quite easy to reproduce when you set fillfactor even lower, like 10. The problem is with this line in heap_multi_insert function: if (PageGetHeapFreeSpace(page) - saveFreeSpace < MAXALIGN(heaptup->t_len)) That doesn't work as intended, because the return value of PageGetHeapFreeSpace and saveFreeSpace are unsigned. When saveFreeSpace is larger than the amount of free space on the page, the left hand side of that comparison is supposed to go negative, but it wraps around to a highly positive number because it's unsigned. Fixed, thanks for the report! -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com