Re: pgstat_drop_relation bugfix

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: ITAGAKI Takahiro <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp>
Cc: pgsql-patches(at)postgresql(dot)org
Subject: Re: pgstat_drop_relation bugfix
Date: 2007-07-03 16:43:58
Message-ID: 9564.1183481038@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

ITAGAKI Takahiro <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp> writes:
> I wrote:
>>> pgstat_drop_relation() is expecting relid (pg_class.oid) as the argument,
>>> but we pass it relfilenode.

> Here is a patch to fix undropped entries in the runtime statistics table.
> Now smgr records the relation oids and uses them to drop entries
> corresponding the relations.
> ...
> I fell my fix is uncool; Let me know if there are any other better ways.

I don't like this patch either. It's ugly because it introduces
relation OIDs into a level of the system that should only be dealing in
relfilenodes --- which I think is not just cosmetic, it adds hazards of
using the wrong one (which indeed is exactly the type of bug we're
trying to fix...) It's not even correct: the patch for
setNewRelfilenode specifies the rel OID to both the smgrcreate and
smgrscheduleunlink calls, which means that the stats collector will be
told to drop its stats for that OID on either commit or rollback.
Surely not what we'd like. Now that could be fixed, but it illustrates
that this is actually a very fragile way of thinking about and dealing
with the problem.

I thought for awhile about changing the pgstats stuff to identify
relations by RelFileNode instead of OID. That has a number of
attractions --- you could argue that it's more correct when dealing with
reassigned relfilenodes, for instance. But it'd be a lot of work and
it would mean changing the signatures of all the pg_stat_get_foo()
functions, which would break people's custom stats views.

What I'm inclined to propose is that we just remove the
pgstat_drop_relation() call from smgr_internal_unlink, and rely entirely
on VACUUM to clean out dead entries in the pgstats data.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jeferson Kasper 2007-07-03 17:09:16 how to "pg_dump", based in select command
Previous Message Naz Gassiep 2007-07-03 16:00:08 Re: todo: Hash index creation

Browse pgsql-patches by date

  From Date Subject
Next Message Jim C. Nasby 2007-07-03 20:09:41 Re: Still recommending daily vacuum...
Previous Message Tom Lane 2007-07-03 14:09:16 Re: SPI-header-files safe for C++-compiler