Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d5Zat-0007of-Jh for pgsql-bugs@arkaria.postgresql.org; Tue, 02 May 2017 15:20:03 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1d5Zas-00084o-Ak for pgsql-bugs@arkaria.postgresql.org; Tue, 02 May 2017 15:20:02 +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 1d5ZaB-0006rd-DK for pgsql-bugs@postgresql.org; Tue, 02 May 2017 15:19:19 +0000 Received: from out4-smtp.messagingengine.com ([66.111.4.28]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1d5Za3-0007sg-9o for pgsql-bugs@postgresql.org; Tue, 02 May 2017 15:19:18 +0000 Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id B05E320964; Tue, 2 May 2017 11:19:09 -0400 (EDT) Received: from frontend2 ([10.202.2.161]) by compute7.internal (MEProxy); Tue, 02 May 2017 11:19:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc:x-sasl-enc; s= fm1; bh=vu603ldrvW7Ot+gt6aG4HWgqp3rW1XamAaA8Sb348ZU=; b=sD6riNFp Ax5UVfN4BKjH5DQfwQgtl+6xEwgk5cSyOXAAbZKm15f1a5yflyFQDtUq6NlWw/58 psy5ynFMWXbA0hI89AR4/tGsvCeWsCkd66/urv+BVsNLs3c69dRZiMGY50bo9g4D HHBY6X9x6DuU2A+sqRkYHWXv0HNzeJro3e2qpr49n+HNpGCH/Q5g+iIkcwNJwiIX BYtzQvcOPnx+SBwF7yRyAYRcIG4jqu6PWGQVxtAWQ+vj+Zv/Wnabn2NO/CObEtoY 4UJoBczqFQYh2jk2j3MUAnA0yvq0HNYg1dGUBWrRDASX2qbbNBvfgoyLHy/x++pS kKfGnhL5pR4G3w== X-ME-Sender: X-Sasl-enc: 4Q/v6/PLN5km1ev1hZchYCmMIAERcUomcTgmLxJXw3cw 1493738349 Received: from april.local (c-73-13-66-39.hsd1.pa.comcast.net [73.13.66.39]) by mail.messagingengine.com (Postfix) with ESMTPA id 787D22415E; Tue, 2 May 2017 11:19:09 -0400 (EDT) Subject: Re: Concurrent ALTER SEQUENCE RESTART Regression To: Andres Freund References: <20170502150744.l6jr32attx2f6575@alap3.anarazel.de> Cc: Jason Petersen , pgsql-bugs@postgresql.org From: Peter Eisentraut Organization: 2ndQuadrant Message-ID: <2adb9428-8cac-6620-3269-9a9a2b8ff6a0@2ndquadrant.com> Date: Tue, 2 May 2017 11:19:08 -0400 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <20170502150744.l6jr32attx2f6575@alap3.anarazel.de> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org On 5/2/17 11:07, Andres Freund wrote: > On 2017-05-02 10:53:19 -0400, Peter Eisentraut wrote: >> On 4/24/17 15:52, Jason Petersen wrote: >>> 1. Create a new sequence: CREATE SEQUENCE my_seq; >>> 2. Start this loop twice in different shells: >>> while true; do psql -1Xtc 'ALTER SEQUENCE my_seq RESTART 1'; done >> >>> Each loop should repeatedly succeed and simply print ALTER SEQUENCE over and over. >> >>> The output stream is punctuated by occasional "ERROR: tuple concurrently updated" messages. >> >> This message comes from the pg_sequence catalog update. But in the case >> of the RESTART clause, you don't need to update the catalog, because it >> just needs to write to the sequence's relation. So I have tweaked the >> code a little to omit the catalog update if it's not needed. Your test >> case works without errors now. > > Wait, how does this *actually* solve anything, but scratch at the > surface? You just add a MAXVALUE and it starts failing (and not being > adhered to) again? The just committed patch somewhat disentangles the transactional from the nontransactional parts of ALTER SEQUENCE. RESTART is a nontransactional action. Now you get the same concurrency behavior for RESTART as you would for setval and nextval. This was not the case prior to the fix. Other clauses such as MAXVALUE are transactional actions. You get the same concurrency behavior as for most DDL in PostgreSQL. You could argue that the RowExclusiveLock on pg_sequence in not enough and should be perhaps ShareRowExclusiveLock to avoid "tuple concurrently updated" messages. But just over in 521fd4795e3ec3d0b263b62e5eb58e1557be9c86 it was argued that that sort of thing was undesirable. -- Peter Eisentraut http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs