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/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_master_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 55 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 866 of file autoprewarm.c.

Referenced by apw_compare_blockinfo().

Typedef Documentation

◆ AutoPrewarmSharedState

◆ BlockInfoRecord

Function Documentation

◆ _PG_init()

void _PG_init ( void  )

Definition at line 114 of file autoprewarm.c.

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

115 {
116  DefineCustomIntVariable("pg_prewarm.autoprewarm_interval",
117  "Sets the interval between dumps of shared buffers",
118  "If set to zero, time-based dumping is disabled.",
120  300,
121  0, INT_MAX / 1000,
122  PGC_SIGHUP,
123  GUC_UNIT_S,
124  NULL,
125  NULL,
126  NULL);
127 
129  return;
130 
131  /* can't define PGC_POSTMASTER variable after startup */
132  DefineCustomBoolVariable("pg_prewarm.autoprewarm",
133  "Starts the autoprewarm worker.",
134  NULL,
135  &autoprewarm,
136  true,
138  0,
139  NULL,
140  NULL,
141  NULL);
142 
143  EmitWarningsOnPlaceholders("pg_prewarm");
144 
146 
147  /* Register autoprewarm worker, if enabled. */
148  if (autoprewarm)
150 }
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:8599
void RequestAddinShmemSpace(Size size)
Definition: ipci.c:70
bool process_shared_preload_libraries_in_progress
Definition: miscinit.c:1522
static int autoprewarm_interval
Definition: autoprewarm.c:108
#define GUC_UNIT_S
Definition: guc.h:226
void EmitWarningsOnPlaceholders(const char *className)
Definition: guc.c:8712
Definition: guc.h:72
static bool autoprewarm
Definition: autoprewarm.c:107
#define MAXALIGN(LEN)
Definition: c.h:685
static void apw_start_master_worker(void)
Definition: autoprewarm.c:792
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:8573

◆ apw_compare_blockinfo()

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

Definition at line 884 of file autoprewarm.c.

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

Referenced by apw_load_buffers().

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

◆ apw_detach_shmem()

static void apw_detach_shmem ( int  code,
Datum  arg 
)
static

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

779 {
786 }
int MyProcPid
Definition: globals.c:40
void LWLockRelease(LWLock *lock)
Definition: lwlock.c:1726
static AutoPrewarmSharedState * apw_state
Definition: autoprewarm.c:104
bool LWLockAcquire(LWLock *lock, LWLockMode mode)
Definition: lwlock.c:1122
#define InvalidPid
Definition: miscadmin.h:32

◆ apw_dump_now()

static int apw_dump_now ( bool  is_bgworker,
bool  dump_unlogged 
)
static

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

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

◆ apw_init_shmem()

static bool apw_init_shmem ( void  )
static

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

753 {
754  bool found;
755 
756  LWLockAcquire(AddinShmemInitLock, LW_EXCLUSIVE);
757  apw_state = ShmemInitStruct("autoprewarm",
758  sizeof(AutoPrewarmSharedState),
759  &found);
760  if (!found)
761  {
762  /* First time through ... */
766  }
767  LWLockRelease(AddinShmemInitLock);
768 
769  LWLockRegisterTranche(apw_state->lock.tranche, "autoprewarm");
770 
771  return found;
772 }
int LWLockNewTrancheId(void)
Definition: lwlock.c:583
void LWLockRegisterTranche(int tranche_id, const char *tranche_name)
Definition: lwlock.c:603
void LWLockRelease(LWLock *lock)
Definition: lwlock.c:1726
static AutoPrewarmSharedState * apw_state
Definition: autoprewarm.c:104
void * ShmemInitStruct(const char *name, Size size, bool *foundPtr)
Definition: shmem.c:372
uint16 tranche
Definition: lwlock.h:34
void LWLockInitialize(LWLock *lock, int tranche_id)
Definition: lwlock.c:678
bool LWLockAcquire(LWLock *lock, LWLockMode mode)
Definition: lwlock.c:1122
#define InvalidPid
Definition: miscadmin.h:32

◆ apw_load_buffers()

static void apw_load_buffers ( void  )
static

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

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

◆ apw_sighup_handler()

static void apw_sighup_handler ( SIGNAL_ARGS  )
static

Definition at line 918 of file autoprewarm.c.

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

Referenced by autoprewarm_main().

919 {
920  int save_errno = errno;
921 
922  got_sighup = true;
923 
924  if (MyProc)
926 
927  errno = save_errno;
928 }
PGPROC * MyProc
Definition: proc.c:68
void SetLatch(Latch *latch)
Definition: latch.c:436
Latch procLatch
Definition: proc.h:104
static volatile sig_atomic_t got_sighup
Definition: autoprewarm.c:101

◆ apw_sigterm_handler()

static void apw_sigterm_handler ( SIGNAL_ARGS  )
static

Definition at line 902 of file autoprewarm.c.

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

Referenced by autoprewarm_main().

903 {
904  int save_errno = errno;
905 
906  got_sigterm = true;
907 
908  if (MyProc)
910 
911  errno = save_errno;
912 }
static volatile sig_atomic_t got_sigterm
Definition: autoprewarm.c:100
PGPROC * MyProc
Definition: proc.c:68
void SetLatch(Latch *latch)
Definition: latch.c:436
Latch procLatch
Definition: proc.h:104

◆ apw_start_database_worker()

static void apw_start_database_worker ( void  )
static

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

835 {
836  BackgroundWorker worker;
837  BackgroundWorkerHandle *handle;
838 
839  MemSet(&worker, 0, sizeof(BackgroundWorker));
840  worker.bgw_flags =
844  strcpy(worker.bgw_library_name, "pg_prewarm");
845  strcpy(worker.bgw_function_name, "autoprewarm_database_main");
846  strcpy(worker.bgw_name, "autoprewarm worker");
847  strcpy(worker.bgw_type, "autoprewarm worker");
848 
849  /* must set notify PID to wait for shutdown */
850  worker.bgw_notify_pid = MyProcPid;
851 
852  if (!RegisterDynamicBackgroundWorker(&worker, &handle))
853  ereport(ERROR,
854  (errcode(ERRCODE_INSUFFICIENT_RESOURCES),
855  errmsg("registering dynamic bgworker autoprewarm failed"),
856  errhint("Consider increasing configuration parameter \"max_worker_processes\".")));
857 
858  /*
859  * Ignore return value; if it fails, postmaster has died, but we have
860  * checks for that elsewhere.
861  */
863 }
int MyProcPid
Definition: globals.c:40
int errhint(const char *fmt,...)
Definition: elog.c:974
int bgw_restart_time
Definition: bgworker.h:94
int errcode(int sqlerrcode)
Definition: elog.c:570
#define MemSet(start, val, len)
Definition: c.h:955
#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:1138
#define BGW_NEVER_RESTART
Definition: bgworker.h:84
#define ereport(elevel, rest)
Definition: elog.h:141
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:932
char bgw_type[BGW_MAXLEN]
Definition: bgworker.h:91
int errmsg(const char *fmt,...)
Definition: elog.c:784
pid_t bgw_notify_pid
Definition: bgworker.h:99
char bgw_library_name[BGW_MAXLEN]
Definition: bgworker.h:95

◆ apw_start_master_worker()

static void apw_start_master_worker ( void  )
static

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

793 {
794  BackgroundWorker worker;
795  BackgroundWorkerHandle *handle;
797  pid_t pid;
798 
799  MemSet(&worker, 0, sizeof(BackgroundWorker));
802  strcpy(worker.bgw_library_name, "pg_prewarm");
803  strcpy(worker.bgw_function_name, "autoprewarm_main");
804  strcpy(worker.bgw_name, "autoprewarm master");
805  strcpy(worker.bgw_type, "autoprewarm master");
806 
808  {
809  RegisterBackgroundWorker(&worker);
810  return;
811  }
812 
813  /* must set notify PID to wait for startup */
814  worker.bgw_notify_pid = MyProcPid;
815 
816  if (!RegisterDynamicBackgroundWorker(&worker, &handle))
817  ereport(ERROR,
818  (errcode(ERRCODE_INSUFFICIENT_RESOURCES),
819  errmsg("could not register background process"),
820  errhint("You may need to increase max_worker_processes.")));
821 
822  status = WaitForBackgroundWorkerStartup(handle, &pid);
823  if (status != BGWH_STARTED)
824  ereport(ERROR,
825  (errcode(ERRCODE_INSUFFICIENT_RESOURCES),
826  errmsg("could not start background process"),
827  errhint("More details may be available in the server log.")));
828 }
BgwHandleStatus WaitForBackgroundWorkerStartup(BackgroundWorkerHandle *handle, pid_t *pidp)
Definition: bgworker.c:1096
void RegisterBackgroundWorker(BackgroundWorker *worker)
Definition: bgworker.c:848
int MyProcPid
Definition: globals.c:40
int errhint(const char *fmt,...)
Definition: elog.c:974
bool process_shared_preload_libraries_in_progress
Definition: miscinit.c:1522
int errcode(int sqlerrcode)
Definition: elog.c:570
#define MemSet(start, val, len)
Definition: c.h:955
#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, rest)
Definition: elog.h:141
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:932
char bgw_type[BGW_MAXLEN]
Definition: bgworker.h:91
int errmsg(const char *fmt,...)
Definition: elog.c:784
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 424 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().

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

◆ autoprewarm_dump_now()

Datum autoprewarm_dump_now ( PG_FUNCTION_ARGS  )

Definition at line 731 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.

732 {
733  int num_blocks;
734 
735  apw_init_shmem();
736 
738  {
739  num_blocks = apw_dump_now(false, true);
740  }
742 
743  PG_RETURN_INT64((int64) num_blocks);
744 }
#define PG_RETURN_INT64(x)
Definition: fmgr.h:357
static int apw_dump_now(bool is_bgworker, bool dump_unlogged)
Definition: autoprewarm.c:559
#define PG_ENSURE_ERROR_CLEANUP(cleanup_function, arg)
Definition: ipc.h:47
static bool apw_init_shmem(void)
Definition: autoprewarm.c:752
#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:778

◆ autoprewarm_main()

void autoprewarm_main ( Datum  main_arg)

Definition at line 157 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.

158 {
159  bool first_time = true;
160  TimestampTz last_dump_time = 0;
161 
162  /* Establish signal handlers; once that's done, unblock signals. */
163  pqsignal(SIGTERM, apw_sigterm_handler);
167 
168  /* Create (if necessary) and attach to our shared memory area. */
169  if (apw_init_shmem())
170  first_time = false;
171 
172  /* Set on-detach hook so that our PID will be cleared on exit. */
174 
175  /*
176  * Store our PID in the shared memory area --- unless there's already
177  * another worker running, in which case just exit.
178  */
181  {
183  ereport(LOG,
184  (errmsg("autoprewarm worker is already running under PID %lu",
185  (unsigned long) apw_state->bgworker_pid)));
186  return;
187  }
190 
191  /*
192  * Preload buffers from the dump file only if we just created the shared
193  * memory region. Otherwise, it's either already been done or shouldn't
194  * be done - e.g. because the old dump file has been overwritten since the
195  * server was started.
196  *
197  * There's not much point in performing a dump immediately after we finish
198  * preloading; so, if we do end up preloading, consider the last dump time
199  * to be equal to the current time.
200  */
201  if (first_time)
202  {
204  last_dump_time = GetCurrentTimestamp();
205  }
206 
207  /* Periodically dump buffers until terminated. */
208  while (!got_sigterm)
209  {
210  /* In case of a SIGHUP, just reload the configuration. */
211  if (got_sighup)
212  {
213  got_sighup = false;
215  }
216 
217  if (autoprewarm_interval <= 0)
218  {
219  /* We're only dumping at shutdown, so just wait forever. */
220  (void) WaitLatch(&MyProc->procLatch,
222  -1L,
224  }
225  else
226  {
227  long delay_in_ms = 0;
228  TimestampTz next_dump_time = 0;
229  long secs = 0;
230  int usecs = 0;
231 
232  /* Compute the next dump time. */
233  next_dump_time =
234  TimestampTzPlusMilliseconds(last_dump_time,
235  autoprewarm_interval * 1000);
236  TimestampDifference(GetCurrentTimestamp(), next_dump_time,
237  &secs, &usecs);
238  delay_in_ms = secs + (usecs / 1000);
239 
240  /* Perform a dump if it's time. */
241  if (delay_in_ms <= 0)
242  {
243  last_dump_time = GetCurrentTimestamp();
244  apw_dump_now(true, false);
245  continue;
246  }
247 
248  /* Sleep until the next dump time. */
249  (void) WaitLatch(&MyProc->procLatch,
251  delay_in_ms,
253  }
254 
255  /* Reset the latch, loop. */
257  }
258 
259  /*
260  * Dump one last time. We assume this is probably the result of a system
261  * shutdown, although it's possible that we've merely been terminated.
262  */
263  apw_dump_now(true, true);
264 }
static void apw_sigterm_handler(SIGNAL_ARGS)
Definition: autoprewarm.c:902
int MyProcPid
Definition: globals.c:40
static volatile sig_atomic_t got_sigterm
Definition: autoprewarm.c:100
#define WL_TIMEOUT
Definition: latch.h:127
void ProcessConfigFile(GucContext context)
#define SIGUSR1
Definition: win32_port.h:175
TimestampTz GetCurrentTimestamp(void)
Definition: timestamp.c:1569
PGPROC * MyProc
Definition: proc.c:68
int64 TimestampTz
Definition: timestamp.h:39
static int autoprewarm_interval
Definition: autoprewarm.c:108
#define LOG
Definition: elog.h:26
static int apw_dump_now(bool is_bgworker, bool dump_unlogged)
Definition: autoprewarm.c:559
void ResetLatch(Latch *latch)
Definition: latch.c:519
Latch procLatch
Definition: proc.h:104
int WaitLatch(Latch *latch, int wakeEvents, long timeout, uint32 wait_event_info)
Definition: latch.c:344
void LWLockRelease(LWLock *lock)
Definition: lwlock.c:1726
static AutoPrewarmSharedState * apw_state
Definition: autoprewarm.c:104
void on_shmem_exit(pg_on_exit_callback function, Datum arg)
Definition: ipc.c:361
#define SIGHUP
Definition: win32_port.h:163
static bool apw_init_shmem(void)
Definition: autoprewarm.c:752
#define ereport(elevel, rest)
Definition: elog.h:141
Definition: guc.h:72
#define PG_WAIT_EXTENSION
Definition: pgstat.h:759
#define TimestampTzPlusMilliseconds(tz, ms)
Definition: timestamp.h:56
static void apw_sighup_handler(SIGNAL_ARGS)
Definition: autoprewarm.c:918
pqsigfunc pqsignal(int signum, pqsigfunc handler)
Definition: signal.c:170
bool LWLockAcquire(LWLock *lock, LWLockMode mode)
Definition: lwlock.c:1122
static volatile sig_atomic_t got_sighup
Definition: autoprewarm.c:101
int errmsg(const char *fmt,...)
Definition: elog.c:784
static void apw_detach_shmem(int code, Datum arg)
Definition: autoprewarm.c:778
static void apw_load_buffers(void)
Definition: autoprewarm.c:271
void procsignal_sigusr1_handler(SIGNAL_ARGS)
Definition: procsignal.c:261
void TimestampDifference(TimestampTz start_time, TimestampTz stop_time, long *secs, int *microsecs)
Definition: timestamp.c:1643
#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:5662

◆ autoprewarm_start_worker()

Datum autoprewarm_start_worker ( PG_FUNCTION_ARGS  )

Definition at line 699 of file autoprewarm.c.

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

700 {
701  pid_t pid;
702 
703  if (!autoprewarm)
704  ereport(ERROR,
705  (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
706  errmsg("autoprewarm is disabled")));
707 
708  apw_init_shmem();
710  pid = apw_state->bgworker_pid;
712 
713  if (pid != InvalidPid)
714  ereport(ERROR,
715  (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
716  errmsg("autoprewarm worker is already running under PID %lu",
717  (unsigned long) pid)));
718 
720 
721  PG_RETURN_VOID();
722 }
int errcode(int sqlerrcode)
Definition: elog.c:570
void LWLockRelease(LWLock *lock)
Definition: lwlock.c:1726
#define ERROR
Definition: elog.h:43
static AutoPrewarmSharedState * apw_state
Definition: autoprewarm.c:104
static bool apw_init_shmem(void)
Definition: autoprewarm.c:752
#define ereport(elevel, rest)
Definition: elog.h:141
#define PG_RETURN_VOID()
Definition: fmgr.h:339
static bool autoprewarm
Definition: autoprewarm.c:107
bool LWLockAcquire(LWLock *lock, LWLockMode mode)
Definition: lwlock.c:1122
static void apw_start_master_worker(void)
Definition: autoprewarm.c:792
int errmsg(const char *fmt,...)
Definition: elog.c:784
#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 104 of file autoprewarm.c.

◆ autoprewarm

bool autoprewarm = true
static

Definition at line 107 of file autoprewarm.c.

Referenced by _PG_init(), and autoprewarm_start_worker().

◆ autoprewarm_interval

int autoprewarm_interval
static

Definition at line 108 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