PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
autovacuum.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define IsAnyAutoVacuumProcess()   (IsAutoVacuumLauncherProcess() || IsAutoVacuumWorkerProcess())
 

Functions

bool AutoVacuumingActive (void)
 
bool IsAutoVacuumLauncherProcess (void)
 
bool IsAutoVacuumWorkerProcess (void)
 
void autovac_init (void)
 
int StartAutoVacLauncher (void)
 
int StartAutoVacWorker (void)
 
void AutoVacWorkerFailed (void)
 
void AutoVacuumUpdateDelay (void)
 
Size AutoVacuumShmemSize (void)
 
void AutoVacuumShmemInit (void)
 

Variables

bool autovacuum_start_daemon
 
int autovacuum_max_workers
 
int autovacuum_work_mem
 
int autovacuum_naptime
 
int autovacuum_vac_thresh
 
double autovacuum_vac_scale
 
int autovacuum_anl_thresh
 
double autovacuum_anl_scale
 
int autovacuum_freeze_max_age
 
int autovacuum_multixact_freeze_max_age
 
int autovacuum_vac_cost_delay
 
int autovacuum_vac_cost_limit
 
int AutovacuumLauncherPid
 
int Log_autovacuum_min_duration
 

Macro Definition Documentation

#define IsAnyAutoVacuumProcess ( )    (IsAutoVacuumLauncherProcess() || IsAutoVacuumWorkerProcess())

Definition at line 42 of file autovacuum.h.

Referenced by InitProcess().

Function Documentation

void autovac_init ( void  )

Definition at line 2968 of file autovacuum.c.

References autovacuum_start_daemon, ereport, errhint(), errmsg(), pgstat_track_counts, and WARNING.

Referenced by PostmasterMain().

2969 {
2971  ereport(WARNING,
2972  (errmsg("autovacuum not started because of misconfiguration"),
2973  errhint("Enable the \"track_counts\" option.")));
2974 }
int errhint(const char *fmt,...)
Definition: elog.c:987
bool autovacuum_start_daemon
Definition: autovacuum.c:110
bool pgstat_track_counts
Definition: pgstat.c:123
#define ereport(elevel, rest)
Definition: elog.h:122
#define WARNING
Definition: elog.h:40
int errmsg(const char *fmt,...)
Definition: elog.c:797
bool AutoVacuumingActive ( void  )

Definition at line 2954 of file autovacuum.c.

References autovacuum_start_daemon, and pgstat_track_counts.

Referenced by AutoVacLauncherMain(), reaper(), relation_needs_vacanalyze(), and ServerLoop().

2955 {
2957  return false;
2958  return true;
2959 }
bool autovacuum_start_daemon
Definition: autovacuum.c:110
bool pgstat_track_counts
Definition: pgstat.c:123
void AutoVacuumShmemInit ( void  )

Definition at line 3018 of file autovacuum.c.

References Assert, autovacuum_max_workers, AutoVacuumShmemSize(), AutoVacuumShmemStruct::av_freeWorkers, AutoVacuumShmemStruct::av_launcherpid, AutoVacuumShmemStruct::av_runningWorkers, AutoVacuumShmemStruct::av_startingWorker, dlist_init(), dlist_push_head(), i, IsUnderPostmaster, MAXALIGN, NULL, ShmemInitStruct(), and WorkerInfoData::wi_links.

Referenced by CreateSharedMemoryAndSemaphores().

3019 {
3020  bool found;
3021 
3023  ShmemInitStruct("AutoVacuum Data",
3025  &found);
3026 
3027  if (!IsUnderPostmaster)
3028  {
3029  WorkerInfo worker;
3030  int i;
3031 
3032  Assert(!found);
3033 
3038 
3039  worker = (WorkerInfo) ((char *) AutoVacuumShmem +
3040  MAXALIGN(sizeof(AutoVacuumShmemStruct)));
3041 
3042  /* initialize the WorkerInfo free list */
3043  for (i = 0; i < autovacuum_max_workers; i++)
3045  &worker[i].wi_links);
3046  }
3047  else
3048  Assert(found);
3049 }
WorkerInfo av_startingWorker
Definition: autovacuum.c:266
dlist_head av_freeWorkers
Definition: autovacuum.c:264
static void dlist_push_head(dlist_head *head, dlist_node *node)
Definition: ilist.h:300
struct WorkerInfoData * WorkerInfo
Definition: autovacuum.c:231
dlist_node wi_links
Definition: autovacuum.c:219
void * ShmemInitStruct(const char *name, Size size, bool *foundPtr)
Definition: shmem.c:372
bool IsUnderPostmaster
Definition: globals.c:100
Size AutoVacuumShmemSize(void)
Definition: autovacuum.c:2999
int autovacuum_max_workers
Definition: autovacuum.c:111
static void dlist_init(dlist_head *head)
Definition: ilist.h:278
#define NULL
Definition: c.h:229
#define Assert(condition)
Definition: c.h:675
static AutoVacuumShmemStruct * AutoVacuumShmem
Definition: autovacuum.c:269
#define MAXALIGN(LEN)
Definition: c.h:588
int i
dlist_head av_runningWorkers
Definition: autovacuum.c:265
Size AutoVacuumShmemSize ( void  )

Definition at line 2999 of file autovacuum.c.

References add_size(), autovacuum_max_workers, MAXALIGN, and mul_size().

Referenced by AutoVacuumShmemInit(), and CreateSharedMemoryAndSemaphores().

3000 {
3001  Size size;
3002 
3003  /*
3004  * Need the fixed struct and the array of WorkerInfoData.
3005  */
3006  size = sizeof(AutoVacuumShmemStruct);
3007  size = MAXALIGN(size);
3009  sizeof(WorkerInfoData)));
3010  return size;
3011 }
Size mul_size(Size s1, Size s2)
Definition: shmem.c:492
Size add_size(Size s1, Size s2)
Definition: shmem.c:475
int autovacuum_max_workers
Definition: autovacuum.c:111
size_t Size
Definition: c.h:356
#define MAXALIGN(LEN)
Definition: c.h:588
void AutoVacuumUpdateDelay ( void  )

Definition at line 1713 of file autovacuum.c.

References VacuumCostDelay, VacuumCostLimit, WorkerInfoData::wi_cost_delay, and WorkerInfoData::wi_cost_limit.

Referenced by do_autovacuum(), and vacuum_delay_point().

1714 {
1715  if (MyWorkerInfo)
1716  {
1719  }
1720 }
int VacuumCostLimit
Definition: globals.c:131
static WorkerInfo MyWorkerInfo
Definition: autovacuum.c:279
int VacuumCostDelay
Definition: globals.c:132
void AutoVacWorkerFailed ( void  )

Definition at line 1346 of file autovacuum.c.

References AutoVacForkFailed, and AutoVacuumShmemStruct::av_signal.

Referenced by StartAutovacuumWorker().

1347 {
1349 }
sig_atomic_t av_signal[AutoVacNumSignals]
Definition: autovacuum.c:262
static AutoVacuumShmemStruct * AutoVacuumShmem
Definition: autovacuum.c:269
bool IsAutoVacuumLauncherProcess ( void  )

Definition at line 2982 of file autovacuum.c.

References am_autovacuum_launcher.

Referenced by autovac_refresh_stats(), backend_read_statsfile(), InitPostgres(), InitProcess(), pgstat_bestart(), and ProcKill().

2983 {
2984  return am_autovacuum_launcher;
2985 }
static bool am_autovacuum_launcher
Definition: autovacuum.c:134
int StartAutoVacLauncher ( void  )

Definition at line 368 of file autovacuum.c.

References AutoVacLauncherMain(), AutoVacPID, ClosePostmasterPorts(), ereport, errmsg(), fork_process(), InitPostmasterChild(), LOG, and NULL.

Referenced by reaper(), and ServerLoop().

369 {
370  pid_t AutoVacPID;
371 
372 #ifdef EXEC_BACKEND
373  switch ((AutoVacPID = avlauncher_forkexec()))
374 #else
375  switch ((AutoVacPID = fork_process()))
376 #endif
377  {
378  case -1:
379  ereport(LOG,
380  (errmsg("could not fork autovacuum launcher process: %m")));
381  return 0;
382 
383 #ifndef EXEC_BACKEND
384  case 0:
385  /* in postmaster child ... */
387 
388  /* Close the postmaster's sockets */
389  ClosePostmasterPorts(false);
390 
392  break;
393 #endif
394  default:
395  return (int) AutoVacPID;
396  }
397 
398  /* shouldn't get here */
399  return 0;
400 }
void InitPostmasterChild(void)
Definition: miscinit.c:175
NON_EXEC_STATIC void AutoVacLauncherMain(int argc, char *argv[]) pg_attribute_noreturn()
Definition: autovacuum.c:406
pid_t fork_process(void)
Definition: fork_process.c:31
#define LOG
Definition: elog.h:26
void ClosePostmasterPorts(bool am_syslogger)
Definition: postmaster.c:2421
#define ereport(elevel, rest)
Definition: elog.h:122
#define NULL
Definition: c.h:229
static pid_t AutoVacPID
Definition: postmaster.c:252
int errmsg(const char *fmt,...)
Definition: elog.c:797
int StartAutoVacWorker ( void  )

Definition at line 1430 of file autovacuum.c.

References AutoVacWorkerMain(), ClosePostmasterPorts(), ereport, errmsg(), fork_process(), InitPostmasterChild(), LOG, and NULL.

Referenced by StartAutovacuumWorker().

1431 {
1432  pid_t worker_pid;
1433 
1434 #ifdef EXEC_BACKEND
1435  switch ((worker_pid = avworker_forkexec()))
1436 #else
1437  switch ((worker_pid = fork_process()))
1438 #endif
1439  {
1440  case -1:
1441  ereport(LOG,
1442  (errmsg("could not fork autovacuum worker process: %m")));
1443  return 0;
1444 
1445 #ifndef EXEC_BACKEND
1446  case 0:
1447  /* in postmaster child ... */
1449 
1450  /* Close the postmaster's sockets */
1451  ClosePostmasterPorts(false);
1452 
1453  AutoVacWorkerMain(0, NULL);
1454  break;
1455 #endif
1456  default:
1457  return (int) worker_pid;
1458  }
1459 
1460  /* shouldn't get here */
1461  return 0;
1462 }
void InitPostmasterChild(void)
Definition: miscinit.c:175
pid_t fork_process(void)
Definition: fork_process.c:31
#define LOG
Definition: elog.h:26
NON_EXEC_STATIC void AutoVacWorkerMain(int argc, char *argv[]) pg_attribute_noreturn()
Definition: autovacuum.c:1468
void ClosePostmasterPorts(bool am_syslogger)
Definition: postmaster.c:2421
#define ereport(elevel, rest)
Definition: elog.h:122
#define NULL
Definition: c.h:229
int errmsg(const char *fmt,...)
Definition: elog.c:797

Variable Documentation

double autovacuum_anl_scale

Definition at line 117 of file autovacuum.c.

Referenced by relation_needs_vacanalyze().

int autovacuum_anl_thresh

Definition at line 116 of file autovacuum.c.

Referenced by relation_needs_vacanalyze().

int autovacuum_freeze_max_age
int autovacuum_multixact_freeze_max_age

Definition at line 119 of file autovacuum.c.

Referenced by MultiXactMemberFreezeThreshold(), and SetMultiXactIdLimit().

int autovacuum_naptime
bool autovacuum_start_daemon

Definition at line 110 of file autovacuum.c.

Referenced by autovac_init(), and AutoVacuumingActive().

int autovacuum_vac_cost_delay

Definition at line 121 of file autovacuum.c.

Referenced by autovac_balance_cost(), and table_recheck_autovac().

int autovacuum_vac_cost_limit

Definition at line 122 of file autovacuum.c.

Referenced by autovac_balance_cost(), and table_recheck_autovac().

double autovacuum_vac_scale

Definition at line 115 of file autovacuum.c.

Referenced by relation_needs_vacanalyze().

int autovacuum_vac_thresh

Definition at line 114 of file autovacuum.c.

Referenced by relation_needs_vacanalyze().

int autovacuum_work_mem

Definition at line 112 of file autovacuum.c.

Referenced by ginInsertCleanup(), and lazy_space_alloc().

int AutovacuumLauncherPid

Definition at line 282 of file autovacuum.c.

Referenced by FreeWorkerInfo(), and ProcKill().

int Log_autovacuum_min_duration

Definition at line 124 of file autovacuum.c.

Referenced by table_recheck_autovac().