Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dCpfz-0008FJ-Vz for pgsql-bugs@arkaria.postgresql.org; Mon, 22 May 2017 15:55:20 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1dCpfy-0007q0-NV for pgsql-bugs@arkaria.postgresql.org; Mon, 22 May 2017 15:55:18 +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 1dCpfG-0004CQ-5h; Mon, 22 May 2017 15:54:34 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dCpfC-000784-Cv; Mon, 22 May 2017 15:54:33 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 37E4C20681; Mon, 22 May 2017 11:54:28 -0400 (EDT) Received: from frontend1 ([10.202.2.160]) by compute5.internal (MEProxy); Mon, 22 May 2017 11:54:28 -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=KybnBCg+90yckkOhlieqM/EVRfSOENmYKOMib0a9nT0=; b=Jqo/ibg0 k6Bcm7E3RjkyQ2TXG75IHnAPk++kH4qeqFh+qF6EdWUJKKcmEV2iPhRKeqQmHXcr 0Hrkmw4zFhlcJmLiQRrnUx2LBGeirycKTBxiX1+ZajCoGuubWF3JmEXnwcZpEFtx QlQBwWTY5HXNA0GLtfUUmv1L5uQ6MdMz5P23y5kwyP3FT8JNL5whLNrlu2vXcAPG faf1NknUYlyiaPtXWbsm5z4vlyZBKzAH2cMzaJaf/8dznCexkJYAIIpJiTCy6GQ5 VrGmLI3NB7dc7h7e32QJcaDB7sjtcd8YSNP1fi9Im6FiwazCZXN38Y2jwuIW/DmY QUfISTILKpxGOA== X-ME-Sender: X-Sasl-enc: RlAUlrSJPUARfayNQ0ZyFj4qDwJWYrKREIzL7sqN7oz9 1495468467 Received: from intern.anarazel.de (unknown [75.104.71.148]) by mail.messagingengine.com (Postfix) with ESMTPA id 36C647E809; Mon, 22 May 2017 11:54:27 -0400 (EDT) Date: Mon, 22 May 2017 08:42:27 -0700 From: Andres Freund To: Robert Haas Cc: Peter Eisentraut , Michael Paquier , PostgreSQL mailing lists , Noah Misch , Jason Petersen , PostgreSQL mailing lists Subject: Re: [HACKERS] Concurrent ALTER SEQUENCE RESTART Regression Message-ID: <20170522154227.nvafbsm62sjpbxvd@alap3.anarazel.de> References: <20170430080517.GA811193@rfd.leadboat.com> <59aeb834-b113-6769-bfe4-65f2f8c875e3@2ndquadrant.com> <20170507234334.yimkp6aq2o43wtt2@alap3.anarazel.de> <4521f870-bb1f-1b29-3b3f-42419696efe7@2ndquadrant.com> <2a1e0c9e-8485-dfd8-86b8-a95542deec30@2ndquadrant.com> <20170518205428.kxxtsdl6wswnz3e3@alap3.anarazel.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: 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 2017-05-19 08:31:15 -0400, Robert Haas wrote: > On Thu, May 18, 2017 at 4:54 PM, Andres Freund wrote: > > There's still weird behaviour, unfortunately. If you do an ALTER > > SEQUENCE changing minval/maxval w/ restart in a transaction, and abort, > > you'll a) quite possibly not be able to use the sequence anymore, > > because it may of bounds b) DDL still isn't transactional. > > Your emails would be a bit easier to understand if you included a few > more words. Yea - I'd explained this one already somewhere upthread, and I'd hoped it'd be enough, but I probably was wrong. > I'm guessing "may of bounds" is supposed to say "may be out of bounds"? Yes. Consider a scenario like: S1: CREATE SEQUENCE oobounds MINVALUE 1 START 1; S1: SELECT nextval('oobounds'); -> 1 S2: BEGIN; S2: ALTER SEQUENCE oobounds MAXVALUE -10 START -10 MINVALUE -1000 INCREMENT BY -1 RESTART; S2: SELECT nextval('oobounds'); -> -10 S2: ROLLBACK; S1: SELECT * FROM pg_sequence WHERE seqrelid = 'oobounds'::regclass; ┌──────────┬──────────┬──────────┬──────────────┬─────────────────────┬────────┬──────────┬──────────┐ │ seqrelid │ seqtypid │ seqstart │ seqincrement │ seqmax │ seqmin │ seqcache │ seqcycle │ ├──────────┼──────────┼──────────┼──────────────┼─────────────────────┼────────┼──────────┼──────────┤ │ 203401 │ 20 │ 1 │ 1 │ 9223372036854775807 │ 1 │ 1 │ f │ └──────────┴──────────┴──────────┴──────────────┴─────────────────────┴────────┴──────────┴──────────┘ S1: SELECT nextval('oobounds'); -> -9 Ooops. Two issues: Firstly, we get a value smaller than seqmin, obviously that's not ok. But even if we'd error out, it'd imo still not be ok, because we have a command that behaves partially transactionally (keeping the seqmax/min transactionally), partially not (keeping the current sequence state at -9). - Andres -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs