ITAGAKI Takahiro <[EMAIL PROTECTED]> 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

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Reply via email to