PostgreSQL Source Code  git master
walsummarizer.h File Reference
#include "access/xlogdefs.h"
Include dependency graph for walsummarizer.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

Size WalSummarizerShmemSize (void)
 
void WalSummarizerShmemInit (void)
 
void WalSummarizerMain (char *startup_data, size_t startup_data_len) pg_attribute_noreturn()
 
void GetWalSummarizerState (TimeLineID *summarized_tli, XLogRecPtr *summarized_lsn, XLogRecPtr *pending_lsn, int *summarizer_pid)
 
XLogRecPtr GetOldestUnsummarizedLSN (TimeLineID *tli, bool *lsn_is_exact, bool reset_pending_lsn)
 
void SetWalSummarizerLatch (void)
 
XLogRecPtr WaitForWalSummarization (XLogRecPtr lsn, long timeout, XLogRecPtr *pending_lsn)
 

Variables

PGDLLIMPORT bool summarize_wal
 
PGDLLIMPORT int wal_summary_keep_time
 

Function Documentation

◆ GetOldestUnsummarizedLSN()

XLogRecPtr GetOldestUnsummarizedLSN ( TimeLineID tli,
bool lsn_is_exact,
bool  reset_pending_lsn 
)

Definition at line 494 of file walsummarizer.c.

496 {
497  TimeLineID latest_tli;
498  LWLockMode mode = reset_pending_lsn ? LW_EXCLUSIVE : LW_SHARED;
499  int n;
500  List *tles;
501  XLogRecPtr unsummarized_lsn = InvalidXLogRecPtr;
502  TimeLineID unsummarized_tli = 0;
503  bool should_make_exact = false;
504  List *existing_summaries;
505  ListCell *lc;
506 
507  /* If not summarizing WAL, do nothing. */
508  if (!summarize_wal)
509  return InvalidXLogRecPtr;
510 
511  /*
512  * Unless we need to reset the pending_lsn, we initially acquire the lock
513  * in shared mode and try to fetch the required information. If we acquire
514  * in shared mode and find that the data structure hasn't been
515  * initialized, we reacquire the lock in exclusive mode so that we can
516  * initialize it. However, if someone else does that first before we get
517  * the lock, then we can just return the requested information after all.
518  */
519  while (1)
520  {
521  LWLockAcquire(WALSummarizerLock, mode);
522 
524  {
525  unsummarized_lsn = WalSummarizerCtl->summarized_lsn;
526  if (tli != NULL)
528  if (lsn_is_exact != NULL)
529  *lsn_is_exact = WalSummarizerCtl->lsn_is_exact;
530  if (reset_pending_lsn)
533  LWLockRelease(WALSummarizerLock);
534  return unsummarized_lsn;
535  }
536 
537  if (mode == LW_EXCLUSIVE)
538  break;
539 
540  LWLockRelease(WALSummarizerLock);
541  mode = LW_EXCLUSIVE;
542  }
543 
544  /*
545  * The data structure needs to be initialized, and we are the first to
546  * obtain the lock in exclusive mode, so it's our job to do that
547  * initialization.
548  *
549  * So, find the oldest timeline on which WAL still exists, and the
550  * earliest segment for which it exists.
551  */
552  (void) GetLatestLSN(&latest_tli);
553  tles = readTimeLineHistory(latest_tli);
554  for (n = list_length(tles) - 1; n >= 0; --n)
555  {
556  TimeLineHistoryEntry *tle = list_nth(tles, n);
557  XLogSegNo oldest_segno;
558 
559  oldest_segno = XLogGetOldestSegno(tle->tli);
560  if (oldest_segno != 0)
561  {
562  /* Compute oldest LSN that still exists on disk. */
563  XLogSegNoOffsetToRecPtr(oldest_segno, 0, wal_segment_size,
564  unsummarized_lsn);
565 
566  unsummarized_tli = tle->tli;
567  break;
568  }
569  }
570 
571  /* It really should not be possible for us to find no WAL. */
572  if (unsummarized_tli == 0)
573  ereport(ERROR,
574  errcode(ERRCODE_INTERNAL_ERROR),
575  errmsg_internal("no WAL found on timeline %u", latest_tli));
576 
577  /*
578  * Don't try to summarize anything older than the end LSN of the newest
579  * summary file that exists for this timeline.
580  */
581  existing_summaries =
582  GetWalSummaries(unsummarized_tli,
584  foreach(lc, existing_summaries)
585  {
586  WalSummaryFile *ws = lfirst(lc);
587 
588  if (ws->end_lsn > unsummarized_lsn)
589  {
590  unsummarized_lsn = ws->end_lsn;
591  should_make_exact = true;
592  }
593  }
594 
595  /* Update shared memory with the discovered values. */
597  WalSummarizerCtl->summarized_lsn = unsummarized_lsn;
598  WalSummarizerCtl->summarized_tli = unsummarized_tli;
599  WalSummarizerCtl->lsn_is_exact = should_make_exact;
600  WalSummarizerCtl->pending_lsn = unsummarized_lsn;
601 
602  /* Also return the to the caller as required. */
603  if (tli != NULL)
605  if (lsn_is_exact != NULL)
606  *lsn_is_exact = WalSummarizerCtl->lsn_is_exact;
607  LWLockRelease(WALSummarizerLock);
608 
609  return unsummarized_lsn;
610 }
List * readTimeLineHistory(TimeLineID targetTLI)
Definition: timeline.c:76
int errmsg_internal(const char *fmt,...)
Definition: elog.c:1157
int errcode(int sqlerrcode)
Definition: elog.c:857
#define ERROR
Definition: elog.h:39
#define ereport(elevel,...)
Definition: elog.h:149
bool LWLockAcquire(LWLock *lock, LWLockMode mode)
Definition: lwlock.c:1170
void LWLockRelease(LWLock *lock)
Definition: lwlock.c:1783
LWLockMode
Definition: lwlock.h:113
@ LW_SHARED
Definition: lwlock.h:115
@ LW_EXCLUSIVE
Definition: lwlock.h:114
static PgChecksumMode mode
Definition: pg_checksums.c:56
#define lfirst(lc)
Definition: pg_list.h:172
static int list_length(const List *l)
Definition: pg_list.h:152
static void * list_nth(const List *list, int n)
Definition: pg_list.h:299
Definition: pg_list.h:54
TimeLineID tli
Definition: timeline.h:27
XLogRecPtr summarized_lsn
Definition: walsummarizer.c:84
TimeLineID summarized_tli
Definition: walsummarizer.c:83
XLogRecPtr pending_lsn
Definition: walsummarizer.c:87
XLogRecPtr end_lsn
Definition: walsummary.h:30
static XLogRecPtr GetLatestLSN(TimeLineID *tli)
static WalSummarizerData * WalSummarizerCtl
bool summarize_wal
List * GetWalSummaries(TimeLineID tli, XLogRecPtr start_lsn, XLogRecPtr end_lsn)
Definition: walsummary.c:43
int wal_segment_size
Definition: xlog.c:143
XLogSegNo XLogGetOldestSegno(TimeLineID tli)
Definition: xlog.c:3763
#define XLogSegNoOffsetToRecPtr(segno, offset, wal_segsz_bytes, dest)
uint64 XLogRecPtr
Definition: xlogdefs.h:21
#define InvalidXLogRecPtr
Definition: xlogdefs.h:28
uint32 TimeLineID
Definition: xlogdefs.h:59
uint64 XLogSegNo
Definition: xlogdefs.h:48

References WalSummaryFile::end_lsn, ereport, errcode(), errmsg_internal(), ERROR, GetLatestLSN(), GetWalSummaries(), WalSummarizerData::initialized, InvalidXLogRecPtr, lfirst, list_length(), list_nth(), WalSummarizerData::lsn_is_exact, LW_EXCLUSIVE, LW_SHARED, LWLockAcquire(), LWLockRelease(), mode, WalSummarizerData::pending_lsn, readTimeLineHistory(), summarize_wal, WalSummarizerData::summarized_lsn, WalSummarizerData::summarized_tli, TimeLineHistoryEntry::tli, wal_segment_size, WalSummarizerCtl, XLogGetOldestSegno(), and XLogSegNoOffsetToRecPtr.

Referenced by KeepLogSeg(), and WalSummarizerMain().

◆ GetWalSummarizerState()

void GetWalSummarizerState ( TimeLineID summarized_tli,
XLogRecPtr summarized_lsn,
XLogRecPtr pending_lsn,
int *  summarizer_pid 
)

Definition at line 433 of file walsummarizer.c.

435 {
436  LWLockAcquire(WALSummarizerLock, LW_SHARED);
438  {
439  /*
440  * If initialized is false, the rest of the structure contents are
441  * undefined.
442  */
443  *summarized_tli = 0;
444  *summarized_lsn = InvalidXLogRecPtr;
445  *pending_lsn = InvalidXLogRecPtr;
446  *summarizer_pid = -1;
447  }
448  else
449  {
450  int summarizer_pgprocno = WalSummarizerCtl->summarizer_pgprocno;
451 
452  *summarized_tli = WalSummarizerCtl->summarized_tli;
453  *summarized_lsn = WalSummarizerCtl->summarized_lsn;
454  if (summarizer_pgprocno == INVALID_PROC_NUMBER)
455  {
456  /*
457  * If the summarizer has exited, the fact that it had processed
458  * beyond summarized_lsn is irrelevant now.
459  */
460  *pending_lsn = WalSummarizerCtl->summarized_lsn;
461  *summarizer_pid = -1;
462  }
463  else
464  {
465  *pending_lsn = WalSummarizerCtl->pending_lsn;
466 
467  /*
468  * We're not fussed about inexact answers here, since they could
469  * become stale instantly, so we don't bother taking the lock, but
470  * make sure that invalid PID values are normalized to -1.
471  */
472  *summarizer_pid = GetPGProcByNumber(summarizer_pgprocno)->pid;
473  if (*summarizer_pid <= 0)
474  *summarizer_pid = -1;
475  }
476  }
477  LWLockRelease(WALSummarizerLock);
478 }
#define GetPGProcByNumber(n)
Definition: proc.h:428
#define INVALID_PROC_NUMBER
Definition: procnumber.h:26
ProcNumber summarizer_pgprocno
Definition: walsummarizer.c:86

References GetPGProcByNumber, WalSummarizerData::initialized, INVALID_PROC_NUMBER, InvalidXLogRecPtr, LW_SHARED, LWLockAcquire(), LWLockRelease(), WalSummarizerData::pending_lsn, WalSummarizerData::summarized_lsn, WalSummarizerData::summarized_tli, WalSummarizerData::summarizer_pgprocno, and WalSummarizerCtl.

Referenced by pg_get_wal_summarizer_state().

◆ SetWalSummarizerLatch()

void SetWalSummarizerLatch ( void  )

Definition at line 621 of file walsummarizer.c.

622 {
623  ProcNumber pgprocno;
624 
625  if (WalSummarizerCtl == NULL)
626  return;
627 
628  LWLockAcquire(WALSummarizerLock, LW_EXCLUSIVE);
630  LWLockRelease(WALSummarizerLock);
631 
632  if (pgprocno != INVALID_PROC_NUMBER)
633  SetLatch(&ProcGlobal->allProcs[pgprocno].procLatch);
634 }
void SetLatch(Latch *latch)
Definition: latch.c:632
int ProcNumber
Definition: procnumber.h:24
PROC_HDR * ProcGlobal
Definition: proc.c:78
Latch procLatch
Definition: proc.h:165
PGPROC * allProcs
Definition: proc.h:380

References PROC_HDR::allProcs, INVALID_PROC_NUMBER, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), ProcGlobal, PGPROC::procLatch, SetLatch(), WalSummarizerData::summarizer_pgprocno, and WalSummarizerCtl.

Referenced by CreateCheckPoint().

◆ WaitForWalSummarization()

XLogRecPtr WaitForWalSummarization ( XLogRecPtr  lsn,
long  timeout,
XLogRecPtr pending_lsn 
)

Definition at line 646 of file walsummarizer.c.

647 {
650  XLogRecPtr summarized_lsn;
651 
653  Assert(timeout > 0);
654 
655  while (1)
656  {
658  long remaining_timeout;
659 
660  /*
661  * If the LSN summarized on disk has reached the target value, stop.
662  */
663  LWLockAcquire(WALSummarizerLock, LW_EXCLUSIVE);
664  summarized_lsn = WalSummarizerCtl->summarized_lsn;
665  *pending_lsn = WalSummarizerCtl->pending_lsn;
666  LWLockRelease(WALSummarizerLock);
667  if (summarized_lsn >= lsn)
668  break;
669 
670  /* Timeout reached? If yes, stop. */
672  remaining_timeout = TimestampDifferenceMilliseconds(now, deadline);
673  if (remaining_timeout <= 0)
674  break;
675 
676  /* Wait and see. */
678  remaining_timeout,
679  WAIT_EVENT_WAL_SUMMARY_READY);
680  }
681 
682  return summarized_lsn;
683 }
long TimestampDifferenceMilliseconds(TimestampTz start_time, TimestampTz stop_time)
Definition: timestamp.c:1766
TimestampTz GetCurrentTimestamp(void)
Definition: timestamp.c:1654
Datum now(PG_FUNCTION_ARGS)
Definition: timestamp.c:1618
#define Assert(condition)
Definition: c.h:858
bool ConditionVariableTimedSleep(ConditionVariable *cv, long timeout, uint32 wait_event_info)
int64 TimestampTz
Definition: timestamp.h:39
static time_t start_time
Definition: pg_ctl.c:94
ConditionVariable summary_file_cv
Definition: walsummarizer.c:92
#define TimestampTzPlusMilliseconds(tz, ms)
Definition: timestamp.h:85
#define XLogRecPtrIsInvalid(r)
Definition: xlogdefs.h:29

References Assert, ConditionVariableTimedSleep(), GetCurrentTimestamp(), LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), now(), WalSummarizerData::pending_lsn, start_time, WalSummarizerData::summarized_lsn, WalSummarizerData::summary_file_cv, TimestampDifferenceMilliseconds(), TimestampTzPlusMilliseconds, WalSummarizerCtl, and XLogRecPtrIsInvalid.

Referenced by PrepareForIncrementalBackup().

◆ WalSummarizerMain()

void WalSummarizerMain ( char *  startup_data,
size_t  startup_data_len 
)

Definition at line 210 of file walsummarizer.c.

211 {
212  sigjmp_buf local_sigjmp_buf;
214 
215  /*
216  * Within this function, 'current_lsn' and 'current_tli' refer to the
217  * point from which the next WAL summary file should start. 'exact' is
218  * true if 'current_lsn' is known to be the start of a WAL record or WAL
219  * segment, and false if it might be in the middle of a record someplace.
220  *
221  * 'switch_lsn' and 'switch_tli', if set, are the LSN at which we need to
222  * switch to a new timeline and the timeline to which we need to switch.
223  * If not set, we either haven't figured out the answers yet or we're
224  * already on the latest timeline.
225  */
226  XLogRecPtr current_lsn;
227  TimeLineID current_tli;
228  bool exact;
229  XLogRecPtr switch_lsn = InvalidXLogRecPtr;
230  TimeLineID switch_tli = 0;
231 
232  Assert(startup_data_len == 0);
233 
236 
237  ereport(DEBUG1,
238  (errmsg_internal("WAL summarizer started")));
239 
240  /*
241  * Properly accept or ignore signals the postmaster might send us
242  *
243  * We have no particular use for SIGINT at the moment, but seems
244  * reasonable to treat like SIGTERM.
245  */
249  /* SIGQUIT handler was already set up by InitPostmasterChild */
253  pqsignal(SIGUSR2, SIG_IGN); /* not used */
254 
255  /* Advertise ourselves. */
257  LWLockAcquire(WALSummarizerLock, LW_EXCLUSIVE);
259  LWLockRelease(WALSummarizerLock);
260 
261  /* Create and switch to a memory context that we can reset on error. */
263  "Wal Summarizer",
266 
267  /*
268  * Reset some signals that are accepted by postmaster but not here
269  */
271 
272  /*
273  * If an exception is encountered, processing resumes here.
274  */
275  if (sigsetjmp(local_sigjmp_buf, 1) != 0)
276  {
277  /* Since not using PG_TRY, must reset error stack by hand */
278  error_context_stack = NULL;
279 
280  /* Prevent interrupts while cleaning up */
281  HOLD_INTERRUPTS();
282 
283  /* Report the error to the server log */
284  EmitErrorReport();
285 
286  /* Release resources we might have acquired. */
291  AtEOXact_Files(false);
292  AtEOXact_HashTables(false);
293 
294  /*
295  * Now return to normal top-level context and clear ErrorContext for
296  * next time.
297  */
299  FlushErrorState();
300 
301  /* Flush any leaked data in the top-level context */
303 
304  /* Now we can allow interrupts again */
306 
307  /*
308  * Sleep for 10 seconds before attempting to resume operations in
309  * order to avoid excessive logging.
310  *
311  * Many of the likely error conditions are things that will repeat
312  * every time. For example, if the WAL can't be read or the summary
313  * can't be written, only administrator action will cure the problem.
314  * So a really fast retry time doesn't seem to be especially
315  * beneficial, and it will clutter the logs.
316  */
317  (void) WaitLatch(MyLatch,
319  10000,
320  WAIT_EVENT_WAL_SUMMARIZER_ERROR);
321  }
322 
323  /* We can now handle ereport(ERROR) */
324  PG_exception_stack = &local_sigjmp_buf;
325 
326  /*
327  * Unblock signals (they were blocked when the postmaster forked us)
328  */
329  sigprocmask(SIG_SETMASK, &UnBlockSig, NULL);
330 
331  /*
332  * Fetch information about previous progress from shared memory, and ask
333  * GetOldestUnsummarizedLSN to reset pending_lsn to summarized_lsn. We
334  * might be recovering from an error, and if so, pending_lsn might have
335  * advanced past summarized_lsn, but any WAL we read previously has been
336  * lost and will need to be reread.
337  *
338  * If we discover that WAL summarization is not enabled, just exit.
339  */
340  current_lsn = GetOldestUnsummarizedLSN(&current_tli, &exact, true);
341  if (XLogRecPtrIsInvalid(current_lsn))
342  proc_exit(0);
343 
344  /*
345  * Loop forever
346  */
347  for (;;)
348  {
349  XLogRecPtr latest_lsn;
350  TimeLineID latest_tli;
351  XLogRecPtr end_of_summary_lsn;
352 
353  /* Flush any leaked data in the top-level context */
355 
356  /* Process any signals received recently. */
358 
359  /* If it's time to remove any old WAL summaries, do that now. */
361 
362  /* Find the LSN and TLI up to which we can safely summarize. */
363  latest_lsn = GetLatestLSN(&latest_tli);
364 
365  /*
366  * If we're summarizing a historic timeline and we haven't yet
367  * computed the point at which to switch to the next timeline, do that
368  * now.
369  *
370  * Note that if this is a standby, what was previously the current
371  * timeline could become historic at any time.
372  *
373  * We could try to make this more efficient by caching the results of
374  * readTimeLineHistory when latest_tli has not changed, but since we
375  * only have to do this once per timeline switch, we probably wouldn't
376  * save any significant amount of work in practice.
377  */
378  if (current_tli != latest_tli && XLogRecPtrIsInvalid(switch_lsn))
379  {
380  List *tles = readTimeLineHistory(latest_tli);
381 
382  switch_lsn = tliSwitchPoint(current_tli, tles, &switch_tli);
383  ereport(DEBUG1,
384  errmsg("switch point from TLI %u to TLI %u is at %X/%X",
385  current_tli, switch_tli, LSN_FORMAT_ARGS(switch_lsn)));
386  }
387 
388  /*
389  * If we've reached the switch LSN, we can't summarize anything else
390  * on this timeline. Switch to the next timeline and go around again.
391  */
392  if (!XLogRecPtrIsInvalid(switch_lsn) && current_lsn >= switch_lsn)
393  {
394  current_tli = switch_tli;
395  switch_lsn = InvalidXLogRecPtr;
396  switch_tli = 0;
397  continue;
398  }
399 
400  /* Summarize WAL. */
401  end_of_summary_lsn = SummarizeWAL(current_tli,
402  current_lsn, exact,
403  switch_lsn, latest_lsn);
404  Assert(!XLogRecPtrIsInvalid(end_of_summary_lsn));
405  Assert(end_of_summary_lsn >= current_lsn);
406 
407  /*
408  * Update state for next loop iteration.
409  *
410  * Next summary file should start from exactly where this one ended.
411  */
412  current_lsn = end_of_summary_lsn;
413  exact = true;
414 
415  /* Update state in shared memory. */
416  LWLockAcquire(WALSummarizerLock, LW_EXCLUSIVE);
417  Assert(WalSummarizerCtl->pending_lsn <= end_of_summary_lsn);
418  WalSummarizerCtl->summarized_lsn = end_of_summary_lsn;
419  WalSummarizerCtl->summarized_tli = current_tli;
421  WalSummarizerCtl->pending_lsn = end_of_summary_lsn;
422  LWLockRelease(WALSummarizerLock);
423 
424  /* Wake up anyone waiting for more summary files to be written. */
426  }
427 }
void AuxiliaryProcessMainCommon(void)
Definition: auxprocess.c:44
XLogRecPtr tliSwitchPoint(TimeLineID tli, List *history, TimeLineID *nextTLI)
Definition: timeline.c:572
sigset_t UnBlockSig
Definition: pqsignal.c:22
bool ConditionVariableCancelSleep(void)
void ConditionVariableBroadcast(ConditionVariable *cv)
void AtEOXact_HashTables(bool isCommit)
Definition: dynahash.c:1869
void EmitErrorReport(void)
Definition: elog.c:1670
ErrorContextCallback * error_context_stack
Definition: elog.c:94
void FlushErrorState(void)
Definition: elog.c:1834
int errmsg(const char *fmt,...)
Definition: elog.c:1070
sigjmp_buf * PG_exception_stack
Definition: elog.c:96
#define DEBUG1
Definition: elog.h:30
void AtEOXact_Files(bool isCommit)
Definition: fd.c:3165
ProcNumber MyProcNumber
Definition: globals.c:87
struct Latch * MyLatch
Definition: globals.c:60
void SignalHandlerForShutdownRequest(SIGNAL_ARGS)
Definition: interrupt.c:105
void SignalHandlerForConfigReload(SIGNAL_ARGS)
Definition: interrupt.c:61
void on_shmem_exit(pg_on_exit_callback function, Datum arg)
Definition: ipc.c:365
void proc_exit(int code)
Definition: ipc.c:104
int WaitLatch(Latch *latch, int wakeEvents, long timeout, uint32 wait_event_info)
Definition: latch.c:517
#define WL_TIMEOUT
Definition: latch.h:130
#define WL_EXIT_ON_PM_DEATH
Definition: latch.h:132
void LWLockReleaseAll(void)
Definition: lwlock.c:1878
void MemoryContextReset(MemoryContext context)
Definition: mcxt.c:383
MemoryContext TopMemoryContext
Definition: mcxt.c:149
#define AllocSetContextCreate
Definition: memutils.h:129
#define ALLOCSET_DEFAULT_SIZES
Definition: memutils.h:160
#define RESUME_INTERRUPTS()
Definition: miscadmin.h:135
#define HOLD_INTERRUPTS()
Definition: miscadmin.h:133
@ B_WAL_SUMMARIZER
Definition: miscadmin.h:360
BackendType MyBackendType
Definition: miscinit.c:63
pqsigfunc pqsignal(int signo, pqsigfunc func)
uintptr_t Datum
Definition: postgres.h:64
void procsignal_sigusr1_handler(SIGNAL_ARGS)
Definition: procsignal.c:635
tree context
Definition: radixtree.h:1833
MemoryContextSwitchTo(old_ctx)
void ReleaseAuxProcessResources(bool isCommit)
Definition: resowner.c:1002
static void pgstat_report_wait_end(void)
Definition: wait_event.h:98
XLogRecPtr GetOldestUnsummarizedLSN(TimeLineID *tli, bool *lsn_is_exact, bool reset_pending_lsn)
static XLogRecPtr SummarizeWAL(TimeLineID tli, XLogRecPtr start_lsn, bool exact, XLogRecPtr switch_lsn, XLogRecPtr maximum_lsn)
static void HandleWalSummarizerInterrupts(void)
static void WalSummarizerShutdown(int code, Datum arg)
static void MaybeRemoveOldWalSummaries(void)
#define SIGCHLD
Definition: win32_port.h:178
#define SIGHUP
Definition: win32_port.h:168
#define SIG_DFL
Definition: win32_port.h:163
#define SIGPIPE
Definition: win32_port.h:173
#define SIGUSR1
Definition: win32_port.h:180
#define SIGALRM
Definition: win32_port.h:174
#define SIGUSR2
Definition: win32_port.h:181
#define SIG_IGN
Definition: win32_port.h:165
#define LSN_FORMAT_ARGS(lsn)
Definition: xlogdefs.h:43

References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, Assert, AtEOXact_Files(), AtEOXact_HashTables(), AuxiliaryProcessMainCommon(), B_WAL_SUMMARIZER, ConditionVariableBroadcast(), ConditionVariableCancelSleep(), context, DEBUG1, EmitErrorReport(), ereport, errmsg(), errmsg_internal(), error_context_stack, FlushErrorState(), GetLatestLSN(), GetOldestUnsummarizedLSN(), HandleWalSummarizerInterrupts(), HOLD_INTERRUPTS, InvalidXLogRecPtr, LSN_FORMAT_ARGS, WalSummarizerData::lsn_is_exact, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), LWLockReleaseAll(), MaybeRemoveOldWalSummaries(), MemoryContextReset(), MemoryContextSwitchTo(), MyBackendType, MyLatch, MyProcNumber, on_shmem_exit(), WalSummarizerData::pending_lsn, PG_exception_stack, pgstat_report_wait_end(), pqsignal(), proc_exit(), procsignal_sigusr1_handler(), readTimeLineHistory(), ReleaseAuxProcessResources(), RESUME_INTERRUPTS, SIG_DFL, SIG_IGN, SIGALRM, SIGCHLD, SIGHUP, SignalHandlerForConfigReload(), SignalHandlerForShutdownRequest(), SIGPIPE, SIGUSR1, SIGUSR2, WalSummarizerData::summarized_lsn, WalSummarizerData::summarized_tli, WalSummarizerData::summarizer_pgprocno, SummarizeWAL(), WalSummarizerData::summary_file_cv, tliSwitchPoint(), TopMemoryContext, UnBlockSig, WaitLatch(), WalSummarizerCtl, WalSummarizerShutdown(), WL_EXIT_ON_PM_DEATH, WL_TIMEOUT, and XLogRecPtrIsInvalid.

◆ WalSummarizerShmemInit()

void WalSummarizerShmemInit ( void  )

Definition at line 179 of file walsummarizer.c.

180 {
181  bool found;
182 
184  ShmemInitStruct("Wal Summarizer Ctl", WalSummarizerShmemSize(),
185  &found);
186 
187  if (!found)
188  {
189  /*
190  * First time through, so initialize.
191  *
192  * We're just filling in dummy values here -- the real initialization
193  * will happen when GetOldestUnsummarizedLSN() is called for the first
194  * time.
195  */
196  WalSummarizerCtl->initialized = false;
203  }
204 }
void ConditionVariableInit(ConditionVariable *cv)
void * ShmemInitStruct(const char *name, Size size, bool *foundPtr)
Definition: shmem.c:387
Size WalSummarizerShmemSize(void)

References ConditionVariableInit(), WalSummarizerData::initialized, INVALID_PROC_NUMBER, InvalidXLogRecPtr, WalSummarizerData::lsn_is_exact, WalSummarizerData::pending_lsn, ShmemInitStruct(), WalSummarizerData::summarized_lsn, WalSummarizerData::summarized_tli, WalSummarizerData::summarizer_pgprocno, WalSummarizerData::summary_file_cv, WalSummarizerCtl, and WalSummarizerShmemSize().

Referenced by CreateOrAttachShmemStructs().

◆ WalSummarizerShmemSize()

Size WalSummarizerShmemSize ( void  )

Definition at line 170 of file walsummarizer.c.

171 {
172  return sizeof(WalSummarizerData);
173 }

Referenced by CalculateShmemSize(), and WalSummarizerShmemInit().

Variable Documentation

◆ summarize_wal

◆ wal_summary_keep_time

PGDLLIMPORT int wal_summary_keep_time
extern

Definition at line 143 of file walsummarizer.c.

Referenced by MaybeRemoveOldWalSummaries().