Thread: Concurrent execution of pg_relation_size and DROP TABLE

Concurrent execution of pg_relation_size and DROP TABLE

From
Itagaki Takahiro
Date:
I received a trouble-report that a query using pg_relation_size()
ends with an error, "could not open relation". It came from
DROP TABLE was executed concurrently; relation_open() used in
pg_relation_size() raised an error.

Is it reasonable to replace relation_open() calls to try_relation_open() ?
If failed, pg_relation_size() will just return NULLs.

Regards,
---
ITAGAKI Takahiro
NTT Open Source Software Center



Re: Concurrent execution of pg_relation_size and DROP TABLE

From
Tom Lane
Date:
Itagaki Takahiro <itagaki.takahiro@oss.ntt.co.jp> writes:
> Is it reasonable to replace relation_open() calls to try_relation_open() ?

I don't think so; that's just papering over one form of the problem,
and who's to say that an error is not desirable when a wrong OID is
given?  In general there's always a risk of concurrency problems.
        regards, tom lane