Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1byZRT-0007Kn-LN for pgsql-hackers@arkaria.postgresql.org; Mon, 24 Oct 2016 07:13:08 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1byZRT-000862-6Q for pgsql-hackers@arkaria.postgresql.org; Mon, 24 Oct 2016 07:13:07 +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 1byZRR-00085m-4i for pgsql-hackers@postgresql.org; Mon, 24 Oct 2016 07:13:05 +0000 Received: from mail.postgrespro.ru ([93.174.131.138]) by makus.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1byZRJ-0001PR-FK for pgsql-hackers@postgresql.org; Mon, 24 Oct 2016 07:13:03 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.postgrespro.ru (Postfix) with ESMTP id 3631F21C316E; Mon, 24 Oct 2016 10:12:54 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at postgrespro.ru Received: from mail.postgrespro.ru ([127.0.0.1]) by localhost (mail.postgrespro.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 20fnprzIsTuh; Mon, 24 Oct 2016 10:12:54 +0300 (MSK) Received: from [192.168.27.61] (unknown [192.168.27.1]) by mail.postgrespro.ru (Postfix) with ESMTPSA id 0275321C3166; Mon, 24 Oct 2016 10:12:53 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1477293174; bh=6A4qMc/eXWnK+JgGgFWNLkTLYCw7XM+XTUwQdg3cjr8=; h=Subject:To:References:Cc:From:Date:In-Reply-To; b=C/boVRn1HiUvQ4vfXGTQa2DVmUELzrnMLco5qkUnufZaAlAP+j0IFrs1+Hxzg+jjk TFsRs69J6ZeqlJhb0mx/4ttHWfsriF4ylegN7HGV/cRfQvORWL4MXnHxEHvD1iTUiG ZJcTNT6q1xvzkiE2VqMxhetVfJRgIPmsNI8o0mhg= Subject: Re: On conflict update & hint bits To: Peter Geoghegan , Tom Lane References: <57EE93C8.8080504@postgrespro.ru> <31342.1477154327@sss.pgh.pa.us> <23481.1477255321@sss.pgh.pa.us> <30037.1477259205@sss.pgh.pa.us> Cc: PostgreSQL Hackers , Andres Freund , Kevin Grittner , Thomas Munro From: Konstantin Knizhnik Message-ID: <580DB47B.5000200@postgrespro.ru> Date: Mon, 24 Oct 2016 10:12:59 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -3.3 (---) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org On 24.10.2016 00:49, Peter Geoghegan wrote: > On Sun, Oct 23, 2016 at 2:46 PM, Tom Lane wrote: >> What's bothering me is (a) it's less than 24 hours to release wrap and >> (b) this patch changes SSI-relevant behavior and hasn't been approved >> by Kevin. I'm not familiar enough with that logic to commit a change >> in it on my own authority, especially with so little time for problems >> to be uncovered. > I should point out that I knew that the next set of point releases had > been moved forward much later than you did. I had to work on this fix > during the week, which was pretty far from ideal for me for my own > reasons. > Just for information: I know that you are working on this issue, but as far as we need to proceed further with our testing of multimaster, I have done the following obvious changes and it fixes the problem (at least this assertion failure is not happen any more): src/backend/executor/nodeModifyTable.c @@ -1087,6 +1087,13 @@ ExecOnConflictUpdate(ModifyTableState *mtstate, test = heap_lock_tuple(relation, &tuple, estate->es_output_cid, lockmode, LockWaitBlock, false, &buffer, &hufd); + /* + * We must hold share lock on the buffer content while examining tuple + * visibility. Afterwards, however, the tuples we have found to be + * visible are guaranteed good as long as we hold the buffer pin. + */ + LockBuffer(buffer, BUFFER_LOCK_SHARE); + switch (test) { case HeapTupleMayBeUpdated: @@ -1142,6 +1149,7 @@ ExecOnConflictUpdate(ModifyTableState *mtstate, * loop here, as the new version of the row might not conflict * anymore, or the conflicting tuple has actually been deleted. */ + LockBuffer(buffer, BUFFER_LOCK_UNLOCK); ReleaseBuffer(buffer); return false; @@ -1175,6 +1183,8 @@ ExecOnConflictUpdate(ModifyTableState *mtstate, /* Store target's existing tuple in the state's dedicated slot */ ExecStoreTuple(&tuple, mtstate->mt_existing, buffer, false); + LockBuffer(buffer, BUFFER_LOCK_UNLOCK); + /* * Make tuple and any needed join variables available to ExecQual and * ExecProject. The EXCLUDED tuple is installed in ecxt_innertuple, while -- Konstantin Knizhnik Postgres Professional: http://www.postgrespro.com The Russian Postgres Company -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers