Re: ResetSystemCaches(was Re: [HACKERS] relation ### modified while in use)

2000-11-06 Thread Hiroshi Inoue
Tom Lane wrote: > Hiroshi Inoue <[EMAIL PROTECTED]> writes: > > RelationCacheInvalidate() is called from ResetSystemCaches() > > and calles RelationFlushRelation() for all relation descriptors > > except some nailed system relations. > > I'm wondering why nailed relations could be exceptions. > >

Re: ResetSystemCaches(was Re: [HACKERS] relation ### modified while in use)

2000-11-06 Thread Tom Lane
Hiroshi Inoue <[EMAIL PROTECTED]> writes: > RelationCacheInvalidate() is called from ResetSystemCaches() > and calles RelationFlushRelation() for all relation descriptors > except some nailed system relations. > I'm wondering why nailed relations could be exceptions. > Conversely why must Relation

ResetSystemCaches(was Re: [HACKERS] relation ### modified while in use)

2000-11-05 Thread Hiroshi Inoue
Hi RelationCacheInvalidate() is called from ResetSystemCaches() and calles RelationFlushRelation() for all relation descriptors except some nailed system relations. I'm wondering why nailed relations could be exceptions. Conversely why must RelationCacheInvalidate() call RelationFlushRelation() fo

AW: [HACKERS] relation ### modified while in use

2000-11-03 Thread Zeugswetter Andreas SB
> > The problem at hand is that > > a plan may be invalidated before it is even finished building. Do you > > expect the parse-rewrite-plan-execute pipeline to be prepared to back up > > and restart if we notice a relation schema change report halfway down the > > process? Yes, during the proce

RE: [HACKERS] relation ### modified while in use

2000-11-03 Thread Hiroshi Inoue
> -Original Message- > From: Tom Lane [mailto:[EMAIL PROTECTED]] > > "Hiroshi Inoue" <[EMAIL PROTECTED]> writes: > > Doesn't current heap_open() have a flaw that even the first > > use of a relation in a transaction may cause an error > > "relation ### modified while in use" ? > > Sure,

RE: [HACKERS] relation ### modified while in use

2000-11-03 Thread Hiroshi Inoue
> -Original Message- > From: Tom Lane [mailto:[EMAIL PROTECTED]] > > > BTW,I sometimes see > > ERROR: SearchSysCache: recursive use of cache 10(16) > > under small MAXNUMMESSAGES environment. > > I'm not sure about the cause but suspicious if sufficiently > > many system relations are

RE: [HACKERS] relation ### modified while in use

2000-11-02 Thread Alex Pilosov
On Fri, 3 Nov 2000, Hiroshi Inoue wrote: > PL/pgSQL already prepares a plan at the first execution > time and executes the plan repeatedly after that. > We would have general PREPARE/EXECUTE feature in the > near fututre. IMHO another mechanism to detect plan invali > dation is needed. Excellent

Re: [HACKERS] relation ### modified while in use

2000-11-02 Thread Tom Lane
"Hiroshi Inoue" <[EMAIL PROTECTED]> writes: > Doesn't current heap_open() have a flaw that even the first > use of a relation in a transaction may cause an error > "relation ### modified while in use" ? Sure, that was the starting point of the discussion. >> because that will open us up to fail

RE: [HACKERS] relation ### modified while in use

2000-11-02 Thread Hiroshi Inoue
> -Original Message- > From: Tom Lane [mailto:[EMAIL PROTECTED]] > > Hiroshi Inoue <[EMAIL PROTECTED]> writes: > > Do we have a conclusion about this thread ? > > If no,how about changing heap_open(r) so that they allocate > > Relation descriptors after acquiring a lock on the table ? > >

Re: [HACKERS] relation ### modified while in use

2000-11-02 Thread Tom Lane
Hiroshi Inoue <[EMAIL PROTECTED]> writes: > Do we have a conclusion about this thread ? > If no,how about changing heap_open(r) so that they allocate > Relation descriptors after acquiring a lock on the table ? > We would use LockRelation() no longer. That won't do by itself, because that will op

Re: [HACKERS] relation ### modified while in use

2000-10-30 Thread Hiroshi Inoue
Tom Lane wrote: > Alex Pilosov <[EMAIL PROTECTED]> writes: > > I think this happens after I create/modify tables which reference this > > table. This is spontaneous, and doesn't _always_ happen... > > Um. I was hoping it was something more easily fixable :-(. What's > causing the relcache to dec

Re: AW: AW: BLERe: AW: AW: [HACKERS] relation ### modified while in use

2000-10-25 Thread Philip Warner
At 09:36 25/10/00 +0200, Zeugswetter Andreas SB wrote: > >> I have not followed the entire thread, but if you are in a serializable OR >> repeatable-read transaction, > >Serializable and repeatable read are the same thing, different wording. Not last time I looked. RR ensures that rows you have s

AW: AW: BLERe: AW: AW: [HACKERS] relation ### modified while in use

2000-10-25 Thread Zeugswetter Andreas SB
> I have not followed the entire thread, but if you are in a serializable OR > repeatable-read transaction, Serializable and repeatable read are the same thing, different wording. > I would think that read-only statements will > need to keep some kind of lock on the rows they read (or the tabl

Re: AW: BLERe: AW: AW: [HACKERS] relation ### modified while in use

2000-10-24 Thread Philip Warner
At 18:31 24/10/00 +0900, Hiroshi Inoue wrote: > > >Zeugswetter Andreas SB wrote: > >> > > > Are there many applications which have many SELECT statements(without >> > > > FOR UPDATE) in one tx ? >> > > >> > > Why not ? >> > > >> > It seems to me that multiple SELECT statements in a tx has little >

Re: [HACKERS] relation ### modified while in use

2000-10-24 Thread Hiroshi Inoue
Vadim Mikheev wrote: > > > > In my understanding,locking levels you provided contains > > > > an implicit share/exclusive lock on the corrsponding > > > > pg_class tuple i.e. AccessExclusive Lock acquires an > > > > exclusive lock on the corresping pg_class tuple and > > > > other locks acquire

AW: AW: BLERe: AW: AW: [HACKERS] relation ### modified while in use

2000-10-24 Thread Zeugswetter Andreas SB
> > > > > Are there many applications which have many SELECT statements(without > > > > > FOR UPDATE) in one tx ? > > > > > > > > Why not ? > > > > > > > It seems to me that multiple SELECT statements in a tx has little > > > meaning unless the tx is executed in SERIALIZABLE isolation level. > > >

Re: [HACKERS] relation ### modified while in use

2000-10-24 Thread Vadim Mikheev
> > > In my understanding,locking levels you provided contains > > > an implicit share/exclusive lock on the corrsponding > > > pg_class tuple i.e. AccessExclusive Lock acquires an > > > exclusive lock on the corresping pg_class tuple and > > > other locks acquire a share lock, Is it right ? > > >

Re: AW: AW: BLERe: AW: AW: [HACKERS] relation ### modified while in use

2000-10-24 Thread Hiroshi Inoue
Zeugswetter Andreas SB wrote: [snip] > > Also the result would be, that the first readonly statements are allowed to > see schema changes, but selects after the first DML would not :-( > Does it mean that even read-only statements aren't allowed to release locks after other DMLs ? Regards. Hi

AW: AW: [HACKERS] relation ### modified while in use

2000-10-24 Thread Zeugswetter Andreas SB
> More of that - while one xaction will wait to alter a table no new xaction > will be allowed to access this table too. Yes, I forgot, that placing an exclusive lock will make later shared lock requests wait. Andreas

AW: AW: AW: BLERe: AW: AW: [HACKERS] relation ### modified while in use

2000-10-24 Thread Zeugswetter Andreas SB
> > Also the result would be, that the first readonly statements are allowed to > > see schema changes, but selects after the first DML would not :-( > > Does it mean that even read-only statements aren't allowed > to release locks after other DMLs ? That is, what Tom is suggesting, but not afte

Re: AW: BLERe: AW: AW: [HACKERS] relation ### modified while in use

2000-10-24 Thread Hiroshi Inoue
Zeugswetter Andreas SB wrote: > > > > Are there many applications which have many SELECT statements(without > > > > FOR UPDATE) in one tx ? > > > > > > Why not ? > > > > > It seems to me that multiple SELECT statements in a tx has little > > meaning unless the tx is executed in SERIALIZABLE isol

AW: BLERe: AW: AW: [HACKERS] relation ### modified while in use

2000-10-24 Thread Zeugswetter Andreas SB
> > > Are there many applications which have many SELECT statements(without > > > FOR UPDATE) in one tx ? > > > > Why not ? > > > It seems to me that multiple SELECT statements in a tx has little > meaning unless the tx is executed in SERIALIZABLE isolation level. E.g. a table is accessed multipl

AW: AW: AW: AW: AW: [HACKERS] relation ### modified while in use

2000-10-24 Thread Zeugswetter Andreas SB
> Zeugswetter Andreas SB <[EMAIL PROTECTED]> writes: > > Yes, and holding a row exclusive lock must imho at least > grab a shared > > table lock > > As indeed it does. Our disagreement seems to be just on the point of > whether it's safe to allow a read-only transaction to release its > Acces

Re: [HACKERS] relation ### modified while in use

2000-10-23 Thread Hiroshi Inoue
"Mikheev, Vadim" wrote: > > > > I've wondered why AccessShareLock is a short term lock. > > > > > > MUST BE. AccessShare-/Exclusive-Locks are *data* locks. > > > If one want to protect schema then new schema share/excl locks > > > must be inroduced. There is no conflict between data and > > > sc

RE: [HACKERS] relation ### modified while in use

2000-10-23 Thread Mikheev, Vadim
> > > I've wondered why AccessShareLock is a short term lock. > > > > MUST BE. AccessShare-/Exclusive-Locks are *data* locks. > > If one want to protect schema then new schema share/excl locks > > must be inroduced. There is no conflict between data and > > schema locks - they are orthogonal. > > >

Re: [HACKERS] relation ### modified while in use

2000-10-23 Thread Hiroshi Inoue
Vadim Mikheev wrote: > > > in general. What I'm proposing is that once an xact has touched a > > > table, other xacts should not be able to apply schema updates to that > > > table until the first xact commits. > > > > > > > I agree with you. > > I don't know. We discussed this issue just after

BLERe: AW: AW: [HACKERS] relation ### modified while in use

2000-10-23 Thread Hiroshi Inoue
Zeugswetter Andreas SB wrote: > > > > What I'm proposing is that once an xact has touched a > > > > table, other xacts should not be able to apply schema updates to that > > > > table until the first xact commits. > > > > > > No, this would mean too many locks, and would leave the dba with hardl

Re: [HACKERS] relation ### modified while in use

2000-10-23 Thread Hiroshi Inoue
Philip Warner wrote: > At 15:29 23/10/00 +0900, Hiroshi Inoue wrote: > > > >If we have a mechanism to acquire a share lock on a tuple,we > >could use it for managing system info generally. However the > >only allowed lock on a tuple is exclusive. Access(Share/Exclusive) > >Lock on tables would

Re: [HACKERS] relation ### modified while in use

2000-10-23 Thread Tom Lane
Hiroshi Inoue <[EMAIL PROTECTED]> writes: > I'm not sure about the use of AccessShareLock in parse-analyze- > optimize phase however. That's something we'll have to clean up while fixing this. Currently the system may acquire and release AccessShareLock multiple times while parsing/rewriting/pla

Re: AW: AW: [HACKERS] relation ### modified while in use

2000-10-23 Thread Philip Warner
At 10:10 23/10/00 -0400, Tom Lane wrote: > >I consider that behavior *far* safer than allowing schema changes to >be seen mid-transaction. Consider the following example: > > Session 1 Session 2 > > begin; > > INSERT INTO foo ...; > >

Re: AW: [HACKERS] relation ### modified while in use

2000-10-23 Thread Vadim Mikheev
> > As for locks,weak locks doesn't pass intensive locks. Dba > > seems to be able to alter a table at any time. > > Sorry, I don't understand this sentence. Tom suggested placing a shared lock on > any table that is accessed until end of tx. Noone can alter table until all users have > closed the

Re: AW: AW: [HACKERS] relation ### modified while in use

2000-10-23 Thread Tom Lane
Philip Warner <[EMAIL PROTECTED]> writes: > In this case, wouldn't the answer depend on the isolation level of session > 1? For serializable TX, then constraint would not apply; 'read committed' > would mean the constraint was visible on the second insert and at the commit. The important issue he

Re: [HACKERS] relation ### modified while in use

2000-10-23 Thread Tom Lane
Philip Warner <[EMAIL PROTECTED]> writes: > Only slightly; one interpretation of a table lock is that it locks all of > the data in the table; and a lock on the pg_class row locks the metadata. I > must admit that I am having a little difficulty thinking of a case where > the distinction would be

Re: AW: AW: AW: AW: [HACKERS] relation ### modified while in use

2000-10-23 Thread Tom Lane
Zeugswetter Andreas SB <[EMAIL PROTECTED]> writes: > Yes, and holding a row exclusive lock must imho at least grab a shared > table lock As indeed it does. Our disagreement seems to be just on the point of whether it's safe to allow a read-only transaction to release its AccessShareLock locks p

Re: [HACKERS] relation ### modified while in use

2000-10-23 Thread Vadim Mikheev
> > in general. What I'm proposing is that once an xact has touched a > > table, other xacts should not be able to apply schema updates to that > > table until the first xact commits. > > > > I agree with you. I don't know. We discussed this issue just after 6.5 and decided to allow concurrent s

AW: AW: AW: AW: [HACKERS] relation ### modified while in use

2000-10-23 Thread Zeugswetter Andreas SB
> > You were talking about the "select only" case (and no for update eighter). > > I think that select statements need a shared lock for the duration of their > > execution only. > > You seem to think that locks on individual tuples conflict with > table-wide locks. Yes, very much so. Any oth

Re: [HACKERS] relation ### modified while in use

2000-10-23 Thread Philip Warner
At 10:45 23/10/00 -0400, Tom Lane wrote: >Philip Warner <[EMAIL PROTECTED]> writes: >> Don't we have this ability? What about taking a RowShare lock on the >> pg_class tuple whenever you read from the table; then requiring schema >> updates take a RowExclusive lock on the pg_class tuple? > >How is

Re: [HACKERS] relation ### modified while in use

2000-10-23 Thread Tom Lane
Philip Warner <[EMAIL PROTECTED]> writes: > Don't we have this ability? What about taking a RowShare lock on the > pg_class tuple whenever you read from the table; then requiring schema > updates take a RowExclusive lock on the pg_class tuple? How is that different from taking locks on the table

Re: AW: AW: AW: [HACKERS] relation ### modified while in use

2000-10-23 Thread Tom Lane
Zeugswetter Andreas SB <[EMAIL PROTECTED]> writes: > No, the above is not a valid example, because Session 2 won't > get the exclusive lock until Session 1 commits, since Session 1 already > holds a lock on foo (for the inserted row). > You were talking about the "select only" case (and no for

Re: AW: AW: [HACKERS] relation ### modified while in use

2000-10-23 Thread Tom Lane
Zeugswetter Andreas SB <[EMAIL PROTECTED]> writes: >> As for locks,weak locks doesn't pass intensive locks. Dba >> seems to be able to alter a table at any time. > Sorry, I don't understand this sentence. Tom suggested placing a > shared lock on any table that is accessed until end of tx. Noone

Re: [HACKERS] relation ### modified while in use

2000-10-23 Thread Philip Warner
At 15:29 23/10/00 +0900, Hiroshi Inoue wrote: > >If we have a mechanism to acquire a share lock on a tuple,we >could use it for managing system info generally. However the >only allowed lock on a tuple is exclusive. Access(Share/Exclusive) >Lock on tables would give us a restricted solution about

AW: AW: AW: [HACKERS] relation ### modified while in use

2000-10-23 Thread Zeugswetter Andreas SB
> Until existing xacts using that table have closed, yes. But I believe > the lock manager has some precedence rules that will allow the pending > request for AccessExclusiveLock to take precedence over new requests > for lesser locks. So you're only held off for a long time if you have > long-

Re: AW: [HACKERS] relation ### modified while in use

2000-10-23 Thread Hiroshi Inoue
Zeugswetter Andreas SB wrote: > > What I'm proposing is that once an xact has touched a > > table, other xacts should not be able to apply schema updates to that > > table until the first xact commits. > > No, this would mean too many locks, and would leave the dba with hardly a > chance to alte

AW: AW: [HACKERS] relation ### modified while in use

2000-10-23 Thread Zeugswetter Andreas SB
> > > What I'm proposing is that once an xact has touched a > > > table, other xacts should not be able to apply schema updates to that > > > table until the first xact commits. > > > > No, this would mean too many locks, and would leave the dba with hardly a > > chance to alter a table. > > > >

AW: [HACKERS] relation ### modified while in use

2000-10-23 Thread Zeugswetter Andreas SB
> What I'm proposing is that once an xact has touched a > table, other xacts should not be able to apply schema updates to that > table until the first xact commits. No, this would mean too many locks, and would leave the dba with hardly a chance to alter a table. If I recall correctly the ANS

Re: [HACKERS] relation ### modified while in use

2000-10-22 Thread Hiroshi Inoue
Tom Lane wrote: > Philip Warner <[EMAIL PROTECTED]> writes: > > At 01:01 23/10/00 -0400, Tom Lane wrote: > >> (It's barely possible that we could get away with allowing > >> triggers to be added or deleted mid-transaction, but that doesn't feel > >> right to me.) > > > A little OT, but the above

Re: [HACKERS] relation ### modified while in use

2000-10-22 Thread Philip Warner
At 01:37 23/10/00 -0400, Tom Lane wrote: > >What I'm proposing is that once an xact has touched a >table, other xacts should not be able to apply schema updates to that >table until the first xact commits. Totally agree. You may want to go further and say that metadata changes can not be made whi

Re: [HACKERS] relation ### modified while in use

2000-10-22 Thread Tom Lane
Philip Warner <[EMAIL PROTECTED]> writes: > At 01:01 23/10/00 -0400, Tom Lane wrote: >> (It's barely possible that we could get away with allowing >> triggers to be added or deleted mid-transaction, but that doesn't feel >> right to me.) > A little OT, but the above is a useful feature for managi

Re: [HACKERS] relation ### modified while in use

2000-10-22 Thread Philip Warner
At 01:01 23/10/00 -0400, Tom Lane wrote: >(It's barely possible that we could get away with allowing >triggers to be added or deleted mid-transaction, but that doesn't feel >right to me.) > A little OT, but the above is a useful feature for managing data; it's not common, but the following sequen

Re: [HACKERS] relation ### modified while in use

2000-10-22 Thread Tom Lane
Alex Pilosov <[EMAIL PROTECTED]> writes: > On Mon, 23 Oct 2000, Tom Lane wrote: >> begin; >> select * from foo; -- gets AccessShareLock >> LOCK TABLE foo; -- gets AccessExclusiveLock >> ... >> end; >> >> this will work currently because the SELECT releases AccessShareLock >> when done,

Re: [HACKERS] relation ### modified while in use

2000-10-22 Thread Alex Pilosov
On Mon, 23 Oct 2000, Tom Lane wrote: > begin; > select * from foo; -- gets AccessShareLock > LOCK TABLE foo; -- gets AccessExclusiveLock > ... > end; > > this will work currently because the SELECT releases AccessShareLock > when done, but it will deadlock if S

Re: [HACKERS] relation ### modified while in use

2000-10-22 Thread Alex Pilosov
On Mon, 23 Oct 2000, Alex Pilosov wrote: > On Mon, 23 Oct 2000, Tom Lane wrote: > > > when done, but it will deadlock if SELECT does not release that lock. > > > > That's annoying but I see no way around it, if we are to allow > > concurrent transactions to do schema modifications of tables tha

Re: [HACKERS] relation ### modified while in use

2000-10-22 Thread Tom Lane
Alex Pilosov <[EMAIL PROTECTED]> writes: > I might be in above my head, but maybe this is time for yet another type > of lock? Wouldn't help --- it's still a deadlock. regards, tom lane

Re: [HACKERS] relation ### modified while in use

2000-10-22 Thread Alex Pilosov
On Mon, 23 Oct 2000, Tom Lane wrote: > when done, but it will deadlock if SELECT does not release that lock. > > That's annoying but I see no way around it, if we are to allow > concurrent transactions to do schema modifications of tables that other > transactions are using. I might be in above

Re: [HACKERS] relation ### modified while in use

2000-10-22 Thread Tom Lane
Alex Pilosov <[EMAIL PROTECTED]> writes: > I think this happens after I create/modify tables which reference this > table. This is spontaneous, and doesn't _always_ happen... Um. I was hoping it was something more easily fixable :-(. What's causing the relcache to decide that the rel has been m

Re: [HACKERS] relation ### modified while in use

2000-10-22 Thread Alex Pilosov
I think this happens after I create/modify tables which reference this table. This is spontaneous, and doesn't _always_ happen... Anything I could do next time it craps up to help track the problem down? -alex CREATE TABLE "customers" ( "cust_id" int4 DEFAULT nextval('customers_cus

Re: [HACKERS] relation ### modified while in use

2000-10-22 Thread Tom Lane
Alex Pilosov <[EMAIL PROTECTED]> writes: > I'm having the error 'relation modified while in use' fairly > often. It is the same relation that's always giving a problem. Hmm, could we see the full schema dump for that relation? (pg_dump -s -t tablename dbname will do) If you are not actively mod

[HACKERS] relation ### modified while in use

2000-10-22 Thread Alex Pilosov
I'm having the error 'relation modified while in use' fairly often. It is the same relation that's always giving a problem. Usually after all currently-running backends die away with that error, error disappears. If I shutdown, ipcclean, start up postgres, it also disappears. What causes this?