From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Hiroshi Inoue <Inoue(at)tpf(dot)co(dot)jp> |
Cc: | Martin Weinberg <weinberg(at)osprey(dot)astro(dot)umass(dot)edu>, pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: [GENERAL] Using an SMP machine to make multiple indices on the same |
Date: | 2001-10-25 21:35:10 |
Message-ID: | 20093.1004045710@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-hackers |
Hiroshi Inoue <Inoue(at)tpf(dot)co(dot)jp> writes:
> Tom Lane wrote:
>> Also, I'm now a little worried about whether concurrent index creations
>> will actually work. Both CREATE INDEX operations will try to update
>> the pg_class tuple to set relhasindex true.
> Yes but there's a big difference. It's at the end of the creation
> not at the beginning. Also note that UpdateStats() updates pg_class
> tuple in case of B-trees etc before updating relhasindex. I'm
> suspicios if we should update Stats under the transactional control.
It would probably be good to fix things so that there's only one update
done for both stats and relhasindex, instead of two. But we *will* get
failures in simple_heap_update if we continue to use that routine.
The window for failure may be relatively short but it's real. It's not
necessarily short, either; consider multiple CREATE INDEX commands
executed in a transaction block.
>> I still don't see any value in LockClassinfoForUpdate, however.
> ISTM to rely on completely the lock for the corresponding
> relation is a little misplaced.
Surely we *must* be able to rely on the relation lock. For example:
how does SELECT FOR UPDATE of the relation's pg_class tuple prevent
writers from adding tuples to the relation? It does not and cannot.
Only getting the appropriate relation lock provides a semantically
correct guarantee that the relation isn't changing underneath us.
Locking the pg_class tuple only locks the tuple itself, it has no wider
scope of meaning.
> For example ALTER TABLE OWNER
> doesn't acquire any lock on the table but it seems natural to me.
Seems like a bug to me. Consider this scenario:
Backend 1 Backend 2
begin;
lock table1;
select from table1; -- works
alter table1 set owner ...
select from table1; -- fails, no permissions
That should not happen. It wouldn't happen if ALTER TABLE OWNER
were acquiring an appropriate lock on the relation.
> UPDATE pg_class set .. doesn't acquire any lock on the correspoding
> relations of the target pg_class tuples but it seems natural to me,
While we allow knowledgeable users to poke at the system catalogs
directly, I feel that that is very much a "let the user beware"
facility. I have no urge to try to guarantee cross-backend
transactional safety for changes executed that way. But CREATE INDEX,
ALTER TABLE, and so forth should have safe concurrent behavior.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Roderick A. Anderson | 2001-10-25 21:49:15 | Re: DBD::Pg |
Previous Message | Fran Fabrizio | 2001-10-25 21:23:00 | Re: DBD::Pg |
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2001-10-25 21:40:08 | Re: LOCK SEQUENCE |
Previous Message | David Ford | 2001-10-25 21:08:25 | [patch] helps fe-connect.c handle -EINTR more gracefully |