Re: Concurrent ALTER SEQUENCE RESTART Regression

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>, Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, Jason Petersen <jason(at)citusdata(dot)com>, PostgreSQL mailing lists <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: Concurrent ALTER SEQUENCE RESTART Regression
Date: 2017-05-02 16:45:35
Message-ID: CA+TgmoZne41kmc7bT3LH8r4M2hmxzqK33nPXGhXQmfh9ar4ZZQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

On Thu, Apr 27, 2017 at 1:52 AM, Andres Freund <andres(at)anarazel(dot)de> wrote:=
> In contrast to <v10, the actual change of the tuple is *not* happening
> with the page lock held. But now we do log XLOG_SEQ_LOG, then unlock
> the buffer, and then do a CatalogTupleUpdate(). How is that correct?
> And if so, why isn't there a honking large comment explaining why it is?

I can't actually understand this complaint. I think this code is
buggy, but for different reasons than you do. The page lock is held,
because read_seq_tuple() acquires it. And then we call heap_open()
with the buffer lock held?! I don't think that's a good idea in any
way - we shouldn't be doing complex operations that might acquire a
buffer lock while we're holding a buffer lock. But by the same token
surely we don't want to do CatalogUpdateIndexes() while holding the
buffer lock either; mutual exclusion needs to be managed at some
higher level, using, say, a heavyweight tuple lock.

Another thing that doesn't look so good about AlterSequence is that it
uses RangeVarGetRelid() instead of RangeVarGetsRelidExtended() with
RangeVarCallbackOwnsRelation or some derivative thereof. That of
course means you can obstruct access to a sequence you don't own.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Andres Freund 2017-05-02 17:36:05 Re: Concurrent ALTER SEQUENCE RESTART Regression
Previous Message Ray Warren 2017-05-02 16:25:33 Re: BUG #14639: Different xmin values in a transaction

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2017-05-02 16:47:33 Re: scram and \password
Previous Message Vladimir Borodin 2017-05-02 16:37:44 Re: [PROPOSAL] Use SnapshotAny in get_actual_variable_range