Re: pg_relation_size locking

From: Andreas Pflug <pgadmin(at)pse-consulting(dot)de>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pg_relation_size locking
Date: 2005-12-12 22:59:04
Message-ID: 439E00B8.4060108@pse-consulting.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Tom Lane wrote:
> Andreas Pflug <pgadmin(at)pse-consulting(dot)de> 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 the relation you're
> interested in.

So pgAdmin violates the convention, because it doesn't hold a lock an a
table when reengineering its attributes....
Since pg_relation_size is a pure metadata function, I don't think the
convention hits here (.

>
>>Hm, I see the issue. Interesting enough, I *do* see the size growing.
>>OTOH, when running BEGIN;TRUNCATE against a test table and retrieving
>>pg_relation_size returns the previous relfilenode and size as expected.
>
>
> That's a bit curious. If they just did TRUNCATE then COPY, the commit
> of the TRUNCATE should have released the lock. If the TRUNCATE wasn't
> committed yet, then how are you able to pick up the correct relfilenode
> to look at?

The truncate is buried in a function, I suspect that actually no
truncate happened on an empty table.

Regards,
Andreas

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2005-12-12 23:00:01 Re: buildfarm off the air pro tem
Previous Message Pierre Racine 2005-12-12 22:57:35 GUI Debugger for PostgreSQL on Windows