PostgreSQL Source Code  git master
autoprewarm.c File Reference
#include "postgres.h"
#include <unistd.h>
#include "access/relation.h"
#include "access/xact.h"
#include "catalog/pg_class.h"
#include "catalog/pg_type.h"
#include "miscadmin.h"
#include "pgstat.h"
#include "postmaster/bgworker.h"
#include "storage/buf_internals.h"
#include "storage/dsm.h"
#include "storage/ipc.h"
#include "storage/latch.h"
#include "storage/lwlock.h"
#include "storage/proc.h"
#include "storage/procsignal.h"
#include "storage/shmem.h"
#include "storage/smgr.h"
#include "tcop/tcopprot.h"
#include "utils/acl.h"
#include "utils/datetime.h"
#include "utils/guc.h"
#include "utils/memutils.h"
#include "utils/rel.h"
#include "utils/relfilenodemap.h"
#include "utils/resowner.h"
Include dependency graph for autoprewarm.c:

Go to the source code of this file.

Data Structures

struct  BlockInfoRecord
 
struct  AutoPrewarmSharedState
 

Macros

#define AUTOPREWARM_FILE   "autoprewarm.blocks"
 
#define cmp_member_elem(fld)
 

Typedefs

typedef struct BlockInfoRecord BlockInfoRecord
 
typedef struct AutoPrewarmSharedState AutoPrewarmSharedState
 

Functions

void _PG_init (void)
 
void autoprewarm_main (Datum main_arg)
 
void autoprewarm_database_main (Datum main_arg)
 
 PG_FUNCTION_INFO_V1 (autoprewarm_start_worker)
 
 PG_FUNCTION_INFO_V1 (autoprewarm_dump_now)
 
static void apw_load_buffers (void)
 
static int apw_dump_now (bool is_bgworker, bool dump_unlogged)
 
static void apw_start_leader_worker (void)
 
static void apw_start_database_worker (void)
 
static bool apw_init_shmem (void)
 
static void apw_detach_shmem (int code, Datum arg)
 
static int apw_compare_blockinfo (const void *p, const void *q)
 
static void apw_sigterm_handler (SIGNAL_ARGS)
 
static void apw_sighup_handler (SIGNAL_ARGS)
 
Datum autoprewarm_start_worker (PG_FUNCTION_ARGS)
 
Datum autoprewarm_dump_now (PG_FUNCTION_ARGS)
 

Variables

static volatile sig_atomic_t got_sigterm = false
 
static volatile sig_atomic_t got_sighup = false
 
static AutoPrewarmSharedStateapw_state = NULL
 
static bool autoprewarm = true
 
static int autoprewarm_interval
 

Macro Definition Documentation

◆ AUTOPREWARM_FILE

#define AUTOPREWARM_FILE   "autoprewarm.blocks"

Definition at line 56 of file autoprewarm.c.

Referenced by apw_dump_now(), and apw_load_buffers().

◆ cmp_member_elem

#define cmp_member_elem (   fld)
Value:
do { \
if (a->fld < b->fld) \
return -1; \
else if (a->fld > b->fld) \
return 1; \
} while(0)

Definition at line 867 of file autoprewarm.c.

Referenced by apw_compare_blockinfo().

Typedef Documentation

◆ AutoPrewarmSharedState

◆ BlockInfoRecord

Function Documentation

◆ _PG_init()

void _PG_init ( void  )

Definition at line 115 of file autoprewarm.c.

References apw_start_leader_worker(), autoprewarm, autoprewarm_interval, DefineCustomBoolVariable(), DefineCustomIntVariable(), EmitWarningsOnPlaceholders(), GUC_UNIT_S, MAXALIGN, PGC_POSTMASTER, PGC_SIGHUP, process_shared_preload_libraries_in_progress, and RequestAddinShmemSpace().

116 {
117  DefineCustomIntVariable("pg_prewarm.autoprewarm_interval",
118  "Sets the interval between dumps of shared buffers",
119  "If set to zero, time-based dumping is disabled.",
121  300,
122  0, INT_MAX / 1000,
123  PGC_SIGHUP,
124  GUC_UNIT_S,
125  NULL,
126  NULL,
127  NULL);
128 
130  return;
131 
132  /* can't define PGC_POSTMASTER variable after startup */
133  DefineCustomBoolVariable("pg_prewarm.autoprewarm",
134  "Starts the autoprewarm worker.",
135  NULL,
136  &autoprewarm,
137  true,
139  0,
140  NULL,
141  NULL,
142  NULL);
143 
144  EmitWarningsOnPlaceholders("pg_prewarm");
145 
147 
148  /* Register autoprewarm worker, if enabled. */
149  if (autoprewarm)
151 }
void DefineCustomIntVariable(const char *name, const char *short_desc, const char *long_desc, int *valueAddr, int bootValue, int minValue, int maxValue, GucContext context, int flags, GucIntCheckHook check_hook, GucIntAssignHook assign_hook, GucShowHook show_hook)
Definition: guc.c:8826
void RequestAddinShmemSpace(Size size)
Definition: ipci.c:71
bool process_shared_preload_libraries_in_progress
Definition: miscinit.c:1596
static int autoprewarm_interval
Definition: autoprewarm.c:109
#define GUC_UNIT_S
Definition: guc.h:226
void EmitWarningsOnPlaceholders(const char *className)
Definition: guc.c:8939
static void apw_start_leader_worker(void)
Definition: autoprewarm.c:793
Definition: guc.h:72
static bool autoprewarm
Definition: autoprewarm.c:108
#define MAXALIGN(LEN)
Definition: c.h:698
void DefineCustomBoolVariable(const char *name, const char *short_desc, const char *long_desc, bool *valueAddr, bool bootValue, GucContext context, int flags, GucBoolCheckHook check_hook, GucBoolAssignHook assign_hook, GucShowHook show_hook)
Definition: guc.c:8800

◆ apw_compare_blockinfo()

static int apw_compare_blockinfo ( const void *  p,
const void *  q 
)
static

Definition at line 885 of file autoprewarm.c.

References BlockInfoRecord::blocknum, cmp_member_elem, BlockInfoRecord::database, BlockInfoRecord::filenode, BlockInfoRecord::forknum, and BlockInfoRecord::tablespace.

Referenced by apw_load_buffers().

886 {
887  const BlockInfoRecord *a = (const BlockInfoRecord *) p;
888  const BlockInfoRecord *b = (const BlockInfoRecord *) q;
889 
890  cmp_member_elem(database);
892  cmp_member_elem(filenode);
893  cmp_member_elem(forknum);
894  cmp_member_elem(blocknum);
895 
896  return 0;
897 }
#define cmp_member_elem(fld)
Definition: autoprewarm.c:867
char * tablespace
Definition: pgbench.c:189

◆ apw_detach_shmem()

static void apw_detach_shmem ( int  code,
Datum  arg 
)
static

Definition at line 779 of file autoprewarm.c.

References AutoPrewarmSharedState::bgworker_pid, InvalidPid, AutoPrewarmSharedState::lock, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), MyProcPid, and AutoPrewarmSharedState::pid_using_dumpfile.

Referenced by autoprewarm_dump_now(), and autoprewarm_main().

780 {
787 }
int MyProcPid
Definition: globals.c:40
void LWLockRelease(LWLock *lock)
Definition: lwlock.c:1812
static AutoPrewarmSharedState * apw_state
Definition: autoprewarm.c:105
bool LWLockAcquire(LWLock *lock, LWLockMode mode)
Definition: lwlock.c:1208
#define InvalidPid
Definition: miscadmin.h:32

◆ apw_dump_now()

static int apw_dump_now ( bool  is_bgworker,
bool  dump_unlogged 
)
static

Definition at line 560 of file autoprewarm.c.

References AllocateFile(), AUTOPREWARM_FILE, BlockInfoRecord::blocknum, buftag::blockNum, BM_PERMANENT, BM_TAG_VALID, CHECK_FOR_INTERRUPTS, BlockInfoRecord::database, RelFileNode::dbNode, DEBUG1, durable_rename(), ereport, errcode_for_file_access(), errmsg(), ERROR, BlockInfoRecord::filenode, BlockInfoRecord::forknum, buftag::forkNum, fprintf, FreeFile(), GetBufferDescriptor, i, InvalidPid, AutoPrewarmSharedState::lock, LockBufHdr(), LOG, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), MAXPGPATH, MyProcPid, NBuffers, palloc(), pfree(), AutoPrewarmSharedState::pid_using_dumpfile, RelFileNode::relNode, buftag::rnode, snprintf, RelFileNode::spcNode, BlockInfoRecord::tablespace, BufferDesc::tag, and UnlockBufHdr.

Referenced by autoprewarm_dump_now(), and autoprewarm_main().

561 {
562  int num_blocks;
563  int i;
564  int ret;
565  BlockInfoRecord *block_info_array;
566  BufferDesc *bufHdr;
567  FILE *file;
568  char transient_dump_file_path[MAXPGPATH];
569  pid_t pid;
570 
576 
577  if (pid != InvalidPid)
578  {
579  if (!is_bgworker)
580  ereport(ERROR,
581  (errmsg("could not perform block dump because dump file is being used by PID %lu",
582  (unsigned long) apw_state->pid_using_dumpfile)));
583 
584  ereport(LOG,
585  (errmsg("skipping block dump because it is already being performed by PID %lu",
586  (unsigned long) apw_state->pid_using_dumpfile)));
587  return 0;
588  }
589 
590  block_info_array =
592 
593  for (num_blocks = 0, i = 0; i < NBuffers; i++)
594  {
595  uint32 buf_state;
596 
598 
599  bufHdr = GetBufferDescriptor(i);
600 
601  /* Lock each buffer header before inspecting. */
602  buf_state = LockBufHdr(bufHdr);
603 
604  /*
605  * Unlogged tables will be automatically truncated after a crash or
606  * unclean shutdown. In such cases we need not prewarm them. Dump them
607  * only if requested by caller.
608  */
609  if (buf_state & BM_TAG_VALID &&
610  ((buf_state & BM_PERMANENT) || dump_unlogged))
611  {
612  block_info_array[num_blocks].database = bufHdr->tag.rnode.dbNode;
613  block_info_array[num_blocks].tablespace = bufHdr->tag.rnode.spcNode;
614  block_info_array[num_blocks].filenode = bufHdr->tag.rnode.relNode;
615  block_info_array[num_blocks].forknum = bufHdr->tag.forkNum;
616  block_info_array[num_blocks].blocknum = bufHdr->tag.blockNum;
617  ++num_blocks;
618  }
619 
620  UnlockBufHdr(bufHdr, buf_state);
621  }
622 
623  snprintf(transient_dump_file_path, MAXPGPATH, "%s.tmp", AUTOPREWARM_FILE);
624  file = AllocateFile(transient_dump_file_path, "w");
625  if (!file)
626  ereport(ERROR,
628  errmsg("could not open file \"%s\": %m",
629  transient_dump_file_path)));
630 
631  ret = fprintf(file, "<<%d>>\n", num_blocks);
632  if (ret < 0)
633  {
634  int save_errno = errno;
635 
636  FreeFile(file);
637  unlink(transient_dump_file_path);
638  errno = save_errno;
639  ereport(ERROR,
641  errmsg("could not write to file \"%s\": %m",
642  transient_dump_file_path)));
643  }
644 
645  for (i = 0; i < num_blocks; i++)
646  {
648 
649  ret = fprintf(file, "%u,%u,%u,%u,%u\n",
650  block_info_array[i].database,
651  block_info_array[i].tablespace,
652  block_info_array[i].filenode,
653  (uint32) block_info_array[i].forknum,
654  block_info_array[i].blocknum);
655  if (ret < 0)
656  {
657  int save_errno = errno;
658 
659  FreeFile(file);
660  unlink(transient_dump_file_path);
661  errno = save_errno;
662  ereport(ERROR,
664  errmsg("could not write to file \"%s\": %m",
665  transient_dump_file_path)));
666  }
667  }
668 
669  pfree(block_info_array);
670 
671  /*
672  * Rename transient_dump_file_path to AUTOPREWARM_FILE to make things
673  * permanent.
674  */
675  ret = FreeFile(file);
676  if (ret != 0)
677  {
678  int save_errno = errno;
679 
680  unlink(transient_dump_file_path);
681  errno = save_errno;
682  ereport(ERROR,
684  errmsg("could not close file \"%s\": %m",
685  transient_dump_file_path)));
686  }
687 
688  (void) durable_rename(transient_dump_file_path, AUTOPREWARM_FILE, ERROR);
690 
691  ereport(DEBUG1,
692  (errmsg("wrote block details for %d blocks", num_blocks)));
693  return num_blocks;
694 }
#define BM_PERMANENT
Definition: buf_internals.h:66
#define DEBUG1
Definition: elog.h:25
int MyProcPid
Definition: globals.c:40
#define BM_TAG_VALID
Definition: buf_internals.h:60
ForkNumber forkNum
Definition: buf_internals.h:93
#define LOG
Definition: elog.h:26
#define fprintf
Definition: port.h:197
void LWLockRelease(LWLock *lock)
Definition: lwlock.c:1812
#define AUTOPREWARM_FILE
Definition: autoprewarm.c:56
ForkNumber forknum
Definition: autoprewarm.c:64
void pfree(void *pointer)
Definition: mcxt.c:1057
#define ERROR
Definition: elog.h:43
static AutoPrewarmSharedState * apw_state
Definition: autoprewarm.c:105
#define MAXPGPATH
char * tablespace
Definition: pgbench.c:189
int errcode_for_file_access(void)
Definition: elog.c:633
#define GetBufferDescriptor(id)
FILE * AllocateFile(const char *name, const char *mode)
Definition: fd.c:2322
unsigned int uint32
Definition: c.h:374
int durable_rename(const char *oldfile, const char *newfile, int elevel)
Definition: fd.c:659
#define ereport(elevel,...)
Definition: elog.h:144
uint32 LockBufHdr(BufferDesc *desc)
Definition: bufmgr.c:4318
bool LWLockAcquire(LWLock *lock, LWLockMode mode)
Definition: lwlock.c:1208
BlockNumber blockNum
Definition: buf_internals.h:94
RelFileNode rnode
Definition: buf_internals.h:92
int FreeFile(FILE *file)
Definition: fd.c:2521
BufferTag tag
BlockNumber blocknum
Definition: autoprewarm.c:65
void * palloc(Size size)
Definition: mcxt.c:950
int errmsg(const char *fmt,...)
Definition: elog.c:824
#define UnlockBufHdr(desc, s)
int i
int NBuffers
Definition: globals.c:132
#define CHECK_FOR_INTERRUPTS()
Definition: miscadmin.h:99
#define snprintf
Definition: port.h:193
#define InvalidPid
Definition: miscadmin.h:32

◆ apw_init_shmem()

static bool apw_init_shmem ( void  )
static

Definition at line 753 of file autoprewarm.c.

References AutoPrewarmSharedState::bgworker_pid, InvalidPid, AutoPrewarmSharedState::lock, LW_EXCLUSIVE, LWLockAcquire(), LWLockInitialize(), LWLockNewTrancheId(), LWLockRegisterTranche(), LWLockRelease(), AutoPrewarmSharedState::pid_using_dumpfile, ShmemInitStruct(), and LWLock::tranche.

Referenced by autoprewarm_database_main(), autoprewarm_dump_now(), autoprewarm_main(), and autoprewarm_start_worker().

754 {
755  bool found;
756 
757  LWLockAcquire(AddinShmemInitLock, LW_EXCLUSIVE);
758  apw_state = ShmemInitStruct("autoprewarm",
759  sizeof(AutoPrewarmSharedState),
760  &found);
761  if (!found)
762  {
763  /* First time through ... */
767  }
768  LWLockRelease(AddinShmemInitLock);
769 
770  LWLockRegisterTranche(apw_state->lock.tranche, "autoprewarm");
771 
772  return found;
773 }
int LWLockNewTrancheId(void)
Definition: lwlock.c:629
void LWLockRegisterTranche(int tranche_id, const char *tranche_name)
Definition: lwlock.c:653
void LWLockRelease(LWLock *lock)
Definition: lwlock.c:1812
static AutoPrewarmSharedState * apw_state
Definition: autoprewarm.c:105
void * ShmemInitStruct(const char *name, Size size, bool *foundPtr)
Definition: shmem.c:392
uint16 tranche
Definition: lwlock.h:33
void LWLockInitialize(LWLock *lock, int tranche_id)
Definition: lwlock.c:745
bool LWLockAcquire(LWLock *lock, LWLockMode mode)
Definition: lwlock.c:1208
#define InvalidPid
Definition: miscadmin.h:32

◆ apw_load_buffers()

static void apw_load_buffers ( void  )
static

Definition at line 272 of file autoprewarm.c.

References AllocateFile(), apw_compare_blockinfo(), apw_start_database_worker(), Assert, AUTOPREWARM_FILE, AutoPrewarmSharedState::block_info_handle, BlockInfoRecord::blocknum, BlockInfoRecord::database, AutoPrewarmSharedState::database, dsm_create(), dsm_detach(), DSM_HANDLE_INVALID, dsm_segment_address(), dsm_segment_handle(), ereport, errcode_for_file_access(), errmsg(), ERROR, BlockInfoRecord::filenode, BlockInfoRecord::forknum, FreeFile(), have_free_buffer(), i, InvalidOid, InvalidPid, AutoPrewarmSharedState::lock, LOG, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), MyProcPid, pg_qsort(), AutoPrewarmSharedState::pid_using_dumpfile, AutoPrewarmSharedState::prewarm_start_idx, AutoPrewarmSharedState::prewarm_stop_idx, AutoPrewarmSharedState::prewarmed_blocks, and BlockInfoRecord::tablespace.

Referenced by autoprewarm_main().

273 {
274  FILE *file = NULL;
275  int num_elements,
276  i;
277  BlockInfoRecord *blkinfo;
278  dsm_segment *seg;
279 
280  /*
281  * Skip the prewarm if the dump file is in use; otherwise, prevent any
282  * other process from writing it while we're using it.
283  */
287  else
288  {
290  ereport(LOG,
291  (errmsg("skipping prewarm because block dump file is being written by PID %lu",
292  (unsigned long) apw_state->pid_using_dumpfile)));
293  return;
294  }
296 
297  /*
298  * Open the block dump file. Exit quietly if it doesn't exist, but report
299  * any other error.
300  */
301  file = AllocateFile(AUTOPREWARM_FILE, "r");
302  if (!file)
303  {
304  if (errno == ENOENT)
305  {
309  return; /* No file to load. */
310  }
311  ereport(ERROR,
313  errmsg("could not read file \"%s\": %m",
314  AUTOPREWARM_FILE)));
315  }
316 
317  /* First line of the file is a record count. */
318  if (fscanf(file, "<<%d>>\n", &num_elements) != 1)
319  ereport(ERROR,
321  errmsg("could not read from file \"%s\": %m",
322  AUTOPREWARM_FILE)));
323 
324  /* Allocate a dynamic shared memory segment to store the record data. */
325  seg = dsm_create(sizeof(BlockInfoRecord) * num_elements, 0);
326  blkinfo = (BlockInfoRecord *) dsm_segment_address(seg);
327 
328  /* Read records, one per line. */
329  for (i = 0; i < num_elements; i++)
330  {
331  unsigned forknum;
332 
333  if (fscanf(file, "%u,%u,%u,%u,%u\n", &blkinfo[i].database,
334  &blkinfo[i].tablespace, &blkinfo[i].filenode,
335  &forknum, &blkinfo[i].blocknum) != 5)
336  ereport(ERROR,
337  (errmsg("autoprewarm block dump file is corrupted at line %d",
338  i + 1)));
339  blkinfo[i].forknum = forknum;
340  }
341 
342  FreeFile(file);
343 
344  /* Sort the blocks to be loaded. */
345  pg_qsort(blkinfo, num_elements, sizeof(BlockInfoRecord),
347 
348  /* Populate shared memory state. */
352 
353  /* Get the info position of the first block of the next database. */
354  while (apw_state->prewarm_start_idx < num_elements)
355  {
356  int j = apw_state->prewarm_start_idx;
357  Oid current_db = blkinfo[j].database;
358 
359  /*
360  * Advance the prewarm_stop_idx to the first BlockInfoRecord that does
361  * not belong to this database.
362  */
363  j++;
364  while (j < num_elements)
365  {
366  if (current_db != blkinfo[j].database)
367  {
368  /*
369  * Combine BlockInfoRecords for global objects with those of
370  * the database.
371  */
372  if (current_db != InvalidOid)
373  break;
374  current_db = blkinfo[j].database;
375  }
376 
377  j++;
378  }
379 
380  /*
381  * If we reach this point with current_db == InvalidOid, then only
382  * BlockInfoRecords belonging to global objects exist. We can't
383  * prewarm without a database connection, so just bail out.
384  */
385  if (current_db == InvalidOid)
386  break;
387 
388  /* Configure stop point and database for next per-database worker. */
390  apw_state->database = current_db;
392 
393  /* If we've run out of free buffers, don't launch another worker. */
394  if (!have_free_buffer())
395  break;
396 
397  /*
398  * Start a per-database worker to load blocks for this database; this
399  * function will return once the per-database worker exits.
400  */
402 
403  /* Prepare for next database. */
405  }
406 
407  /* Clean up. */
408  dsm_detach(seg);
413 
414  /* Report our success. */
415  ereport(LOG,
416  (errmsg("autoprewarm successfully prewarmed %d of %d previously-loaded blocks",
417  apw_state->prewarmed_blocks, num_elements)));
418 }
int MyProcPid
Definition: globals.c:40
dsm_handle dsm_segment_handle(dsm_segment *seg)
Definition: dsm.c:1082
#define LOG
Definition: elog.h:26
unsigned int Oid
Definition: postgres_ext.h:31
void LWLockRelease(LWLock *lock)
Definition: lwlock.c:1812
#define DSM_HANDLE_INVALID
Definition: dsm.h:23
#define AUTOPREWARM_FILE
Definition: autoprewarm.c:56
ForkNumber forknum
Definition: autoprewarm.c:64
#define ERROR
Definition: elog.h:43
static AutoPrewarmSharedState * apw_state
Definition: autoprewarm.c:105
static void apw_start_database_worker(void)
Definition: autoprewarm.c:835
char * tablespace
Definition: pgbench.c:189
int errcode_for_file_access(void)
Definition: elog.c:633
dsm_handle block_info_handle
Definition: autoprewarm.c:76
FILE * AllocateFile(const char *name, const char *mode)
Definition: fd.c:2322
dsm_segment * dsm_create(Size size, int flags)
Definition: dsm.c:487
bool have_free_buffer(void)
Definition: freelist.c:180
#define InvalidOid
Definition: postgres_ext.h:36
#define ereport(elevel,...)
Definition: elog.h:144
void * dsm_segment_address(dsm_segment *seg)
Definition: dsm.c:1054
#define Assert(condition)
Definition: c.h:745
void pg_qsort(void *base, size_t nel, size_t elsize, int(*cmp)(const void *, const void *))
Definition: qsort.c:113
bool LWLockAcquire(LWLock *lock, LWLockMode mode)
Definition: lwlock.c:1208
int FreeFile(FILE *file)
Definition: fd.c:2521
void dsm_detach(dsm_segment *seg)
Definition: dsm.c:769
int errmsg(const char *fmt,...)
Definition: elog.c:824
int i
static int apw_compare_blockinfo(const void *p, const void *q)
Definition: autoprewarm.c:885
#define InvalidPid
Definition: miscadmin.h:32

◆ apw_sighup_handler()

static void apw_sighup_handler ( SIGNAL_ARGS  )
static

Definition at line 919 of file autoprewarm.c.

References got_sighup, MyProc, PGPROC::procLatch, and SetLatch().

Referenced by autoprewarm_main().

920 {
921  int save_errno = errno;
922 
923  got_sighup = true;
924 
925  if (MyProc)
927 
928  errno = save_errno;
929 }
PGPROC * MyProc
Definition: proc.c:67
void SetLatch(Latch *latch)
Definition: latch.c:505
Latch procLatch
Definition: proc.h:121
static volatile sig_atomic_t got_sighup
Definition: autoprewarm.c:102

◆ apw_sigterm_handler()

static void apw_sigterm_handler ( SIGNAL_ARGS  )
static

Definition at line 903 of file autoprewarm.c.

References got_sigterm, MyProc, PGPROC::procLatch, and SetLatch().

Referenced by autoprewarm_main().

904 {
905  int save_errno = errno;
906 
907  got_sigterm = true;
908 
909  if (MyProc)
911 
912  errno = save_errno;
913 }
static volatile sig_atomic_t got_sigterm
Definition: autoprewarm.c:101
PGPROC * MyProc
Definition: proc.c:67
void SetLatch(Latch *latch)
Definition: latch.c:505
Latch procLatch
Definition: proc.h:121

◆ apw_start_database_worker()

static void apw_start_database_worker ( void  )
static

Definition at line 835 of file autoprewarm.c.

References BackgroundWorker::bgw_flags, BackgroundWorker::bgw_function_name, BackgroundWorker::bgw_library_name, BackgroundWorker::bgw_name, BGW_NEVER_RESTART, BackgroundWorker::bgw_notify_pid, BackgroundWorker::bgw_restart_time, BackgroundWorker::bgw_start_time, BackgroundWorker::bgw_type, BGWORKER_BACKEND_DATABASE_CONNECTION, BGWORKER_SHMEM_ACCESS, BgWorkerStart_ConsistentState, ereport, errcode(), errhint(), errmsg(), ERROR, MemSet, MyProcPid, RegisterDynamicBackgroundWorker(), and WaitForBackgroundWorkerShutdown().

Referenced by apw_load_buffers().

836 {
837  BackgroundWorker worker;
838  BackgroundWorkerHandle *handle;
839 
840  MemSet(&worker, 0, sizeof(BackgroundWorker));
841  worker.bgw_flags =
845  strcpy(worker.bgw_library_name, "pg_prewarm");
846  strcpy(worker.bgw_function_name, "autoprewarm_database_main");
847  strcpy(worker.bgw_name, "autoprewarm worker");
848  strcpy(worker.bgw_type, "autoprewarm worker");
849 
850  /* must set notify PID to wait for shutdown */
851  worker.bgw_notify_pid = MyProcPid;
852 
853  if (!RegisterDynamicBackgroundWorker(&worker, &handle))
854  ereport(ERROR,
855  (errcode(ERRCODE_INSUFFICIENT_RESOURCES),
856  errmsg("registering dynamic bgworker autoprewarm failed"),
857  errhint("Consider increasing configuration parameter \"max_worker_processes\".")));
858 
859  /*
860  * Ignore return value; if it fails, postmaster has died, but we have
861  * checks for that elsewhere.
862  */
864 }
int MyProcPid
Definition: globals.c:40
int errhint(const char *fmt,...)
Definition: elog.c:1071
int bgw_restart_time
Definition: bgworker.h:94
int errcode(int sqlerrcode)
Definition: elog.c:610
#define MemSet(start, val, len)
Definition: c.h:949
#define BGWORKER_SHMEM_ACCESS
Definition: bgworker.h:52
char bgw_function_name[BGW_MAXLEN]
Definition: bgworker.h:96
#define ERROR
Definition: elog.h:43
BgwHandleStatus WaitForBackgroundWorkerShutdown(BackgroundWorkerHandle *handle)
Definition: bgworker.c:1124
#define BGW_NEVER_RESTART
Definition: bgworker.h:84
#define ereport(elevel,...)
Definition: elog.h:144
char bgw_name[BGW_MAXLEN]
Definition: bgworker.h:90
#define BGWORKER_BACKEND_DATABASE_CONNECTION
Definition: bgworker.h:59
BgWorkerStartTime bgw_start_time
Definition: bgworker.h:93
bool RegisterDynamicBackgroundWorker(BackgroundWorker *worker, BackgroundWorkerHandle **handle)
Definition: bgworker.c:918
char bgw_type[BGW_MAXLEN]
Definition: bgworker.h:91
int errmsg(const char *fmt,...)
Definition: elog.c:824
pid_t bgw_notify_pid
Definition: bgworker.h:99
char bgw_library_name[BGW_MAXLEN]
Definition: bgworker.h:95

◆ apw_start_leader_worker()

static void apw_start_leader_worker ( void  )
static

Definition at line 793 of file autoprewarm.c.

References BackgroundWorker::bgw_flags, BackgroundWorker::bgw_function_name, BackgroundWorker::bgw_library_name, BackgroundWorker::bgw_name, BackgroundWorker::bgw_notify_pid, BackgroundWorker::bgw_start_time, BackgroundWorker::bgw_type, BGWH_STARTED, BGWORKER_SHMEM_ACCESS, BgWorkerStart_ConsistentState, ereport, errcode(), errhint(), errmsg(), ERROR, MemSet, MyProcPid, process_shared_preload_libraries_in_progress, RegisterBackgroundWorker(), RegisterDynamicBackgroundWorker(), status(), and WaitForBackgroundWorkerStartup().

Referenced by _PG_init(), and autoprewarm_start_worker().

794 {
795  BackgroundWorker worker;
796  BackgroundWorkerHandle *handle;
798  pid_t pid;
799 
800  MemSet(&worker, 0, sizeof(BackgroundWorker));
803  strcpy(worker.bgw_library_name, "pg_prewarm");
804  strcpy(worker.bgw_function_name, "autoprewarm_main");
805  strcpy(worker.bgw_name, "autoprewarm leader");
806  strcpy(worker.bgw_type, "autoprewarm leader");
807 
809  {
810  RegisterBackgroundWorker(&worker);
811  return;
812  }
813 
814  /* must set notify PID to wait for startup */
815  worker.bgw_notify_pid = MyProcPid;
816 
817  if (!RegisterDynamicBackgroundWorker(&worker, &handle))
818  ereport(ERROR,
819  (errcode(ERRCODE_INSUFFICIENT_RESOURCES),
820  errmsg("could not register background process"),
821  errhint("You may need to increase max_worker_processes.")));
822 
823  status = WaitForBackgroundWorkerStartup(handle, &pid);
824  if (status != BGWH_STARTED)
825  ereport(ERROR,
826  (errcode(ERRCODE_INSUFFICIENT_RESOURCES),
827  errmsg("could not start background process"),
828  errhint("More details may be available in the server log.")));
829 }
BgwHandleStatus WaitForBackgroundWorkerStartup(BackgroundWorkerHandle *handle, pid_t *pidp)
Definition: bgworker.c:1082
void RegisterBackgroundWorker(BackgroundWorker *worker)
Definition: bgworker.c:834
int MyProcPid
Definition: globals.c:40
int errhint(const char *fmt,...)
Definition: elog.c:1071
bool process_shared_preload_libraries_in_progress
Definition: miscinit.c:1596
int errcode(int sqlerrcode)
Definition: elog.c:610
#define MemSet(start, val, len)
Definition: c.h:949
#define BGWORKER_SHMEM_ACCESS
Definition: bgworker.h:52
char bgw_function_name[BGW_MAXLEN]
Definition: bgworker.h:96
#define ERROR
Definition: elog.h:43
BgwHandleStatus
Definition: bgworker.h:102
#define ereport(elevel,...)
Definition: elog.h:144
char bgw_name[BGW_MAXLEN]
Definition: bgworker.h:90
BgWorkerStartTime bgw_start_time
Definition: bgworker.h:93
bool RegisterDynamicBackgroundWorker(BackgroundWorker *worker, BackgroundWorkerHandle **handle)
Definition: bgworker.c:918
char bgw_type[BGW_MAXLEN]
Definition: bgworker.h:91
int errmsg(const char *fmt,...)
Definition: elog.c:824
pid_t bgw_notify_pid
Definition: bgworker.h:99
static void static void status(const char *fmt,...) pg_attribute_printf(1
Definition: pg_regress.c:227
char bgw_library_name[BGW_MAXLEN]
Definition: bgworker.h:95

◆ autoprewarm_database_main()

void autoprewarm_database_main ( Datum  main_arg)

Definition at line 425 of file autoprewarm.c.

References AccessShareLock, apw_init_shmem(), Assert, BackgroundWorkerInitializeConnectionByOid(), BackgroundWorkerUnblockSignals(), AutoPrewarmSharedState::block_info_handle, BlockInfoRecord::blocknum, buf, BufferIsValid, CHECK_FOR_INTERRUPTS, CommitTransactionCommand(), BlockInfoRecord::database, AutoPrewarmSharedState::database, die, dsm_attach(), dsm_detach(), dsm_segment_address(), ereport, errcode(), errmsg(), ERROR, BlockInfoRecord::filenode, BlockInfoRecord::forknum, have_free_buffer(), InvalidForkNumber, InvalidOid, MAX_FORKNUM, OidIsValid, pqsignal(), AutoPrewarmSharedState::prewarm_start_idx, AutoPrewarmSharedState::prewarmed_blocks, RBM_NORMAL, RelationData::rd_smgr, ReadBufferExtended(), relation_close(), RelationGetNumberOfBlocksInFork(), RelationOpenSmgr, ReleaseBuffer(), RelidByRelfilenode(), smgrexists(), StartTransactionCommand(), BlockInfoRecord::tablespace, and try_relation_open().

426 {
427  int pos;
428  BlockInfoRecord *block_info;
429  Relation rel = NULL;
430  BlockNumber nblocks = 0;
431  BlockInfoRecord *old_blk = NULL;
432  dsm_segment *seg;
433 
434  /* Establish signal handlers; once that's done, unblock signals. */
435  pqsignal(SIGTERM, die);
437 
438  /* Connect to correct database and get block information. */
439  apw_init_shmem();
441  if (seg == NULL)
442  ereport(ERROR,
443  (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
444  errmsg("could not map dynamic shared memory segment")));
446  block_info = (BlockInfoRecord *) dsm_segment_address(seg);
448 
449  /*
450  * Loop until we run out of blocks to prewarm or until we run out of free
451  * buffers.
452  */
453  while (pos < apw_state->prewarm_stop_idx && have_free_buffer())
454  {
455  BlockInfoRecord *blk = &block_info[pos++];
456  Buffer buf;
457 
459 
460  /*
461  * Quit if we've reached records for another database. If previous
462  * blocks are of some global objects, then continue pre-warming.
463  */
464  if (old_blk != NULL && old_blk->database != blk->database &&
465  old_blk->database != 0)
466  break;
467 
468  /*
469  * As soon as we encounter a block of a new relation, close the old
470  * relation. Note that rel will be NULL if try_relation_open failed
471  * previously; in that case, there is nothing to close.
472  */
473  if (old_blk != NULL && old_blk->filenode != blk->filenode &&
474  rel != NULL)
475  {
477  rel = NULL;
479  }
480 
481  /*
482  * Try to open each new relation, but only once, when we first
483  * encounter it. If it's been dropped, skip the associated blocks.
484  */
485  if (old_blk == NULL || old_blk->filenode != blk->filenode)
486  {
487  Oid reloid;
488 
489  Assert(rel == NULL);
491  reloid = RelidByRelfilenode(blk->tablespace, blk->filenode);
492  if (OidIsValid(reloid))
493  rel = try_relation_open(reloid, AccessShareLock);
494 
495  if (!rel)
497  }
498  if (!rel)
499  {
500  old_blk = blk;
501  continue;
502  }
503 
504  /* Once per fork, check for fork existence and size. */
505  if (old_blk == NULL ||
506  old_blk->filenode != blk->filenode ||
507  old_blk->forknum != blk->forknum)
508  {
509  RelationOpenSmgr(rel);
510 
511  /*
512  * smgrexists is not safe for illegal forknum, hence check whether
513  * the passed forknum is valid before using it in smgrexists.
514  */
515  if (blk->forknum > InvalidForkNumber &&
516  blk->forknum <= MAX_FORKNUM &&
517  smgrexists(rel->rd_smgr, blk->forknum))
518  nblocks = RelationGetNumberOfBlocksInFork(rel, blk->forknum);
519  else
520  nblocks = 0;
521  }
522 
523  /* Check whether blocknum is valid and within fork file size. */
524  if (blk->blocknum >= nblocks)
525  {
526  /* Move to next forknum. */
527  old_blk = blk;
528  continue;
529  }
530 
531  /* Prewarm buffer. */
532  buf = ReadBufferExtended(rel, blk->forknum, blk->blocknum, RBM_NORMAL,
533  NULL);
534  if (BufferIsValid(buf))
535  {
537  ReleaseBuffer(buf);
538  }
539 
540  old_blk = blk;
541  }
542 
543  dsm_detach(seg);
544 
545  /* Release lock on previous relation. */
546  if (rel)
547  {
550  }
551 }
struct SMgrRelationData * rd_smgr
Definition: rel.h:57
void CommitTransactionCommand(void)
Definition: xact.c:2947
Buffer ReadBufferExtended(Relation reln, ForkNumber forkNum, BlockNumber blockNum, ReadBufferMode mode, BufferAccessStrategy strategy)
Definition: bufmgr.c:653
dsm_segment * dsm_attach(dsm_handle h)
Definition: dsm.c:631
Oid RelidByRelfilenode(Oid reltablespace, Oid relfilenode)
#define AccessShareLock
Definition: lockdefs.h:36
int errcode(int sqlerrcode)
Definition: elog.c:610
uint32 BlockNumber
Definition: block.h:31
void ReleaseBuffer(Buffer buffer)
Definition: bufmgr.c:3511
bool smgrexists(SMgrRelation reln, ForkNumber forknum)
Definition: smgr.c:248
unsigned int Oid
Definition: postgres_ext.h:31
#define OidIsValid(objectId)
Definition: c.h:651
Relation try_relation_open(Oid relationId, LOCKMODE lockmode)
Definition: relation.c:89
#define RelationOpenSmgr(relation)
Definition: rel.h:513
ForkNumber forknum
Definition: autoprewarm.c:64
#define ERROR
Definition: elog.h:43
static AutoPrewarmSharedState * apw_state
Definition: autoprewarm.c:105
static char * buf
Definition: pg_test_fsync.c:67
dsm_handle block_info_handle
Definition: autoprewarm.c:76
static bool apw_init_shmem(void)
Definition: autoprewarm.c:753
bool have_free_buffer(void)
Definition: freelist.c:180
void BackgroundWorkerInitializeConnectionByOid(Oid dboid, Oid useroid, uint32 flags)
Definition: postmaster.c:5759
#define InvalidOid
Definition: postgres_ext.h:36
#define ereport(elevel,...)
Definition: elog.h:144
pqsigfunc pqsignal(int signum, pqsigfunc handler)
Definition: signal.c:170
BlockNumber RelationGetNumberOfBlocksInFork(Relation relation, ForkNumber forkNum)
Definition: bufmgr.c:2848
void * dsm_segment_address(dsm_segment *seg)
Definition: dsm.c:1054
void relation_close(Relation relation, LOCKMODE lockmode)
Definition: relation.c:206
#define Assert(condition)
Definition: c.h:745
void StartTransactionCommand(void)
Definition: xact.c:2846
#define MAX_FORKNUM
Definition: relpath.h:55
#define BufferIsValid(bufnum)
Definition: bufmgr.h:123
BlockNumber blocknum
Definition: autoprewarm.c:65
void dsm_detach(dsm_segment *seg)
Definition: dsm.c:769
int errmsg(const char *fmt,...)
Definition: elog.c:824
#define CHECK_FOR_INTERRUPTS()
Definition: miscadmin.h:99
int Buffer
Definition: buf.h:23
#define die(msg)
Definition: pg_test_fsync.c:96
void BackgroundWorkerUnblockSignals(void)
Definition: postmaster.c:5788

◆ autoprewarm_dump_now()

Datum autoprewarm_dump_now ( PG_FUNCTION_ARGS  )

Definition at line 732 of file autoprewarm.c.

References apw_detach_shmem(), apw_dump_now(), apw_init_shmem(), PG_END_ENSURE_ERROR_CLEANUP, PG_ENSURE_ERROR_CLEANUP, and PG_RETURN_INT64.

733 {
734  int num_blocks;
735 
736  apw_init_shmem();
737 
739  {
740  num_blocks = apw_dump_now(false, true);
741  }
743 
744  PG_RETURN_INT64((int64) num_blocks);
745 }
#define PG_RETURN_INT64(x)
Definition: fmgr.h:366
static int apw_dump_now(bool is_bgworker, bool dump_unlogged)
Definition: autoprewarm.c:560
#define PG_ENSURE_ERROR_CLEANUP(cleanup_function, arg)
Definition: ipc.h:47
static bool apw_init_shmem(void)
Definition: autoprewarm.c:753
#define PG_END_ENSURE_ERROR_CLEANUP(cleanup_function, arg)
Definition: ipc.h:52
static void apw_detach_shmem(int code, Datum arg)
Definition: autoprewarm.c:779

◆ autoprewarm_main()

void autoprewarm_main ( Datum  main_arg)

Definition at line 158 of file autoprewarm.c.

References apw_detach_shmem(), apw_dump_now(), apw_init_shmem(), apw_load_buffers(), apw_sighup_handler(), apw_sigterm_handler(), autoprewarm_interval, BackgroundWorkerUnblockSignals(), AutoPrewarmSharedState::bgworker_pid, ereport, errmsg(), GetCurrentTimestamp(), got_sighup, got_sigterm, InvalidPid, AutoPrewarmSharedState::lock, LOG, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), MyProc, MyProcPid, on_shmem_exit(), PG_WAIT_EXTENSION, PGC_SIGHUP, pqsignal(), ProcessConfigFile(), PGPROC::procLatch, procsignal_sigusr1_handler(), ResetLatch(), SIGHUP, SIGUSR1, TimestampDifference(), TimestampTzPlusMilliseconds, WaitLatch(), WL_EXIT_ON_PM_DEATH, WL_LATCH_SET, and WL_TIMEOUT.

159 {
160  bool first_time = true;
161  TimestampTz last_dump_time = 0;
162 
163  /* Establish signal handlers; once that's done, unblock signals. */
164  pqsignal(SIGTERM, apw_sigterm_handler);
168 
169  /* Create (if necessary) and attach to our shared memory area. */
170  if (apw_init_shmem())
171  first_time = false;
172 
173  /* Set on-detach hook so that our PID will be cleared on exit. */
175 
176  /*
177  * Store our PID in the shared memory area --- unless there's already
178  * another worker running, in which case just exit.
179  */
182  {
184  ereport(LOG,
185  (errmsg("autoprewarm worker is already running under PID %lu",
186  (unsigned long) apw_state->bgworker_pid)));
187  return;
188  }
191 
192  /*
193  * Preload buffers from the dump file only if we just created the shared
194  * memory region. Otherwise, it's either already been done or shouldn't
195  * be done - e.g. because the old dump file has been overwritten since the
196  * server was started.
197  *
198  * There's not much point in performing a dump immediately after we finish
199  * preloading; so, if we do end up preloading, consider the last dump time
200  * to be equal to the current time.
201  */
202  if (first_time)
203  {
205  last_dump_time = GetCurrentTimestamp();
206  }
207 
208  /* Periodically dump buffers until terminated. */
209  while (!got_sigterm)
210  {
211  /* In case of a SIGHUP, just reload the configuration. */
212  if (got_sighup)
213  {
214  got_sighup = false;
216  }
217 
218  if (autoprewarm_interval <= 0)
219  {
220  /* We're only dumping at shutdown, so just wait forever. */
221  (void) WaitLatch(&MyProc->procLatch,
223  -1L,
225  }
226  else
227  {
228  long delay_in_ms = 0;
229  TimestampTz next_dump_time = 0;
230  long secs = 0;
231  int usecs = 0;
232 
233  /* Compute the next dump time. */
234  next_dump_time =
235  TimestampTzPlusMilliseconds(last_dump_time,
236  autoprewarm_interval * 1000);
237  TimestampDifference(GetCurrentTimestamp(), next_dump_time,
238  &secs, &usecs);
239  delay_in_ms = secs + (usecs / 1000);
240 
241  /* Perform a dump if it's time. */
242  if (delay_in_ms <= 0)
243  {
244  last_dump_time = GetCurrentTimestamp();
245  apw_dump_now(true, false);
246  continue;
247  }
248 
249  /* Sleep until the next dump time. */
250  (void) WaitLatch(&MyProc->procLatch,
252  delay_in_ms,
254  }
255 
256  /* Reset the latch, loop. */
258  }
259 
260  /*
261  * Dump one last time. We assume this is probably the result of a system
262  * shutdown, although it's possible that we've merely been terminated.
263  */
264  apw_dump_now(true, true);
265 }
static void apw_sigterm_handler(SIGNAL_ARGS)
Definition: autoprewarm.c:903
int MyProcPid
Definition: globals.c:40
static volatile sig_atomic_t got_sigterm
Definition: autoprewarm.c:101
#define WL_TIMEOUT
Definition: latch.h:127
void ProcessConfigFile(GucContext context)
#define SIGUSR1
Definition: win32_port.h:165
TimestampTz GetCurrentTimestamp(void)
Definition: timestamp.c:1574
PGPROC * MyProc
Definition: proc.c:67
int64 TimestampTz
Definition: timestamp.h:39
static int autoprewarm_interval
Definition: autoprewarm.c:109
#define LOG
Definition: elog.h:26
static int apw_dump_now(bool is_bgworker, bool dump_unlogged)
Definition: autoprewarm.c:560
void ResetLatch(Latch *latch)
Definition: latch.c:588
Latch procLatch
Definition: proc.h:121
int WaitLatch(Latch *latch, int wakeEvents, long timeout, uint32 wait_event_info)
Definition: latch.c:390
void LWLockRelease(LWLock *lock)
Definition: lwlock.c:1812
static AutoPrewarmSharedState * apw_state
Definition: autoprewarm.c:105
void on_shmem_exit(pg_on_exit_callback function, Datum arg)
Definition: ipc.c:361
#define SIGHUP
Definition: win32_port.h:153
static bool apw_init_shmem(void)
Definition: autoprewarm.c:753
Definition: guc.h:72
#define PG_WAIT_EXTENSION
Definition: pgstat.h:789
#define TimestampTzPlusMilliseconds(tz, ms)
Definition: timestamp.h:56
#define ereport(elevel,...)
Definition: elog.h:144
static void apw_sighup_handler(SIGNAL_ARGS)
Definition: autoprewarm.c:919
pqsigfunc pqsignal(int signum, pqsigfunc handler)
Definition: signal.c:170
bool LWLockAcquire(LWLock *lock, LWLockMode mode)
Definition: lwlock.c:1208
static volatile sig_atomic_t got_sighup
Definition: autoprewarm.c:102
int errmsg(const char *fmt,...)
Definition: elog.c:824
static void apw_detach_shmem(int code, Datum arg)
Definition: autoprewarm.c:779
static void apw_load_buffers(void)
Definition: autoprewarm.c:272
void procsignal_sigusr1_handler(SIGNAL_ARGS)
Definition: procsignal.c:551
void TimestampDifference(TimestampTz start_time, TimestampTz stop_time, long *secs, int *microsecs)
Definition: timestamp.c:1648
#define WL_LATCH_SET
Definition: latch.h:124
#define WL_EXIT_ON_PM_DEATH
Definition: latch.h:129
#define InvalidPid
Definition: miscadmin.h:32
void BackgroundWorkerUnblockSignals(void)
Definition: postmaster.c:5788

◆ autoprewarm_start_worker()

Datum autoprewarm_start_worker ( PG_FUNCTION_ARGS  )

Definition at line 700 of file autoprewarm.c.

References apw_init_shmem(), apw_start_leader_worker(), autoprewarm, AutoPrewarmSharedState::bgworker_pid, ereport, errcode(), errmsg(), ERROR, InvalidPid, AutoPrewarmSharedState::lock, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), and PG_RETURN_VOID.

701 {
702  pid_t pid;
703 
704  if (!autoprewarm)
705  ereport(ERROR,
706  (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
707  errmsg("autoprewarm is disabled")));
708 
709  apw_init_shmem();
711  pid = apw_state->bgworker_pid;
713 
714  if (pid != InvalidPid)
715  ereport(ERROR,
716  (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
717  errmsg("autoprewarm worker is already running under PID %lu",
718  (unsigned long) pid)));
719 
721 
722  PG_RETURN_VOID();
723 }
int errcode(int sqlerrcode)
Definition: elog.c:610
void LWLockRelease(LWLock *lock)
Definition: lwlock.c:1812
#define ERROR
Definition: elog.h:43
static AutoPrewarmSharedState * apw_state
Definition: autoprewarm.c:105
static void apw_start_leader_worker(void)
Definition: autoprewarm.c:793
static bool apw_init_shmem(void)
Definition: autoprewarm.c:753
#define ereport(elevel,...)
Definition: elog.h:144
#define PG_RETURN_VOID()
Definition: fmgr.h:348
static bool autoprewarm
Definition: autoprewarm.c:108
bool LWLockAcquire(LWLock *lock, LWLockMode mode)
Definition: lwlock.c:1208
int errmsg(const char *fmt,...)
Definition: elog.c:824
#define InvalidPid
Definition: miscadmin.h:32

◆ PG_FUNCTION_INFO_V1() [1/2]

PG_FUNCTION_INFO_V1 ( autoprewarm_start_worker  )

◆ PG_FUNCTION_INFO_V1() [2/2]

PG_FUNCTION_INFO_V1 ( autoprewarm_dump_now  )

Variable Documentation

◆ apw_state

AutoPrewarmSharedState* apw_state = NULL
static

Definition at line 105 of file autoprewarm.c.

◆ autoprewarm

bool autoprewarm = true
static

Definition at line 108 of file autoprewarm.c.

Referenced by _PG_init(), and autoprewarm_start_worker().

◆ autoprewarm_interval

int autoprewarm_interval
static

Definition at line 109 of file autoprewarm.c.

Referenced by _PG_init(), and autoprewarm_main().

◆ got_sighup

volatile sig_atomic_t got_sighup = false
static

◆ got_sigterm

volatile sig_atomic_t got_sigterm = false
static