Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
49b3462a
Commit
49b3462a
authored
May 19, 2006
by
Alvaro Herrera
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Have autovacuum report its activities to the stat collector.
parent
4adab7ee
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
96 additions
and
12 deletions
+96
-12
src/backend/postmaster/autovacuum.c
src/backend/postmaster/autovacuum.c
+68
-1
src/backend/postmaster/pgstat.c
src/backend/postmaster/pgstat.c
+9
-9
src/backend/postmaster/postmaster.c
src/backend/postmaster/postmaster.c
+4
-1
src/backend/utils/adt/pgstatfuncs.c
src/backend/utils/adt/pgstatfuncs.c
+15
-1
No files found.
src/backend/postmaster/autovacuum.c
View file @
49b3462a
...
@@ -10,7 +10,7 @@
...
@@ -10,7 +10,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/postmaster/autovacuum.c,v 1.1
8 2006/05/03 22:45:26 tgl
Exp $
* $PostgreSQL: pgsql/src/backend/postmaster/autovacuum.c,v 1.1
9 2006/05/19 15:15:37 alvherre
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -45,6 +45,8 @@
...
@@ -45,6 +45,8 @@
#include "utils/fmgroids.h"
#include "utils/fmgroids.h"
#include "utils/memutils.h"
#include "utils/memutils.h"
#include "utils/ps_status.h"
#include "utils/ps_status.h"
#include "utils/lsyscache.h"
#include "utils/rel.h"
#include "utils/relcache.h"
#include "utils/relcache.h"
#include "utils/syscache.h"
#include "utils/syscache.h"
...
@@ -109,6 +111,8 @@ static void test_rel_for_autovac(Oid relid, PgStat_StatTabEntry *tabentry,
...
@@ -109,6 +111,8 @@ static void test_rel_for_autovac(Oid relid, PgStat_StatTabEntry *tabentry,
List
**
toast_table_ids
);
List
**
toast_table_ids
);
static
void
autovacuum_do_vac_analyze
(
List
*
relids
,
bool
dovacuum
,
static
void
autovacuum_do_vac_analyze
(
List
*
relids
,
bool
dovacuum
,
bool
doanalyze
,
bool
freeze
);
bool
doanalyze
,
bool
freeze
);
static
void
autovac_report_activity
(
VacuumStmt
*
vacstmt
,
List
*
relids
);
/*
/*
...
@@ -911,12 +915,75 @@ autovacuum_do_vac_analyze(List *relids, bool dovacuum, bool doanalyze,
...
@@ -911,12 +915,75 @@ autovacuum_do_vac_analyze(List *relids, bool dovacuum, bool doanalyze,
vacstmt
->
relation
=
NULL
;
/* all tables, or not used if relids != NIL */
vacstmt
->
relation
=
NULL
;
/* all tables, or not used if relids != NIL */
vacstmt
->
va_cols
=
NIL
;
vacstmt
->
va_cols
=
NIL
;
/* Let pgstat know what we're doing */
autovac_report_activity
(
vacstmt
,
relids
);
vacuum
(
vacstmt
,
relids
);
vacuum
(
vacstmt
,
relids
);
pfree
(
vacstmt
);
pfree
(
vacstmt
);
MemoryContextSwitchTo
(
old_cxt
);
MemoryContextSwitchTo
(
old_cxt
);
}
}
/*
* autovac_report_activity
* Report to pgstat what autovacuum is doing
*
* We send a SQL string corresponding to what the user would see if the
* equivalent command was to be issued manually.
*
* Note we assume that we are going to report the next command as soon as we're
* done with the current one, and exiting right after the last one, so we don't
* bother to report "<IDLE>" or some such.
*/
#define MAX_AUTOVAC_ACTIV_LEN (NAMEDATALEN * 2 + 32)
static
void
autovac_report_activity
(
VacuumStmt
*
vacstmt
,
List
*
relids
)
{
char
activity
[
MAX_AUTOVAC_ACTIV_LEN
];
/*
* This case is not currently exercised by the autovac code. Fill it in
* if needed.
*/
if
(
list_length
(
relids
)
>
1
)
elog
(
WARNING
,
"vacuuming >1 rel unsupported"
);
/* Report the command and possible options */
if
(
vacstmt
->
vacuum
)
snprintf
(
activity
,
MAX_AUTOVAC_ACTIV_LEN
,
"VACUUM%s%s%s"
,
vacstmt
->
full
?
" FULL"
:
""
,
vacstmt
->
freeze
?
" FREEZE"
:
""
,
vacstmt
->
analyze
?
" ANALYZE"
:
""
);
else
if
(
vacstmt
->
analyze
)
snprintf
(
activity
,
MAX_AUTOVAC_ACTIV_LEN
,
"ANALYZE"
);
/* Report the qualified name of the first relation, if any */
if
(
list_length
(
relids
)
>
0
)
{
Oid
relid
=
linitial_oid
(
relids
);
Relation
rel
;
rel
=
RelationIdGetRelation
(
relid
);
if
(
rel
==
NULL
)
elog
(
WARNING
,
"cache lookup failed for relation %u"
,
relid
);
else
{
char
*
nspname
=
get_namespace_name
(
RelationGetNamespace
(
rel
));
int
len
=
strlen
(
activity
);
snprintf
(
activity
+
len
,
MAX_AUTOVAC_ACTIV_LEN
-
len
,
" %s.%s"
,
nspname
,
RelationGetRelationName
(
rel
));
pfree
(
nspname
);
RelationClose
(
rel
);
}
}
pgstat_report_activity
(
activity
);
}
/*
/*
* AutoVacuumingActive
* AutoVacuumingActive
* Check GUC vars and report whether the autovacuum process should be
* Check GUC vars and report whether the autovacuum process should be
...
...
src/backend/postmaster/pgstat.c
View file @
49b3462a
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
*
*
* Copyright (c) 2001-2006, PostgreSQL Global Development Group
* Copyright (c) 2001-2006, PostgreSQL Global Development Group
*
*
* $PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.12
4 2006/04/27 00:06:58 momjian
Exp $
* $PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.12
5 2006/05/19 15:15:37 alvherre
Exp $
* ----------
* ----------
*/
*/
#include "postgres.h"
#include "postgres.h"
...
@@ -700,17 +700,17 @@ pgstat_bestart(void)
...
@@ -700,17 +700,17 @@ pgstat_bestart(void)
/*
/*
* We may not have a MyProcPort (eg, if this is the autovacuum process).
* We may not have a MyProcPort (eg, if this is the autovacuum process).
*
For the moment, punt and don't send BESTART --- would be better to work
*
Send an all-zeroes client address, which is dealt with specially in
*
out a clean way of handling "unknown clientaddr"
.
*
pg_stat_get_backend_client_addr and pg_stat_get_backend_client_port
.
*/
*/
if
(
MyProcPort
)
{
pgstat_setheader
(
&
msg
.
m_hdr
,
PGSTAT_MTYPE_BESTART
);
pgstat_setheader
(
&
msg
.
m_hdr
,
PGSTAT_MTYPE_BESTART
);
msg
.
m_databaseid
=
MyDatabaseId
;
msg
.
m_databaseid
=
MyDatabaseId
;
msg
.
m_userid
=
GetSessionUserId
();
msg
.
m_userid
=
GetSessionUserId
();
if
(
MyProcPort
)
memcpy
(
&
msg
.
m_clientaddr
,
&
MyProcPort
->
raddr
,
sizeof
(
msg
.
m_clientaddr
));
memcpy
(
&
msg
.
m_clientaddr
,
&
MyProcPort
->
raddr
,
sizeof
(
msg
.
m_clientaddr
));
else
MemSet
(
&
msg
.
m_clientaddr
,
0
,
sizeof
(
msg
.
m_clientaddr
));
pgstat_send
(
&
msg
,
sizeof
(
msg
));
pgstat_send
(
&
msg
,
sizeof
(
msg
));
}
/*
/*
* Set up a process-exit hook to ensure we flush the last batch of
* Set up a process-exit hook to ensure we flush the last batch of
...
...
src/backend/postmaster/postmaster.c
View file @
49b3462a
...
@@ -37,7 +37,7 @@
...
@@ -37,7 +37,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.48
3 2006/03/18 22:09:58 neilc
Exp $
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.48
4 2006/05/19 15:15:37 alvherre
Exp $
*
*
* NOTES
* NOTES
*
*
...
@@ -2182,6 +2182,9 @@ reaper(SIGNAL_ARGS)
...
@@ -2182,6 +2182,9 @@ reaper(SIGNAL_ARGS)
{
{
AutoVacPID
=
0
;
AutoVacPID
=
0
;
autovac_stopped
();
autovac_stopped
();
/* Tell the collector about process termination */
pgstat_beterm
(
pid
);
if
(
exitstatus
!=
0
)
if
(
exitstatus
!=
0
)
HandleChildCrash
(
pid
,
exitstatus
,
HandleChildCrash
(
pid
,
exitstatus
,
_
(
"autovacuum process"
));
_
(
"autovacuum process"
));
...
...
src/backend/utils/adt/pgstatfuncs.c
View file @
49b3462a
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/pgstatfuncs.c,v 1.2
7 2006/03/05 15:58:43 momjian
Exp $
* $PostgreSQL: pgsql/src/backend/utils/adt/pgstatfuncs.c,v 1.2
8 2006/05/19 15:15:37 alvherre
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -389,6 +389,7 @@ Datum
...
@@ -389,6 +389,7 @@ Datum
pg_stat_get_backend_client_addr
(
PG_FUNCTION_ARGS
)
pg_stat_get_backend_client_addr
(
PG_FUNCTION_ARGS
)
{
{
PgStat_StatBeEntry
*
beentry
;
PgStat_StatBeEntry
*
beentry
;
SockAddr
zero_clientaddr
;
int32
beid
;
int32
beid
;
char
remote_host
[
NI_MAXHOST
];
char
remote_host
[
NI_MAXHOST
];
int
ret
;
int
ret
;
...
@@ -405,6 +406,12 @@ pg_stat_get_backend_client_addr(PG_FUNCTION_ARGS)
...
@@ -405,6 +406,12 @@ pg_stat_get_backend_client_addr(PG_FUNCTION_ARGS)
if
(
!
superuser
()
&&
beentry
->
userid
!=
GetUserId
())
if
(
!
superuser
()
&&
beentry
->
userid
!=
GetUserId
())
PG_RETURN_NULL
();
PG_RETURN_NULL
();
/* A zeroed client addr means we don't know */
memset
(
&
zero_clientaddr
,
0
,
sizeof
(
zero_clientaddr
));
if
(
memcmp
(
&
(
beentry
->
clientaddr
),
&
zero_clientaddr
,
sizeof
(
zero_clientaddr
)
==
0
))
PG_RETURN_NULL
();
switch
(
beentry
->
clientaddr
.
addr
.
ss_family
)
switch
(
beentry
->
clientaddr
.
addr
.
ss_family
)
{
{
case
AF_INET
:
case
AF_INET
:
...
@@ -432,6 +439,7 @@ Datum
...
@@ -432,6 +439,7 @@ Datum
pg_stat_get_backend_client_port
(
PG_FUNCTION_ARGS
)
pg_stat_get_backend_client_port
(
PG_FUNCTION_ARGS
)
{
{
PgStat_StatBeEntry
*
beentry
;
PgStat_StatBeEntry
*
beentry
;
SockAddr
zero_clientaddr
;
int32
beid
;
int32
beid
;
char
remote_port
[
NI_MAXSERV
];
char
remote_port
[
NI_MAXSERV
];
int
ret
;
int
ret
;
...
@@ -448,6 +456,12 @@ pg_stat_get_backend_client_port(PG_FUNCTION_ARGS)
...
@@ -448,6 +456,12 @@ pg_stat_get_backend_client_port(PG_FUNCTION_ARGS)
if
(
!
superuser
()
&&
beentry
->
userid
!=
GetUserId
())
if
(
!
superuser
()
&&
beentry
->
userid
!=
GetUserId
())
PG_RETURN_NULL
();
PG_RETURN_NULL
();
/* A zeroed client addr means we don't know */
memset
(
&
zero_clientaddr
,
0
,
sizeof
(
zero_clientaddr
));
if
(
memcmp
(
&
(
beentry
->
clientaddr
),
&
zero_clientaddr
,
sizeof
(
zero_clientaddr
)
==
0
))
PG_RETURN_NULL
();
switch
(
beentry
->
clientaddr
.
addr
.
ss_family
)
switch
(
beentry
->
clientaddr
.
addr
.
ss_family
)
{
{
case
AF_INET
:
case
AF_INET
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment