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 2969 of file autovacuum.c.

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

Referenced by PostmasterMain().

2970 {
2972  ereport(WARNING,
2973  (errmsg("autovacuum not started because of misconfiguration"),
2974  errhint("Enable the \"track_counts\" option.")));
2975 }
int errhint(const char *fmt,...)
Definition: elog.c:987
bool autovacuum_start_daemon
Definition: autovacuum.c:111
bool pgstat_track_counts
Definition: pgstat.c:110
#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 2955 of file autovacuum.c.

References autovacuum_start_daemon, and pgstat_track_counts.

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

2956 {
2958  return false;
2959  return true;
2960 }
bool autovacuum_start_daemon
Definition: autovacuum.c:111
bool pgstat_track_counts
Definition: pgstat.c:110
void AutoVacuumShmemInit ( void  )

Definition at line 3019 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().

3020 {
3021  bool found;
3022 
3024  ShmemInitStruct("AutoVacuum Data",
3026  &found);
3027 
3028  if (!IsUnderPostmaster)
3029  {
3030  WorkerInfo worker;
3031  int i;
3032 
3033  Assert(!found);
3034 
3039 
3040  worker = (WorkerInfo) ((char *) AutoVacuumShmem +
3041  MAXALIGN(sizeof(AutoVacuumShmemStruct)));
3042 
3043  /* initialize the WorkerInfo free list */
3044  for (i = 0; i < autovacuum_max_workers; i++)
3046  &worker[i].wi_links);
3047  }
3048  else
3049  Assert(found);
3050 }
WorkerInfo av_startingWorker
Definition: autovacuum.c:267
dlist_head av_freeWorkers
Definition: autovacuum.c:265
static void dlist_push_head(dlist_head *head, dlist_node *node)
Definition: ilist.h:300
struct WorkerInfoData * WorkerInfo
Definition: autovacuum.c:232
dlist_node wi_links
Definition: autovacuum.c:220
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:3000
int autovacuum_max_workers
Definition: autovacuum.c:112
static void dlist_init(dlist_head *head)
Definition: ilist.h:278
#define NULL
Definition: c.h:226
#define Assert(condition)
Definition: c.h:670
static AutoVacuumShmemStruct * AutoVacuumShmem
Definition: autovacuum.c:270
#define MAXALIGN(LEN)
Definition: c.h:583
int i
dlist_head av_runningWorkers
Definition: autovacuum.c:266
Size AutoVacuumShmemSize ( void  )

Definition at line 3000 of file autovacuum.c.

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

Referenced by AutoVacuumShmemInit(), and CreateSharedMemoryAndSemaphores().

3001 {
3002  Size size;
3003 
3004  /*
3005  * Need the fixed struct and the array of WorkerInfoData.
3006  */
3007  size = sizeof(AutoVacuumShmemStruct);
3008  size = MAXALIGN(size);
3010  sizeof(WorkerInfoData)));
3011  return size;
3012 }
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:112
size_t Size
Definition: c.h:352
#define MAXALIGN(LEN)
Definition: c.h:583
void AutoVacuumUpdateDelay ( void  )

Definition at line 1714 of file autovacuum.c.

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

Referenced by do_autovacuum(), and vacuum_delay_point().

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

Definition at line 1347 of file autovacuum.c.

References AutoVacForkFailed, and AutoVacuumShmemStruct::av_signal.

Referenced by StartAutovacuumWorker().

1348 {
1350 }
sig_atomic_t av_signal[AutoVacNumSignals]
Definition: autovacuum.c:263
static AutoVacuumShmemStruct * AutoVacuumShmem
Definition: autovacuum.c:270
bool IsAutoVacuumLauncherProcess ( void  )

Definition at line 2983 of file autovacuum.c.

References am_autovacuum_launcher.

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

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

Definition at line 369 of file autovacuum.c.

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

Referenced by reaper(), and ServerLoop().

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

Definition at line 1431 of file autovacuum.c.

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

Referenced by StartAutovacuumWorker().

1432 {
1433  pid_t worker_pid;
1434 
1435 #ifdef EXEC_BACKEND
1436  switch ((worker_pid = avworker_forkexec()))
1437 #else
1438  switch ((worker_pid = fork_process()))
1439 #endif
1440  {
1441  case -1:
1442  ereport(LOG,
1443  (errmsg("could not fork autovacuum worker process: %m")));
1444  return 0;
1445 
1446 #ifndef EXEC_BACKEND
1447  case 0:
1448  /* in postmaster child ... */
1450 
1451  /* Close the postmaster's sockets */
1452  ClosePostmasterPorts(false);
1453 
1454  AutoVacWorkerMain(0, NULL);
1455  break;
1456 #endif
1457  default:
1458  return (int) worker_pid;
1459  }
1460 
1461  /* shouldn't get here */
1462  return 0;
1463 }
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:1469
void ClosePostmasterPorts(bool am_syslogger)
Definition: postmaster.c:2414
#define ereport(elevel, rest)
Definition: elog.h:122
#define NULL
Definition: c.h:226
int errmsg(const char *fmt,...)
Definition: elog.c:797

Variable Documentation

double autovacuum_anl_scale

Definition at line 118 of file autovacuum.c.

Referenced by relation_needs_vacanalyze().

int autovacuum_anl_thresh

Definition at line 117 of file autovacuum.c.

Referenced by relation_needs_vacanalyze().

int autovacuum_freeze_max_age
int autovacuum_multixact_freeze_max_age

Definition at line 120 of file autovacuum.c.

Referenced by MultiXactMemberFreezeThreshold(), and SetMultiXactIdLimit().

int autovacuum_naptime
bool autovacuum_start_daemon

Definition at line 111 of file autovacuum.c.

Referenced by autovac_init(), and AutoVacuumingActive().

int autovacuum_vac_cost_delay

Definition at line 122 of file autovacuum.c.

Referenced by autovac_balance_cost(), and table_recheck_autovac().

int autovacuum_vac_cost_limit

Definition at line 123 of file autovacuum.c.

Referenced by autovac_balance_cost(), and table_recheck_autovac().

double autovacuum_vac_scale

Definition at line 116 of file autovacuum.c.

Referenced by relation_needs_vacanalyze().

int autovacuum_vac_thresh

Definition at line 115 of file autovacuum.c.

Referenced by relation_needs_vacanalyze().

int autovacuum_work_mem

Definition at line 113 of file autovacuum.c.

Referenced by ginInsertCleanup(), and lazy_space_alloc().

int AutovacuumLauncherPid

Definition at line 283 of file autovacuum.c.

Referenced by FreeWorkerInfo(), and ProcKill().

int Log_autovacuum_min_duration

Definition at line 125 of file autovacuum.c.

Referenced by table_recheck_autovac().