Re: Catalog Access (was: [GENERAL] Concurrency problem building indexes) - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Catalog Access (was: [GENERAL] Concurrency problem building indexes)
Date
Msg-id 22715.1145987907@sss.pgh.pa.us
Whole thread Raw
In response to Re: Catalog Access (was: [GENERAL] Concurrency problem building indexes)  (Martijn van Oosterhout <kleptog@svana.org>)
Responses Re: Catalog Access (was: [GENERAL] Concurrency problem  (Hannu Krosing <hannu@skype.net>)
List pgsql-hackers
Martijn van Oosterhout <kleptog@svana.org> writes:
> I think the basic problem is that DDL can't really work within a
> transaction. If I do an ALTER TABLE, some of these changes need to show
> up to concurrent transactions (maybe creating a unique index?).

The point is that DDL can't be MVCC.  If for instance you add an index
to a table, once you commit every other transaction must *immediately*
start updating that index when they modify the table.  They can't use
the excuse of "not my problem because the catalog change postdates the
snapshot I'm using".  The drop-index case is even worse, since a
transaction that believes the index is still present is likely to try
to access/update a disk file that's not there anymore.  Adding/dropping
columns, constraints, triggers, etc all have hazards of the same ilk.

> I think it's like Tom says in that email, it could be done, but the
> cost/benefit ratio isn't very good...

It's barely possible that we could make this happen, but it would be a
huge amount of work, and probably a huge amount of instability for a
very long time until we'd gotten all the corner cases sorted.  I think
there are much more productive uses for our development effort.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: Avoiding redundant fetches of btree index metapages
Next
From: "Dave Page"
Date:
Subject: Re: Installation on Duel-Core Pentium XP