Thread: "could not open relation..."

"could not open relation..."

From
Brian Cox
Date:
I saw this in the postgres log. Anyone know what would cause this?
Thanks, Brian

postgres 8.3.5 on RHEL4 update 6

[3358-cemdb-admin-2010-04-09 04:00:19.029 PDT]ERROR:  could not open
relation with OID 170592
[3358-cemdb-admin-2010-04-09 04:00:19.029 PDT]STATEMENT:  select
lm.ts_login_name,sm.ts_session_id from ts_user_logins_map lm join
ts_user_sessions_map sm on sm.ts_user_id=lm.ts_user_id where not
sm.ts_soft_delete and not lm.ts_soft_delete and lm.ts_user_id != 1 and
lm.ts_app_id in (600000000000000001) order by sm.ts_creation_time

Re: "could not open relation..."

From
Tom Lane
Date:
Brian Cox <brian.cox@ca.com> writes:
> I saw this in the postgres log. Anyone know what would cause this?
> Thanks, Brian

> postgres 8.3.5 on RHEL4 update 6

> [3358-cemdb-admin-2010-04-09 04:00:19.029 PDT]ERROR:  could not open
> relation with OID 170592

Seems a bit off-topic for pgsql-performance, but anyway: the main
known cause for that is if one of the tables used in the query got
dropped (by another session) just after the query started.  Could
that have happened to you?

            regards, tom lane

Re: "could not open relation..."

From
Brian Cox
Date:
On 04/10/2010 12:29 AM, Tom Lane [tgl@sss.pgh.pa.us] wrote:
> Seems a bit off-topic for pgsql-performance,
What would be the appropriate forum?

> but anyway: the main
> known cause for that is if one of the tables used in the query got
> dropped (by another session) just after the query started. Could
> that have happened to you?
interesting and possible; but why doesn't locking prevent this?

Brian

Re: "could not open relation..."

From
Tom Lane
Date:
Brian Cox <brian.cox@ca.com> writes:
> On 04/10/2010 12:29 AM, Tom Lane [tgl@sss.pgh.pa.us] wrote:
>> but anyway: the main
>> known cause for that is if one of the tables used in the query got
>> dropped (by another session) just after the query started. Could
>> that have happened to you?

> interesting and possible; but why doesn't locking prevent this?

Locking prevents you from getting some random internal failure
that would happen if the table disappeared mid-query.  It cannot
eliminate the problem altogether, because the issue here is that
the dropping transaction got there first; there is no reason not
to allow it to proceed.  So the reading transaction is going to fail.
The most we could change is the spelling of the error message,
but I'm not sure that masking the fact that something odd happened
is a good idea.  (From the reader's viewpoint, it did see a table
by that name in the catalogs, but by the time it acquired lock on
the table, the catalog entry was gone.  Playing dumb and just saying
"table does not exist" could be even more confusing than the current
behavior.)

            regards, tom lane