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

Commit9336d63

Browse files
committed
Flush any remaining statistics counts out to the collector at process
exit. Without this, operations triggered during backend exit (such astemp table deletions) won't be counted ... which given heavy usage oftemp tables can lead to pg_autovacuum falling way behind on the needto vacuum pg_class and pg_attribute. Per reports from Steve Crawfordand others.
1 parent47888fe commit9336d63

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

‎src/backend/postmaster/pgstat.c

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*
1414
*Copyright (c) 2001-2005, PostgreSQL Global Development Group
1515
*
16-
*$PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.88 2005/03/25 00:34:21 tgl Exp $
16+
*$PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.89 2005/03/31 23:20:49 tgl Exp $
1717
* ----------
1818
*/
1919
#include"postgres.h"
@@ -160,6 +160,7 @@ NON_EXEC_STATIC void PgstatCollectorMain(int argc, char *argv[]);
160160
staticvoidpgstat_recvbuffer(void);
161161
staticvoidpgstat_exit(SIGNAL_ARGS);
162162
staticvoidpgstat_die(SIGNAL_ARGS);
163+
staticvoidpgstat_beshutdown_hook(intcode,Datumarg);
163164

164165
staticintpgstat_add_backend(PgStat_MsgHdr*msg);
165166
staticvoidpgstat_sub_backend(intprocpid);
@@ -670,6 +671,25 @@ pgstat_bestart(void)
670671

671672
pgstat_setheader(&msg.m_hdr,PGSTAT_MTYPE_BESTART);
672673
pgstat_send(&msg,sizeof(msg));
674+
675+
/*
676+
* Set up a process-exit hook to ensure we flush the last batch of
677+
* statistics to the collector.
678+
*/
679+
on_proc_exit(pgstat_beshutdown_hook,0);
680+
}
681+
682+
/*
683+
* Flush any remaining statistics counts out to the collector at process
684+
* exit. Without this, operations triggered during backend exit (such as
685+
* temp table deletions) won't be counted. This is an on_proc_exit hook,
686+
* not on_shmem_exit, so that everything interesting must have happened
687+
* already.
688+
*/
689+
staticvoid
690+
pgstat_beshutdown_hook(intcode,Datumarg)
691+
{
692+
pgstat_report_tabstat();
673693
}
674694

675695

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp