From: Andres Freund <andres@anarazel.de>
To: Robert Haas <robertmhaas@gmail.com>
Cc: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
Cc: Michael Paquier <michael.paquier@gmail.com>
Cc: PostgreSQL mailing lists <pgsql-hackers@postgresql.org>
Cc: Noah Misch <noah@leadboat.com>
Cc: Jason Petersen <jason@citusdata.com>
Cc: PostgreSQL mailing lists <pgsql-bugs@postgresql.org>
Subject: Re: [HACKERS] Concurrent ALTER SEQUENCE RESTART Regression
Date: Mon, 22 May 2017 08:42:27 -0700
Message-ID: <20170522154227.nvafbsm62sjpbxvd@alap3.anarazel.de> (raw)
In-Reply-To: <CA+TgmoadW_JQRSCn4qCQE1FsD+FNwzW+_cLdHDnMf6Qk+S1XiQ@mail.gmail.com>
References: <E77D2275-DA45-4F43-B00D-A9B113DFA9FB@anarazel.de>
<CAB7nPqQ=yHXxiWU2FuaC13L_5y7UG7R_OkJhWQbXYMJPXCDtNg@mail.gmail.com>
<20170430080517.GA811193@rfd.leadboat.com>
<59aeb834-b113-6769-bfe4-65f2f8c875e3@2ndquadrant.com>
<20170507234334.yimkp6aq2o43wtt2@alap3.anarazel.de>
<4521f870-bb1f-1b29-3b3f-42419696efe7@2ndquadrant.com>
<CAB7nPqQvG=B6Bqz_mSc1YoA0O5T52dDL9-9stKWPgFPWvEe=hw@mail.gmail.com>
<2a1e0c9e-8485-dfd8-86b8-a95542deec30@2ndquadrant.com>
<20170518205428.kxxtsdl6wswnz3e3@alap3.anarazel.de>
<CA+TgmoadW_JQRSCn4qCQE1FsD+FNwzW+_cLdHDnMf6Qk+S1XiQ@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
On 2017-05-19 08:31:15 -0400, Robert Haas wrote:
> On Thu, May 18, 2017 at 4:54 PM, Andres Freund <andres@anarazel.de> 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: andres@anarazel.de, robertmhaas@gmail.com, peter.eisentraut@2ndquadrant.com, michael.paquier@gmail.com, pgsql-hackers@postgresql.org, noah@leadboat.com, jason@citusdata.com
Subject: Re: [HACKERS] Concurrent ALTER SEQUENCE RESTART Regression
In-Reply-To: <20170522154227.nvafbsm62sjpbxvd@alap3.anarazel.de>
References: <E77D2275-DA45-4F43-B00D-A9B113DFA9FB@anarazel.de> <CAB7nPqQ=yHXxiWU2FuaC13L_5y7UG7R_OkJhWQbXYMJPXCDtNg@mail.gmail.com> <20170430080517.GA811193@rfd.leadboat.com> <59aeb834-b113-6769-bfe4-65f2f8c875e3@2ndquadrant.com> <20170507234334.yimkp6aq2o43wtt2@alap3.anarazel.de> <4521f870-bb1f-1b29-3b3f-42419696efe7@2ndquadrant.com> <CAB7nPqQvG=B6Bqz_mSc1YoA0O5T52dDL9-9stKWPgFPWvEe=hw@mail.gmail.com> <2a1e0c9e-8485-dfd8-86b8-a95542deec30@2ndquadrant.com> <20170518205428.kxxtsdl6wswnz3e3@alap3.anarazel.de> <CA+TgmoadW_JQRSCn4qCQE1FsD+FNwzW+_cLdHDnMf6Qk+S1XiQ@mail.gmail.com> <20170522154227.nvafbsm62sjpbxvd@alap3.anarazel.de>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox