Re: [HACKERS] pg_relation_size locking

2005-12-12 Thread Andreas Pflug
Alvaro Herrera wrote: Andreas Pflug wrote: Alvaro Herrera wrote: The problem with the original coding was that it used the table Oid to look up the file name, which is wrong. (Test it with a table that has been clustered or an index that has been reindexed.) Um, can't test at the moment. T

Re: [HACKERS] pg_relation_size locking

2005-12-12 Thread Alvaro Herrera
Andreas Pflug wrote: > Alvaro Herrera wrote: > > > >The problem with the original coding was that it used the table Oid to > >look up the file name, which is wrong. (Test it with a table that has > >been clustered or an index that has been reindexed.) > > Um, can't test at the moment. The oldcode

Re: [HACKERS] pg_relation_size locking

2005-12-12 Thread Andreas Pflug
Tom Lane wrote: Andreas Pflug <[EMAIL PROTECTED]> writes: Tom Lane wrote: You have to have a lock to ensure that the table even exists, let alone that you are looking at the right set of disk files. This would require a lock on pg_class, not table foo, no? No, the convention is that yo

Re: [HACKERS] pg_relation_size locking

2005-12-12 Thread Alvaro Herrera
[Resend: apparently there's a problem with my mail server] Andreas Pflug wrote: > Until recently, pg_relation_size used SearchSysCache to locate the > relation to examine, and calculated the file location from that > information. Starting with dbsize.c V1.5 (committed after Beta2), > relation_o

Re: [HACKERS] pg_relation_size locking

2005-12-12 Thread Tom Lane
Andreas Pflug <[EMAIL PROTECTED]> writes: > Tom Lane wrote: >> You have to have a lock to ensure that the table even exists, let alone >> that you are looking at the right set of disk files. > This would require a lock on pg_class, not table foo, no? No, the convention is that you take a lock on

Re: [HACKERS] pg_relation_size locking

2005-12-12 Thread Alvaro Herrera
Andreas Pflug wrote: > Until recently, pg_relation_size used SearchSysCache to locate the > relation to examine, and calculated the file location from that > information. Starting with dbsize.c V1.5 (committed after Beta2), > relation_open(.., AccessShareLock) is used. This is very unfortunate

Re: [HACKERS] pg_relation_size locking

2005-12-12 Thread Andreas Pflug
Tom Lane wrote: Andreas Pflug <[EMAIL PROTECTED]> writes: Tom Lane wrote: That's only possible if Slony is taking AccessExclusive lock; if so, your gripe is properly directed to the Slony folks, not to pg_relation_size which is acting as a good database citizen should. More precisely, it e

Re: [HACKERS] pg_relation_size locking

2005-12-12 Thread Andreas Pflug
Alvaro Herrera wrote: The problem with the original coding was that it used the table Oid to look up the file name, which is wrong. (Test it with a table that has been clustered or an index that has been reindexed.) Um, can't test at the moment. The oldcode used pg_class->relfilnode, which d

Re: [HACKERS] pg_relation_size locking

2005-12-12 Thread Alvaro Herrera
Tom Lane wrote: > In the above example, the contrib code would have not done the right > thing at all --- if I'm not mistaken, it would have kept handing back > the size of the original, pre-TRUNCATE file, since the new pg_class > row with the new relfilenode isn't committed yet. So it wouldn't h

Re: [HACKERS] pg_relation_size locking

2005-12-12 Thread Tom Lane
Andreas Pflug <[EMAIL PROTECTED]> writes: > Tom Lane wrote: >> That's only possible if Slony is taking AccessExclusive lock; if so, >> your gripe is properly directed to the Slony folks, not to >> pg_relation_size which is acting as a good database citizen should. > More precisely, it executes TRU

Re: [HACKERS] pg_relation_size locking

2005-12-12 Thread Andreas Pflug
Tom Lane wrote: Andreas Pflug <[EMAIL PROTECTED]> writes: Tom Lane wrote: Nonsense. Ahem. I'm running Slony against a big replication set. While slon runs COPY foo(colnamelist) FROM STDIN, I can't execute pg_relation_size(foo_oid). pg_locks will show that the AccessShareLock on foo i

Re: [HACKERS] pg_relation_size locking

2005-12-12 Thread Tom Lane
Andreas Pflug <[EMAIL PROTECTED]> writes: > Tom Lane wrote: >> Nonsense. > Ahem. > I'm running Slony against a big replication set. While slon runs COPY > foo(colnamelist) FROM STDIN, I can't execute pg_relation_size(foo_oid). > pg_locks will show that the AccessShareLock on foo is not granted.

Re: [HACKERS] pg_relation_size locking

2005-12-12 Thread Andreas Pflug
Tom Lane wrote: Andreas Pflug <[EMAIL PROTECTED]> writes: Until recently, pg_relation_size used SearchSysCache to locate the relation to examine, and calculated the file location from that information. Starting with dbsize.c V1.5 (committed after Beta2), relation_open(.., AccessShareLock) is

Re: [HACKERS] pg_relation_size locking

2005-12-12 Thread Tom Lane
Andreas Pflug <[EMAIL PROTECTED]> writes: > Until recently, pg_relation_size used SearchSysCache to locate the > relation to examine, and calculated the file location from that > information. Starting with dbsize.c V1.5 (committed after Beta2), > relation_open(.., AccessShareLock) is used. This