mirror of
https://github.com/postgres/postgres.git
synced 2025-05-28 05:21:27 +03:00
Remove the pgstat_drop_relation() call from smgr_internal_unlink(), because
we don't know at that point which relation OID to tell pgstat to forget. The code was passing the relfilenode, which is incorrect, and could possibly cause some other relation's stats to be zeroed out. While we could try to clean this up, it seems much simpler and more reliable to let the next invocation of pgstat_vacuum_tabstat() fix things; which indeed is how it worked before I introduced the buggy code into 8.1.3 and later :-(. Problem noticed by Itagaki Takahiro, fix is per subsequent discussion.
This commit is contained in:
parent
5d798ba82f
commit
4ceaf35ff3
@ -13,7 +13,7 @@
|
|||||||
*
|
*
|
||||||
* Copyright (c) 2001-2005, PostgreSQL Global Development Group
|
* Copyright (c) 2001-2005, PostgreSQL Global Development Group
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.111.2.8 2007/06/07 19:07:11 alvherre Exp $
|
* $PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.111.2.9 2007/07/08 22:23:32 tgl Exp $
|
||||||
* ----------
|
* ----------
|
||||||
*/
|
*/
|
||||||
#include "postgres.h"
|
#include "postgres.h"
|
||||||
@ -1070,8 +1070,12 @@ pgstat_drop_database(Oid databaseid)
|
|||||||
* Tell the collector that we just dropped a relation.
|
* Tell the collector that we just dropped a relation.
|
||||||
* (If the message gets lost, we will still clean the dead entry eventually
|
* (If the message gets lost, we will still clean the dead entry eventually
|
||||||
* via future invocations of pgstat_vacuum_tabstat().)
|
* via future invocations of pgstat_vacuum_tabstat().)
|
||||||
|
*
|
||||||
|
* Currently not used for lack of any good place to call it; we rely
|
||||||
|
* entirely on pgstat_vacuum_tabstat() to clean out stats for dead rels.
|
||||||
* ----------
|
* ----------
|
||||||
*/
|
*/
|
||||||
|
#ifdef NOT_USED
|
||||||
void
|
void
|
||||||
pgstat_drop_relation(Oid relid)
|
pgstat_drop_relation(Oid relid)
|
||||||
{
|
{
|
||||||
@ -1090,6 +1094,7 @@ pgstat_drop_relation(Oid relid)
|
|||||||
msg.m_databaseid = MyDatabaseId;
|
msg.m_databaseid = MyDatabaseId;
|
||||||
pgstat_send(&msg, len);
|
pgstat_send(&msg, len);
|
||||||
}
|
}
|
||||||
|
#endif /* NOT_USED */
|
||||||
|
|
||||||
|
|
||||||
/* ----------
|
/* ----------
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/storage/smgr/smgr.c,v 1.93.2.3 2006/03/30 22:11:59 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/storage/smgr/smgr.c,v 1.93.2.4 2007/07/08 22:23:32 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
#include "access/xact.h"
|
#include "access/xact.h"
|
||||||
#include "commands/tablespace.h"
|
#include "commands/tablespace.h"
|
||||||
#include "pgstat.h"
|
|
||||||
#include "storage/bufmgr.h"
|
#include "storage/bufmgr.h"
|
||||||
#include "storage/freespace.h"
|
#include "storage/freespace.h"
|
||||||
#include "storage/ipc.h"
|
#include "storage/ipc.h"
|
||||||
@ -471,13 +470,11 @@ smgr_internal_unlink(RelFileNode rnode, int which, bool isTemp, bool isRedo)
|
|||||||
FreeSpaceMapForgetRel(&rnode);
|
FreeSpaceMapForgetRel(&rnode);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Tell the stats collector to forget it immediately, too. Skip this
|
* It'd be nice to tell the stats collector to forget it immediately, too.
|
||||||
* in recovery mode, since the stats collector likely isn't running
|
* But we can't because we don't know the OID (and in cases involving
|
||||||
* (and if it is, pgstats.c will get confused because we aren't a real
|
* relfilenode swaps, it's not always clear which table OID to forget,
|
||||||
* backend process).
|
* anyway).
|
||||||
*/
|
*/
|
||||||
if (!InRecovery)
|
|
||||||
pgstat_drop_relation(rnode.relNode);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* And delete the physical files.
|
* And delete the physical files.
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
*
|
*
|
||||||
* Copyright (c) 2001-2005, PostgreSQL Global Development Group
|
* Copyright (c) 2001-2005, PostgreSQL Global Development Group
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/include/pgstat.h,v 1.38.2.1 2006/01/18 20:35:16 tgl Exp $
|
* $PostgreSQL: pgsql/src/include/pgstat.h,v 1.38.2.2 2007/07/08 22:23:32 tgl Exp $
|
||||||
* ----------
|
* ----------
|
||||||
*/
|
*/
|
||||||
#ifndef PGSTAT_H
|
#ifndef PGSTAT_H
|
||||||
@ -412,7 +412,6 @@ extern void pgstat_report_analyze(Oid tableoid, bool shared,
|
|||||||
PgStat_Counter livetuples,
|
PgStat_Counter livetuples,
|
||||||
PgStat_Counter deadtuples);
|
PgStat_Counter deadtuples);
|
||||||
extern void pgstat_vacuum_tabstat(void);
|
extern void pgstat_vacuum_tabstat(void);
|
||||||
extern void pgstat_drop_relation(Oid relid);
|
|
||||||
|
|
||||||
extern void pgstat_reset_counters(void);
|
extern void pgstat_reset_counters(void);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user