Skip to content

Commit f442711

Browse files
committed
Call pgstat_drop_database during DROP DATABASE, so that any stats file
entries for the victim database go away sooner rather than later. We already did the equivalent thing at the per-relation level, not sure why it's not been done for whole databases. With this change, pgstat_vacuum_tabstat should usually not find anything to do; though we still need it as a backstop in case DROPDB or TABPURGE messages get lost under load.
1 parent c138b96 commit f442711

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

src/backend/commands/dbcommands.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*
1414
*
1515
* IDENTIFICATION
16-
* $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.191 2007/02/01 19:10:26 momjian Exp $
16+
* $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.192 2007/02/09 16:12:18 tgl Exp $
1717
*
1818
*-------------------------------------------------------------------------
1919
*/
@@ -37,6 +37,7 @@
3737
#include "commands/tablespace.h"
3838
#include "mb/pg_wchar.h"
3939
#include "miscadmin.h"
40+
#include "pgstat.h"
4041
#include "postmaster/bgwriter.h"
4142
#include "storage/freespace.h"
4243
#include "storage/procarray.h"
@@ -644,6 +645,11 @@ dropdb(const char *dbname, bool missing_ok)
644645
*/
645646
FreeSpaceMapForgetDatabase(db_id);
646647

648+
/*
649+
* Tell the stats collector to forget it immediately, too.
650+
*/
651+
pgstat_drop_database(db_id);
652+
647653
/*
648654
* Tell bgwriter to forget any pending fsync requests for files in the
649655
* database; else it'll fail at next checkpoint.

src/backend/postmaster/pgstat.c

Lines changed: 2 additions & 3 deletions
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.145 2007/02/07 23:11:29 tgl Exp $
16+
* $PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.146 2007/02/09 16:12:18 tgl Exp $
1717
* ----------
1818
*/
1919
#include "postgres.h"
@@ -153,7 +153,6 @@ static void force_statwrite(SIGNAL_ARGS);
153153
static void pgstat_beshutdown_hook(int code, Datum arg);
154154

155155
static PgStat_StatDBEntry *pgstat_get_db_entry(Oid databaseid, bool create);
156-
static void pgstat_drop_database(Oid databaseid);
157156
static void pgstat_write_statsfile(void);
158157
static HTAB *pgstat_read_statsfile(Oid onlydb);
159158
static void backend_read_statsfile(void);
@@ -820,7 +819,7 @@ pgstat_collect_oids(Oid catalogid)
820819
* via future invocations of pgstat_vacuum_tabstat().)
821820
* ----------
822821
*/
823-
static void
822+
void
824823
pgstat_drop_database(Oid databaseid)
825824
{
826825
PgStat_MsgDropdb msg;

src/include/pgstat.h

Lines changed: 2 additions & 1 deletion
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.53 2007/02/07 23:11:30 tgl Exp $
8+
* $PostgreSQL: pgsql/src/include/pgstat.h,v 1.54 2007/02/09 16:12:19 tgl Exp $
99
* ----------
1010
*/
1111
#ifndef PGSTAT_H
@@ -378,6 +378,7 @@ extern void pgstat_ping(void);
378378

379379
extern void pgstat_report_tabstat(void);
380380
extern void pgstat_vacuum_tabstat(void);
381+
extern void pgstat_drop_database(Oid databaseid);
381382
extern void pgstat_drop_relation(Oid relid);
382383

383384
extern void pgstat_clear_snapshot(void);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy