pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Bruce Momjian <bruce@momjian.us>
Cc: Michael Paquier <michael@paquier.xyz>
Cc: Robins Tharakan <tharakan@gmail.com>
Cc: pgsql-bugs@postgresql.org
Subject: Re: ALTER TABLE ALTER COLUMN SET TYPE crash
Date: Tue, 25 Aug 2020 12:14:20 -0400
Message-ID: <2745154.1598372060@sss.pgh.pa.us> (raw)
In-Reply-To: <20200825155544.GG32540@momjian.us>
References: <CAEP4nAzwokLht2Bi3RCHNcCJBdOa8d7LnqJkDO1xiaH+biW8fw@mail.gmail.com>
	<20200825060511.GF2017@paquier.xyz>
	<20200825155544.GG32540@momjian.us>

Bruce Momjian <bruce@momjian.us> writes:
> On Tue, Aug 25, 2020 at 03:05:11PM +0900, Michael Paquier wrote:
>> On Tue, Aug 25, 2020 at 02:14:06PM +1000, Robins Tharakan wrote:
>>> Unlike a recently reported similar issue, executing the following ALTER
>>> TABLE on the regression database crashes Postgres (master).

>> Such reports are constructive!  I can reproduce the crash here down to
>> 9.5.  From what I can see, the problem comes from ATRewriteTable() ->
>> ExecEvalExpr() when we evaluate expressions with inputs coming from
>> the old tuple.  It looks like a memory corruption issue or a context
>> issue at quick glance, and I cannot get a clean backtrace.

I think the nature of the problem (and Robins' other report too) is pretty
clear.  We have a SQL or plpgsql function that's trying to access a table
that is inconsistent during an ALTER TABLE operation.  The function would
be locked out from seeing that transient state if it were in another
session, thanks to normal locking rules; but the lock acquisition rules
don't prevent same-session accesses.

ALTER TABLE and related utility commands contain guards against the
reverse form of this problem: CheckTableNotInUse will bitch if there's
some already-active outer query referencing the table.  But we haven't
thought about the possibility of one of these commands executing
user-defined code midway through.

			regards, tom lane





view thread (10+ messages)  latest in thread

Message-ID: <2745154.1598372060@sss.pgh.pa.us>
Permalink:  ../2745154.1598372060@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/2745154.1598372060@sss.pgh.pa.us

 · 

reply

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 using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, bruce@momjian.us, michael@paquier.xyz, tharakan@gmail.com
  Subject: Re: ALTER TABLE ALTER COLUMN SET TYPE crash
  In-Reply-To: <2745154.1598372060@sss.pgh.pa.us>

* 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