pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feed8.3.5: Types with typnamespace pointing at non-existent pg_namespace oid
6+ messages / 3 participants
[nested] [flat]
* 8.3.5: Types with typnamespace pointing at non-existent pg_namespace oid
@ 2011-02-22 06:43 Daniel Farina <daniel@heroku.com>
2011-02-22 06:46 ` Re: 8.3.5: Types with typnamespace pointing at non-existent pg_namespace oid Daniel Farina <daniel@heroku.com>
0 siblings, 1 reply; 6+ messages in thread
From: Daniel Farina @ 2011-02-22 06:43 UTC (permalink / raw)
To: pgsql-bugs
A medium-length story short, this query returns non-zero:
select count(distinct typnamespace) from pg_type where not exists
(select 1 from pg_namespace where oid = pg_type.typnamespace);
I did a very brief search in all the release notes for 8.3.5 to
8.3.14, but have not found precisely what I was looking for (searches
for namespace, schema, type, and corruption).
This was discovered when performing a pg_dump of this user's database,
whereby pg_dump complained when trying to dump types for lack of a
good catalog entry to nab the namespace name from. In our case, two
namespaces seem to be affected. The user of this database was never
privileged enough to even perform CREATE SCHEMA, to my knowledge, and
in fact only have the schema (owned by the postgres superuser) that
they began with.
Is it safe to perform an UPDATE on pg_type to give entries a valid
typnamespace? Is there any forensic evidence I can grab before doing
that to assist in figuring out the mechanism for this bug, if
applicable?
Cheers.
--
fdr
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: 8.3.5: Types with typnamespace pointing at non-existent pg_namespace oid
2011-02-22 06:43 8.3.5: Types with typnamespace pointing at non-existent pg_namespace oid Daniel Farina <daniel@heroku.com>
@ 2011-02-22 06:46 ` Daniel Farina <daniel@heroku.com>
2011-02-22 08:48 ` Re: 8.3.5: Types with typnamespace pointing at non-existent pg_namespace oid Daniel Farina <daniel@heroku.com>
0 siblings, 1 reply; 6+ messages in thread
From: Daniel Farina @ 2011-02-22 06:46 UTC (permalink / raw)
To: pgsql-bugs
On Mon, Feb 21, 2011 at 10:43 PM, Daniel Farina <daniel@heroku.com> wrote:
> A medium-length story short, this query returns non-zero:
>
> select count(distinct typnamespace) from pg_type where not exists
> (select 1 from pg_namespace where oid = pg_type.typnamespace);
>
> I did a very brief search in all the release notes for 8.3.5 to
> 8.3.14, but have not found precisely what I was looking for (searches
> for namespace, schema, type, and corruption).
It may also be useful information to know that no recent shenanigans
have happened on this server: it's been up continuously for about 500
days. That doesn't mean something interesting did not occur a very
long time ago, and I'm currently asking around for any notes about
interesting things that have occurred on this machine.
--
fdr
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: 8.3.5: Types with typnamespace pointing at non-existent pg_namespace oid
2011-02-22 06:43 8.3.5: Types with typnamespace pointing at non-existent pg_namespace oid Daniel Farina <daniel@heroku.com>
2011-02-22 06:46 ` Re: 8.3.5: Types with typnamespace pointing at non-existent pg_namespace oid Daniel Farina <daniel@heroku.com>
@ 2011-02-22 08:48 ` Daniel Farina <daniel@heroku.com>
2011-02-22 11:30 ` Re: 8.3.5: Types with typnamespace pointing at non-existent pg_namespace oid Greg Stark <gsstark@mit.edu>
2011-02-22 16:54 ` Re: Re: 8.3.5: Types with typnamespace pointing at non-existent pg_namespace oid Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 2 replies; 6+ messages in thread
From: Daniel Farina @ 2011-02-22 08:48 UTC (permalink / raw)
To: pgsql-bugs
On Mon, Feb 21, 2011 at 10:46 PM, Daniel Farina <daniel@heroku.com> wrote:
> It may also be useful information to know that no recent shenanigans
> have happened on this server: it's been up continuously for about 500
> days. That doesn't mean something interesting did not occur a very
> long time ago, and I'm currently asking around for any notes about
> interesting things that have occurred on this machine.
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: 8.3.5: Types with typnamespace pointing at non-existent pg_namespace oid
2011-02-22 06:43 8.3.5: Types with typnamespace pointing at non-existent pg_namespace oid Daniel Farina <daniel@heroku.com>
2011-02-22 06:46 ` Re: 8.3.5: Types with typnamespace pointing at non-existent pg_namespace oid Daniel Farina <daniel@heroku.com>
2011-02-22 08:48 ` Re: 8.3.5: Types with typnamespace pointing at non-existent pg_namespace oid Daniel Farina <daniel@heroku.com>
@ 2011-02-22 11:30 ` Greg Stark <gsstark@mit.edu>
1 sibling, 0 replies; 6+ messages in thread
From: Greg Stark @ 2011-02-22 11:30 UTC (permalink / raw)
To: Daniel Farina <daniel@heroku.com>; +Cc: pgsql-bugs
On Tue, Feb 22, 2011 at 8:48 AM, Daniel Farina <daniel@heroku.com> wrote:
> The modern namespace OID is
> 378382, which is in line with a smooth monotonic increase over time.
Wait, what? namespace OID is the OID of the schema. The OID of an
object doesn't change over the lifetime of the object, it's a unique
identifier. So the only reason this would be increasing like this
would be if you're creating schemas continually over time. What
actually is going on in this database?
--
greg
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Re: 8.3.5: Types with typnamespace pointing at non-existent pg_namespace oid
2011-02-22 06:43 8.3.5: Types with typnamespace pointing at non-existent pg_namespace oid Daniel Farina <daniel@heroku.com>
2011-02-22 06:46 ` Re: 8.3.5: Types with typnamespace pointing at non-existent pg_namespace oid Daniel Farina <daniel@heroku.com>
2011-02-22 08:48 ` Re: 8.3.5: Types with typnamespace pointing at non-existent pg_namespace oid Daniel Farina <daniel@heroku.com>
@ 2011-02-22 16:54 ` Tom Lane <tgl@sss.pgh.pa.us>
2011-02-22 18:32 ` Re: Re: 8.3.5: Types with typnamespace pointing at non-existent pg_namespace oid Daniel Farina <daniel@heroku.com>
1 sibling, 1 reply; 6+ messages in thread
From: Tom Lane @ 2011-02-22 16:54 UTC (permalink / raw)
To: Daniel Farina <daniel@heroku.com>; +Cc: pgsql-bugs
Daniel Farina <daniel@heroku.com> writes:
> From what I can tell, people only see this problem with pg_dump, which
> is interesting. This symptom has a very long history:
Yeah. There seems to be some well-hidden bug whereby dropping an object
sometimes fails to drop (some of?) its dependencies. I'm still looking
for a reproducible case, or even a hint as to what the trigger condition
might be.
> In my case, there are two "missing" pg_namespace entries, and both
> have the same missing relations.
Uh, what do you mean by "same missing relations"?
> * There's also a valid version of all these relations/objects that
> *are* connected to the schema that's alive and expected.
And this isn't making any sense to this onlooker, either. Could you
provide a more detailed explanation of the usage pattern in this
database? I speculate that what you mean is the user periodically
drops and recreates a schema + its contents, but please be explicit.
> Sadly, for whatever reason, pg_dump --schema=public didn't seem to
> help me out. We do need a workaround if we wish to keep doing
> forensics.
Yeah, pg_dump is written to glom onto everything listed in the catalogs
and sort it out later. So it tends to notice inconsistencies that you
might not notice in regular usage of the database. It's sort of hard to
avoid, since for example a --schema switch depends on seeing which
objects belong to which schema ...
regards, tom lane
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Re: 8.3.5: Types with typnamespace pointing at non-existent pg_namespace oid
2011-02-22 06:43 8.3.5: Types with typnamespace pointing at non-existent pg_namespace oid Daniel Farina <daniel@heroku.com>
2011-02-22 06:46 ` Re: 8.3.5: Types with typnamespace pointing at non-existent pg_namespace oid Daniel Farina <daniel@heroku.com>
2011-02-22 08:48 ` Re: 8.3.5: Types with typnamespace pointing at non-existent pg_namespace oid Daniel Farina <daniel@heroku.com>
2011-02-22 16:54 ` Re: Re: 8.3.5: Types with typnamespace pointing at non-existent pg_namespace oid Tom Lane <tgl@sss.pgh.pa.us>
@ 2011-02-22 18:32 ` Daniel Farina <daniel@heroku.com>
0 siblings, 0 replies; 6+ messages in thread
From: Daniel Farina @ 2011-02-22 18:32 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-bugs
On Tue, Feb 22, 2011 at 8:54 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Daniel Farina <daniel@heroku.com> writes:
>> From what I can tell, people only see this problem with pg_dump, which
>> is interesting. This symptom has a very long history:
>
> Yeah. There seems to be some well-hidden bug whereby dropping an object
> sometimes fails to drop (some of?) its dependencies. I'm still looking
> for a reproducible case, or even a hint as to what the trigger condition
> might be.
>
>> In my case, there are two "missing" pg_namespace entries, and both
>> have the same missing relations.
>
> Uh, what do you mean by "same missing relations"?
There are an identical set of relations (including quasi-relations
like indexes and sequences) with relnames and most other properties
that are identical between the versions that are tied with each of the
two missing namespaces. There's also a superset of those (but that may
be partially or totally explained by the current set being more recent
as the application as grown) that are seen with a normal looking
pg_namespace record. All three copies of these formations seem to have
very sensible pg_class/pg_type/pg_sequence formations in their
respective relnamespaces.
>> * There's also a valid version of all these relations/objects that
>> *are* connected to the schema that's alive and expected.
>
> And this isn't making any sense to this onlooker, either. Could you
> provide a more detailed explanation of the usage pattern in this
> database? I speculate that what you mean is the user periodically
> drops and recreates a schema + its contents, but please be explicit.
We run quite a large number of databases, and I unfortunately think
that this particular fault has occurred in what could be called
ancient history, as far as log retention is concerned. Sadly our
investigation will have to be limited to what we can find at this
time, although we can probably slowly work our way to being able to
catch this one in the act. We might also be able to run a catalog
query across other databases to get a sense as to the frequency of the
problem.
It may be worth noting in this case that the user does not own the
schema that is thought to be dropped (or, in fact, any schemas at
all), so DROP SCHEMA as issued by them is not likely a culprit. I will
ask around as to what administrative programs we possess that might
fool with the schema. Still, such a program is probably run many times
across many databases. This is why I'm scratching my head about the
fact that two sets of such bogus relnamespace references were
produced.
Although I have no idea how such a thing could happen, is it possible
that both copies come from one occurrence of the bug?
> Yeah, pg_dump is written to glom onto everything listed in the catalogs
> and sort it out later. So it tends to notice inconsistencies that you
> might not notice in regular usage of the database. It's sort of hard to
> avoid, since for example a --schema switch depends on seeing which
> objects belong to which schema ...
I figured as much, although if it were written slightly differently
(starting from oid where nspname = 'public') then perhaps it would not
run into problems. I was meaning to poke at pg_depend to see if
anything interesting can be seen in there.
I'll probably hack up pg_dump to try to step around the yucky
relations so we can ensure that this database gets a clean-looking
restore elsewhere before we put the strange-looking database on ice --
permanently, if you think there is no value in having it around.
--
fdr
^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2011-02-22 18:32 UTC | newest]
Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2011-02-22 06:43 8.3.5: Types with typnamespace pointing at non-existent pg_namespace oid Daniel Farina <daniel@heroku.com>
2011-02-22 06:46 ` Daniel Farina <daniel@heroku.com>
2011-02-22 08:48 ` Daniel Farina <daniel@heroku.com>
2011-02-22 11:30 ` Greg Stark <gsstark@mit.edu>
2011-02-22 16:54 ` Tom Lane <tgl@sss.pgh.pa.us>
2011-02-22 18:32 ` Daniel Farina <daniel@heroku.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox