Re: Apparent race in information_schema.tables

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Florian Weimer <fweimer(at)bfk(dot)de>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Apparent race in information_schema.tables
Date: 2009-05-11 17:00:01
Message-ID: 3742.1242061201@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Florian Weimer <fweimer(at)bfk(dot)de> writes:
> This query:
> SELECT 1 FROM information_schema.tables WHERE table_schema = $1 AND table_name = $2;

> fails sporadically with the error "relation with OID <number> does not
> exist".

> I guess the OID refers to a temporary table because I can't find it in
> pg_class, and the cause is a race between listing the tables and
> applying the permission checks to them (which I don't need anyway, I
> think) because tables in the system catalog are not subject to MVCC.

Yeah, that's what I guess too. There is a change in 8.4 that should
prevent this class of failures:

2008-12-15 13:09 tgl

* src/: backend/catalog/namespace.c, backend/utils/adt/acl.c,
test/regress/expected/privileges.out: Arrange for the
pg_foo_is_visible and has_foo_privilege families of functions to
return NULL, instead of erroring out, if the target object is
specified by OID and we can't find that OID in the catalogs. Since
these functions operate internally on SnapshotNow rules, there is a
race condition when using them in user queries: the query's MVCC
snapshot might "see" a catalog row that's already committed dead,
leading to a failure when the inquiry function is applied.
Returning NULL should generally provide more convenient behavior.
This issue has been complained of before, and in particular we are
now seeing it in the regression tests due to another recent patch.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message sramirez 2009-05-11 17:50:58 warm-standby errors
Previous Message Florian Weimer 2009-05-11 16:29:43 Apparent race in information_schema.tables