Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb09cb0c

Browse files
committed
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 possiblycause some other relation's stats to be zeroed out. While we could try toclean this up, it seems much simpler and more reliable to let the nextinvocation of pgstat_vacuum_tabstat() fix things; which indeed is how itworked before I introduced the buggy code into 8.1.3 and later :-(.Problem noticed by Itagaki Takahiro, fix is per subsequent discussion.
1 parent8331c11 commitb09cb0c

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

‎src/backend/postmaster/pgstat.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*
1414
*Copyright (c) 2001-2007, PostgreSQL Global Development Group
1515
*
16-
*$PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.160 2007/06/28 00:02:38 tgl Exp $
16+
*$PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.161 2007/07/08 22:23:16 tgl Exp $
1717
* ----------
1818
*/
1919
#include"postgres.h"
@@ -964,8 +964,12 @@ pgstat_drop_database(Oid databaseid)
964964
*Tell the collector that we just dropped a relation.
965965
*(If the message gets lost, we will still clean the dead entry eventually
966966
*via future invocations of pgstat_vacuum_tabstat().)
967+
*
968+
*Currently not used for lack of any good place to call it; we rely
969+
*entirely on pgstat_vacuum_tabstat() to clean out stats for dead rels.
967970
* ----------
968971
*/
972+
#ifdefNOT_USED
969973
void
970974
pgstat_drop_relation(Oidrelid)
971975
{
@@ -984,6 +988,7 @@ pgstat_drop_relation(Oid relid)
984988
msg.m_databaseid=MyDatabaseId;
985989
pgstat_send(&msg,len);
986990
}
991+
#endif/* NOT_USED */
987992

988993

989994
/* ----------

‎src/backend/storage/smgr/smgr.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*
1212
*
1313
* IDENTIFICATION
14-
* $PostgreSQL: pgsql/src/backend/storage/smgr/smgr.c,v 1.103 2007/01/05 22:19:39 momjian Exp $
14+
* $PostgreSQL: pgsql/src/backend/storage/smgr/smgr.c,v 1.104 2007/07/08 22:23:16 tgl Exp $
1515
*
1616
*-------------------------------------------------------------------------
1717
*/
@@ -20,11 +20,11 @@
2020
#include"access/xact.h"
2121
#include"access/xlogutils.h"
2222
#include"commands/tablespace.h"
23-
#include"pgstat.h"
2423
#include"storage/bufmgr.h"
2524
#include"storage/freespace.h"
2625
#include"storage/ipc.h"
2726
#include"storage/smgr.h"
27+
#include"utils/hsearch.h"
2828
#include"utils/memutils.h"
2929

3030

@@ -452,13 +452,11 @@ smgr_internal_unlink(RelFileNode rnode, int which, bool isTemp, bool isRedo)
452452
FreeSpaceMapForgetRel(&rnode);
453453

454454
/*
455-
*Tellthe stats collector to forget it immediately, too.Skip this in
456-
*recovery mode, since the stats collector likely isn'trunning(andif
457-
*it is, pgstat.c will get confused because we aren't a real backend
458-
*process).
455+
*It'd be nice to tellthe stats collector to forget it immediately, too.
456+
*But we can't because we don'tknow the OID(andin cases involving
457+
*relfilenode swaps, it's not always clear which table OID to forget,
458+
*anyway).
459459
*/
460-
if (!InRecovery)
461-
pgstat_drop_relation(rnode.relNode);
462460

463461
/*
464462
* And delete the physical files.

‎src/include/pgstat.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*
66
*Copyright (c) 2001-2007, PostgreSQL Global Development Group
77
*
8-
*$PostgreSQL: pgsql/src/include/pgstat.h,v 1.63 2007/06/28 00:02:40 tgl Exp $
8+
*$PostgreSQL: pgsql/src/include/pgstat.h,v 1.64 2007/07/08 22:23:16 tgl Exp $
99
* ----------
1010
*/
1111
#ifndefPGSTAT_H
@@ -486,7 +486,6 @@ extern void pgstat_ping(void);
486486
externvoidpgstat_report_tabstat(boolforce);
487487
externvoidpgstat_vacuum_tabstat(void);
488488
externvoidpgstat_drop_database(Oiddatabaseid);
489-
externvoidpgstat_drop_relation(Oidrelid);
490489

491490
externvoidpgstat_clear_snapshot(void);
492491
externvoidpgstat_reset_counters(void);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp