PostgreSQL Source Code  git master
xlogfuncs.c
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * xlogfuncs.c
4  *
5  * PostgreSQL write-ahead log manager user interface functions
6  *
7  * This file contains WAL control and information functions.
8  *
9  *
10  * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
11  * Portions Copyright (c) 1994, Regents of the University of California
12  *
13  * src/backend/access/transam/xlogfuncs.c
14  *
15  *-------------------------------------------------------------------------
16  */
17 #include "postgres.h"
18 
19 #include <unistd.h>
20 
21 #include "access/htup_details.h"
22 #include "access/xlog_internal.h"
23 #include "access/xlogrecovery.h"
24 #include "access/xlogutils.h"
25 #include "catalog/pg_type.h"
26 #include "funcapi.h"
27 #include "miscadmin.h"
28 #include "pgstat.h"
30 #include "storage/fd.h"
31 #include "storage/ipc.h"
32 #include "storage/smgr.h"
33 #include "utils/builtins.h"
34 #include "utils/guc.h"
35 #include "utils/memutils.h"
36 #include "utils/numeric.h"
37 #include "utils/pg_lsn.h"
38 #include "utils/timestamp.h"
39 #include "utils/tuplestore.h"
40 
41 /*
42  * Store label file and tablespace map during backups.
43  */
46 
47 /*
48  * pg_backup_start: set up for taking an on-line backup dump
49  *
50  * Essentially what this does is to create a backup label file in $PGDATA,
51  * where it will be archived as part of the backup dump. The label file
52  * contains the user-supplied label string (typically this would be used
53  * to tell where the backup dump will be stored) and the starting time and
54  * starting WAL location for the dump.
55  *
56  * Permission checking for this function is managed through the normal
57  * GRANT system.
58  */
59 Datum
61 {
62  text *backupid = PG_GETARG_TEXT_PP(0);
63  bool fast = PG_GETARG_BOOL(1);
64  char *backupidstr;
65  XLogRecPtr startpoint;
67  MemoryContext oldcontext;
68 
69  backupidstr = text_to_cstring(backupid);
70 
72  ereport(ERROR,
73  (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
74  errmsg("a backup is already in progress in this session")));
75 
76  /*
77  * Label file and tablespace map file need to be long-lived, since they
78  * are read in pg_backup_stop.
79  */
83  MemoryContextSwitchTo(oldcontext);
84 
86 
87  startpoint = do_pg_backup_start(backupidstr, fast, NULL, label_file,
88  NULL, tblspc_map_file);
89 
90  PG_RETURN_LSN(startpoint);
91 }
92 
93 
94 /*
95  * pg_backup_stop: finish taking an on-line backup.
96  *
97  * The first parameter (variable 'waitforarchive'), which is optional,
98  * allows the user to choose if they want to wait for the WAL to be archived
99  * or if we should just return as soon as the WAL record is written.
100  *
101  * Permission checking for this function is managed through the normal
102  * GRANT system.
103  */
104 Datum
106 {
107 #define PG_STOP_BACKUP_V2_COLS 3
108  TupleDesc tupdesc;
110  bool nulls[PG_STOP_BACKUP_V2_COLS];
111 
112  bool waitforarchive = PG_GETARG_BOOL(0);
113  XLogRecPtr stoppoint;
115 
116  /* Initialize attributes information in the tuple descriptor */
117  if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
118  elog(ERROR, "return type must be a row type");
119 
120  MemSet(values, 0, sizeof(values));
121  MemSet(nulls, 0, sizeof(nulls));
122 
124  ereport(ERROR,
125  (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
126  errmsg("backup is not in progress"),
127  errhint("Did you call pg_backup_start()?")));
128 
129  /*
130  * Stop the backup. Return a copy of the backup label and tablespace map
131  * so they can be written to disk by the caller.
132  */
133  stoppoint = do_pg_backup_stop(label_file->data, waitforarchive, NULL);
134 
135  values[0] = LSNGetDatum(stoppoint);
138 
139  /* Free structures allocated in TopMemoryContext */
141  pfree(label_file);
142  label_file = NULL;
145  tblspc_map_file = NULL;
146 
147  /* Returns the record as Datum */
149 }
150 
151 /*
152  * pg_switch_wal: switch to next xlog file
153  *
154  * Permission checking for this function is managed through the normal
155  * GRANT system.
156  */
157 Datum
159 {
160  XLogRecPtr switchpoint;
161 
162  if (RecoveryInProgress())
163  ereport(ERROR,
164  (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
165  errmsg("recovery is in progress"),
166  errhint("WAL control functions cannot be executed during recovery.")));
167 
168  switchpoint = RequestXLogSwitch(false);
169 
170  /*
171  * As a convenience, return the WAL location of the switch record
172  */
173  PG_RETURN_LSN(switchpoint);
174 }
175 
176 /*
177  * pg_create_restore_point: a named point for restore
178  *
179  * Permission checking for this function is managed through the normal
180  * GRANT system.
181  */
182 Datum
184 {
185  text *restore_name = PG_GETARG_TEXT_PP(0);
186  char *restore_name_str;
187  XLogRecPtr restorepoint;
188 
189  if (RecoveryInProgress())
190  ereport(ERROR,
191  (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
192  errmsg("recovery is in progress"),
193  errhint("WAL control functions cannot be executed during recovery.")));
194 
195  if (!XLogIsNeeded())
196  ereport(ERROR,
197  (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
198  errmsg("WAL level not sufficient for creating a restore point"),
199  errhint("wal_level must be set to \"replica\" or \"logical\" at server start.")));
200 
201  restore_name_str = text_to_cstring(restore_name);
202 
203  if (strlen(restore_name_str) >= MAXFNAMELEN)
204  ereport(ERROR,
205  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
206  errmsg("value too long for restore point (maximum %d characters)", MAXFNAMELEN - 1)));
207 
208  restorepoint = XLogRestorePoint(restore_name_str);
209 
210  /*
211  * As a convenience, return the WAL location of the restore point record
212  */
213  PG_RETURN_LSN(restorepoint);
214 }
215 
216 /*
217  * Report the current WAL write location (same format as pg_backup_start etc)
218  *
219  * This is useful for determining how much of WAL is visible to an external
220  * archiving process. Note that the data before this point is written out
221  * to the kernel, but is not necessarily synced to disk.
222  */
223 Datum
225 {
226  XLogRecPtr current_recptr;
227 
228  if (RecoveryInProgress())
229  ereport(ERROR,
230  (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
231  errmsg("recovery is in progress"),
232  errhint("WAL control functions cannot be executed during recovery.")));
233 
234  current_recptr = GetXLogWriteRecPtr();
235 
236  PG_RETURN_LSN(current_recptr);
237 }
238 
239 /*
240  * Report the current WAL insert location (same format as pg_backup_start etc)
241  *
242  * This function is mostly for debugging purposes.
243  */
244 Datum
246 {
247  XLogRecPtr current_recptr;
248 
249  if (RecoveryInProgress())
250  ereport(ERROR,
251  (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
252  errmsg("recovery is in progress"),
253  errhint("WAL control functions cannot be executed during recovery.")));
254 
255  current_recptr = GetXLogInsertRecPtr();
256 
257  PG_RETURN_LSN(current_recptr);
258 }
259 
260 /*
261  * Report the current WAL flush location (same format as pg_backup_start etc)
262  *
263  * This function is mostly for debugging purposes.
264  */
265 Datum
267 {
268  XLogRecPtr current_recptr;
269 
270  if (RecoveryInProgress())
271  ereport(ERROR,
272  (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
273  errmsg("recovery is in progress"),
274  errhint("WAL control functions cannot be executed during recovery.")));
275 
276  current_recptr = GetFlushRecPtr(NULL);
277 
278  PG_RETURN_LSN(current_recptr);
279 }
280 
281 /*
282  * Report the last WAL receive location (same format as pg_backup_start etc)
283  *
284  * This is useful for determining how much of WAL is guaranteed to be received
285  * and synced to disk by walreceiver.
286  */
287 Datum
289 {
290  XLogRecPtr recptr;
291 
292  recptr = GetWalRcvFlushRecPtr(NULL, NULL);
293 
294  if (recptr == 0)
295  PG_RETURN_NULL();
296 
297  PG_RETURN_LSN(recptr);
298 }
299 
300 /*
301  * Report the last WAL replay location (same format as pg_backup_start etc)
302  *
303  * This is useful for determining how much of WAL is visible to read-only
304  * connections during recovery.
305  */
306 Datum
308 {
309  XLogRecPtr recptr;
310 
311  recptr = GetXLogReplayRecPtr(NULL);
312 
313  if (recptr == 0)
314  PG_RETURN_NULL();
315 
316  PG_RETURN_LSN(recptr);
317 }
318 
319 /*
320  * Compute an xlog file name and decimal byte offset given a WAL location,
321  * such as is returned by pg_backup_stop() or pg_switch_wal().
322  *
323  * Note that a location exactly at a segment boundary is taken to be in
324  * the previous segment. This is usually the right thing, since the
325  * expected usage is to determine which xlog file(s) are ready to archive.
326  */
327 Datum
329 {
330  XLogSegNo xlogsegno;
331  uint32 xrecoff;
332  XLogRecPtr locationpoint = PG_GETARG_LSN(0);
333  char xlogfilename[MAXFNAMELEN];
334  Datum values[2];
335  bool isnull[2];
336  TupleDesc resultTupleDesc;
337  HeapTuple resultHeapTuple;
338  Datum result;
339 
340  if (RecoveryInProgress())
341  ereport(ERROR,
342  (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
343  errmsg("recovery is in progress"),
344  errhint("%s cannot be executed during recovery.",
345  "pg_walfile_name_offset()")));
346 
347  /*
348  * Construct a tuple descriptor for the result row. This must match this
349  * function's pg_proc entry!
350  */
351  resultTupleDesc = CreateTemplateTupleDesc(2);
352  TupleDescInitEntry(resultTupleDesc, (AttrNumber) 1, "file_name",
353  TEXTOID, -1, 0);
354  TupleDescInitEntry(resultTupleDesc, (AttrNumber) 2, "file_offset",
355  INT4OID, -1, 0);
356 
357  resultTupleDesc = BlessTupleDesc(resultTupleDesc);
358 
359  /*
360  * xlogfilename
361  */
362  XLByteToPrevSeg(locationpoint, xlogsegno, wal_segment_size);
363  XLogFileName(xlogfilename, GetWALInsertionTimeLine(), xlogsegno,
365 
366  values[0] = CStringGetTextDatum(xlogfilename);
367  isnull[0] = false;
368 
369  /*
370  * offset
371  */
372  xrecoff = XLogSegmentOffset(locationpoint, wal_segment_size);
373 
374  values[1] = UInt32GetDatum(xrecoff);
375  isnull[1] = false;
376 
377  /*
378  * Tuple jam: Having first prepared your Datums, then squash together
379  */
380  resultHeapTuple = heap_form_tuple(resultTupleDesc, values, isnull);
381 
382  result = HeapTupleGetDatum(resultHeapTuple);
383 
384  PG_RETURN_DATUM(result);
385 }
386 
387 /*
388  * Compute an xlog file name given a WAL location,
389  * such as is returned by pg_backup_stop() or pg_switch_wal().
390  */
391 Datum
393 {
394  XLogSegNo xlogsegno;
395  XLogRecPtr locationpoint = PG_GETARG_LSN(0);
396  char xlogfilename[MAXFNAMELEN];
397 
398  if (RecoveryInProgress())
399  ereport(ERROR,
400  (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
401  errmsg("recovery is in progress"),
402  errhint("%s cannot be executed during recovery.",
403  "pg_walfile_name()")));
404 
405  XLByteToPrevSeg(locationpoint, xlogsegno, wal_segment_size);
406  XLogFileName(xlogfilename, GetWALInsertionTimeLine(), xlogsegno,
408 
409  PG_RETURN_TEXT_P(cstring_to_text(xlogfilename));
410 }
411 
412 /*
413  * pg_wal_replay_pause - Request to pause recovery
414  *
415  * Permission checking for this function is managed through the normal
416  * GRANT system.
417  */
418 Datum
420 {
421  if (!RecoveryInProgress())
422  ereport(ERROR,
423  (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
424  errmsg("recovery is not in progress"),
425  errhint("Recovery control functions can only be executed during recovery.")));
426 
427  if (PromoteIsTriggered())
428  ereport(ERROR,
429  (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
430  errmsg("standby promotion is ongoing"),
431  errhint("%s cannot be executed after promotion is triggered.",
432  "pg_wal_replay_pause()")));
433 
434  SetRecoveryPause(true);
435 
436  /* wake up the recovery process so that it can process the pause request */
437  WakeupRecovery();
438 
439  PG_RETURN_VOID();
440 }
441 
442 /*
443  * pg_wal_replay_resume - resume recovery now
444  *
445  * Permission checking for this function is managed through the normal
446  * GRANT system.
447  */
448 Datum
450 {
451  if (!RecoveryInProgress())
452  ereport(ERROR,
453  (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
454  errmsg("recovery is not in progress"),
455  errhint("Recovery control functions can only be executed during recovery.")));
456 
457  if (PromoteIsTriggered())
458  ereport(ERROR,
459  (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
460  errmsg("standby promotion is ongoing"),
461  errhint("%s cannot be executed after promotion is triggered.",
462  "pg_wal_replay_resume()")));
463 
464  SetRecoveryPause(false);
465 
466  PG_RETURN_VOID();
467 }
468 
469 /*
470  * pg_is_wal_replay_paused
471  */
472 Datum
474 {
475  if (!RecoveryInProgress())
476  ereport(ERROR,
477  (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
478  errmsg("recovery is not in progress"),
479  errhint("Recovery control functions can only be executed during recovery.")));
480 
482 }
483 
484 /*
485  * pg_get_wal_replay_pause_state - Returns the recovery pause state.
486  *
487  * Returned values:
488  *
489  * 'not paused' - if pause is not requested
490  * 'pause requested' - if pause is requested but recovery is not yet paused
491  * 'paused' - if recovery is paused
492  */
493 Datum
495 {
496  char *statestr = NULL;
497 
498  if (!RecoveryInProgress())
499  ereport(ERROR,
500  (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
501  errmsg("recovery is not in progress"),
502  errhint("Recovery control functions can only be executed during recovery.")));
503 
504  /* get the recovery pause state */
505  switch (GetRecoveryPauseState())
506  {
507  case RECOVERY_NOT_PAUSED:
508  statestr = "not paused";
509  break;
511  statestr = "pause requested";
512  break;
513  case RECOVERY_PAUSED:
514  statestr = "paused";
515  break;
516  }
517 
518  Assert(statestr != NULL);
520 }
521 
522 /*
523  * Returns timestamp of latest processed commit/abort record.
524  *
525  * When the server has been started normally without recovery the function
526  * returns NULL.
527  */
528 Datum
530 {
531  TimestampTz xtime;
532 
533  xtime = GetLatestXTime();
534  if (xtime == 0)
535  PG_RETURN_NULL();
536 
537  PG_RETURN_TIMESTAMPTZ(xtime);
538 }
539 
540 /*
541  * Returns bool with current recovery mode, a global state.
542  */
543 Datum
545 {
547 }
548 
549 /*
550  * Compute the difference in bytes between two WAL locations.
551  */
552 Datum
554 {
555  Datum result;
556 
558  PG_GETARG_DATUM(0),
559  PG_GETARG_DATUM(1));
560 
561  PG_RETURN_NUMERIC(result);
562 }
563 
564 /*
565  * Promotes a standby server.
566  *
567  * A result of "true" means that promotion has been completed if "wait" is
568  * "true", or initiated if "wait" is false.
569  */
570 Datum
572 {
573  bool wait = PG_GETARG_BOOL(0);
574  int wait_seconds = PG_GETARG_INT32(1);
575  FILE *promote_file;
576  int i;
577 
578  if (!RecoveryInProgress())
579  ereport(ERROR,
580  (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
581  errmsg("recovery is not in progress"),
582  errhint("Recovery control functions can only be executed during recovery.")));
583 
584  if (wait_seconds <= 0)
585  ereport(ERROR,
586  (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
587  errmsg("\"wait_seconds\" must not be negative or zero")));
588 
589  /* create the promote signal file */
591  if (!promote_file)
592  ereport(ERROR,
594  errmsg("could not create file \"%s\": %m",
596 
597  if (FreeFile(promote_file))
598  ereport(ERROR,
600  errmsg("could not write file \"%s\": %m",
602 
603  /* signal the postmaster */
604  if (kill(PostmasterPid, SIGUSR1) != 0)
605  {
607  (errmsg("failed to send signal to postmaster: %m")));
608  (void) unlink(PROMOTE_SIGNAL_FILE);
609  PG_RETURN_BOOL(false);
610  }
611 
612  /* return immediately if waiting was not requested */
613  if (!wait)
614  PG_RETURN_BOOL(true);
615 
616  /* wait for the amount of time wanted until promotion */
617 #define WAITS_PER_SECOND 10
618  for (i = 0; i < WAITS_PER_SECOND * wait_seconds; i++)
619  {
620  int rc;
621 
623 
624  if (!RecoveryInProgress())
625  PG_RETURN_BOOL(true);
626 
628 
629  rc = WaitLatch(MyLatch,
631  1000L / WAITS_PER_SECOND,
633 
634  /*
635  * Emergency bailout if postmaster has died. This is to avoid the
636  * necessity for manual cleanup of all postmaster children.
637  */
638  if (rc & WL_POSTMASTER_DEATH)
639  PG_RETURN_BOOL(false);
640  }
641 
643  (errmsg_plural("server did not promote within %d second",
644  "server did not promote within %d seconds",
645  wait_seconds,
646  wait_seconds)));
647  PG_RETURN_BOOL(false);
648 }
int16 AttrNumber
Definition: attnum.h:21
static Datum values[MAXATTR]
Definition: bootstrap.c:156
#define CStringGetTextDatum(s)
Definition: builtins.h:85
unsigned int uint32
Definition: c.h:441
#define MemSet(start, val, len)
Definition: c.h:1008
int64 TimestampTz
Definition: timestamp.h:39
int errmsg_plural(const char *fmt_singular, const char *fmt_plural, unsigned long n,...)
Definition: elog.c:1014
int errcode_for_file_access(void)
Definition: elog.c:716
int errhint(const char *fmt,...)
Definition: elog.c:1151
int errcode(int sqlerrcode)
Definition: elog.c:693
int errmsg(const char *fmt,...)
Definition: elog.c:904
#define WARNING
Definition: elog.h:30
#define ERROR
Definition: elog.h:33
#define elog(elevel,...)
Definition: elog.h:218
#define ereport(elevel,...)
Definition: elog.h:143
TupleDesc BlessTupleDesc(TupleDesc tupdesc)
Definition: execTuples.c:2071
FILE * AllocateFile(const char *name, const char *mode)
Definition: fd.c:2461
int FreeFile(FILE *file)
Definition: fd.c:2660
#define PG_RETURN_VOID()
Definition: fmgr.h:349
#define PG_GETARG_TEXT_PP(n)
Definition: fmgr.h:309
#define DirectFunctionCall2(func, arg1, arg2)
Definition: fmgr.h:633
#define PG_GETARG_DATUM(n)
Definition: fmgr.h:268
#define PG_RETURN_NULL()
Definition: fmgr.h:345
#define PG_RETURN_TEXT_P(x)
Definition: fmgr.h:372
#define PG_GETARG_INT32(n)
Definition: fmgr.h:269
#define PG_GETARG_BOOL(n)
Definition: fmgr.h:274
#define PG_RETURN_DATUM(x)
Definition: fmgr.h:353
#define PG_FUNCTION_ARGS
Definition: fmgr.h:193
#define PG_RETURN_BOOL(x)
Definition: fmgr.h:359
TypeFuncClass get_call_result_type(FunctionCallInfo fcinfo, Oid *resultTypeId, TupleDesc *resultTupleDesc)
Definition: funcapi.c:276
@ TYPEFUNC_COMPOSITE
Definition: funcapi.h:149
#define HeapTupleGetDatum(tuple)
Definition: funcapi.h:220
pid_t PostmasterPid
Definition: globals.c:99
struct Latch * MyLatch
Definition: globals.c:58
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, Datum *values, bool *isnull)
Definition: heaptuple.c:1020
int i
Definition: isn.c:73
void ResetLatch(Latch *latch)
Definition: latch.c:658
int WaitLatch(Latch *latch, int wakeEvents, long timeout, uint32 wait_event_info)
Definition: latch.c:451
#define WL_TIMEOUT
Definition: latch.h:128
#define WL_LATCH_SET
Definition: latch.h:125
#define WL_POSTMASTER_DEATH
Definition: latch.h:129
Assert(fmt[strlen(fmt) - 1] !='\n')
void pfree(void *pointer)
Definition: mcxt.c:1175
MemoryContext TopMemoryContext
Definition: mcxt.c:48
#define CHECK_FOR_INTERRUPTS()
Definition: miscadmin.h:121
#define PG_RETURN_NUMERIC(x)
Definition: numeric.h:64
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
Definition: palloc.h:109
static char promote_file[MAXPGPATH]
Definition: pg_ctl.c:105
static int wait_seconds
Definition: pg_ctl.c:80
Datum pg_lsn_mi(PG_FUNCTION_ARGS)
Definition: pg_lsn.c:225
#define PG_GETARG_LSN(n)
Definition: pg_lsn.h:24
#define PG_RETURN_LSN(x)
Definition: pg_lsn.h:25
#define LSNGetDatum(X)
Definition: pg_lsn.h:22
static void static void status(const char *fmt,...) pg_attribute_printf(1
Definition: pg_regress.c:229
#define UInt32GetDatum(X)
Definition: postgres.h:537
uintptr_t Datum
Definition: postgres.h:411
StringInfo makeStringInfo(void)
Definition: stringinfo.c:41
Definition: c.h:622
TupleDesc CreateTemplateTupleDesc(int natts)
Definition: tupdesc.c:45
void TupleDescInitEntry(TupleDesc desc, AttrNumber attributeNumber, const char *attributeName, Oid oidtypeid, int32 typmod, int attdim)
Definition: tupdesc.c:583
#define PG_RETURN_TIMESTAMPTZ(x)
Definition: timestamp.h:40
char * text_to_cstring(const text *t)
Definition: varlena.c:221
text * cstring_to_text(const char *s)
Definition: varlena.c:188
@ WAIT_EVENT_PROMOTE
Definition: wait_event.h:119
XLogRecPtr GetWalRcvFlushRecPtr(XLogRecPtr *latestChunkStart, TimeLineID *receiveTLI)
#define kill(pid, sig)
Definition: win32_port.h:464
#define SIGUSR1
Definition: win32_port.h:179
XLogRecPtr do_pg_backup_start(const char *backupidstr, bool fast, TimeLineID *starttli_p, StringInfo labelfile, List **tablespaces, StringInfo tblspcmapfile)
Definition: xlog.c:8077
bool RecoveryInProgress(void)
Definition: xlog.c:5753
TimeLineID GetWALInsertionTimeLine(void)
Definition: xlog.c:5941
XLogRecPtr RequestXLogSwitch(bool mark_unimportant)
Definition: xlog.c:7357
SessionBackupState get_backup_status(void)
Definition: xlog.c:8419
int wal_segment_size
Definition: xlog.c:144
XLogRecPtr GetXLogInsertRecPtr(void)
Definition: xlog.c:8803
XLogRecPtr GetFlushRecPtr(TimeLineID *insertTLI)
Definition: xlog.c:5918
void register_persistent_abort_backup_handler(void)
Definition: xlog.c:8789
XLogRecPtr GetXLogWriteRecPtr(void)
Definition: xlog.c:8819
XLogRecPtr XLogRestorePoint(const char *rpName)
Definition: xlog.c:7375
XLogRecPtr do_pg_backup_stop(char *labelfile, bool waitforarchive, TimeLineID *stoptli_p)
Definition: xlog.c:8437
#define PROMOTE_SIGNAL_FILE
Definition: xlog.h:299
SessionBackupState
Definition: xlog.h:275
@ SESSION_BACKUP_RUNNING
Definition: xlog.h:277
#define XLogIsNeeded()
Definition: xlog.h:104
#define XLogSegmentOffset(xlogptr, wal_segsz_bytes)
#define XLogFileName(fname, tli, logSegNo, wal_segsz_bytes)
#define XLByteToPrevSeg(xlrp, logSegNo, wal_segsz_bytes)
#define MAXFNAMELEN
uint64 XLogRecPtr
Definition: xlogdefs.h:21
uint64 XLogSegNo
Definition: xlogdefs.h:48
Datum pg_is_wal_replay_paused(PG_FUNCTION_ARGS)
Definition: xlogfuncs.c:473
Datum pg_wal_lsn_diff(PG_FUNCTION_ARGS)
Definition: xlogfuncs.c:553
Datum pg_backup_start(PG_FUNCTION_ARGS)
Definition: xlogfuncs.c:60
Datum pg_create_restore_point(PG_FUNCTION_ARGS)
Definition: xlogfuncs.c:183
Datum pg_current_wal_insert_lsn(PG_FUNCTION_ARGS)
Definition: xlogfuncs.c:245
Datum pg_switch_wal(PG_FUNCTION_ARGS)
Definition: xlogfuncs.c:158
Datum pg_is_in_recovery(PG_FUNCTION_ARGS)
Definition: xlogfuncs.c:544
Datum pg_backup_stop(PG_FUNCTION_ARGS)
Definition: xlogfuncs.c:105
#define WAITS_PER_SECOND
Datum pg_last_xact_replay_timestamp(PG_FUNCTION_ARGS)
Definition: xlogfuncs.c:529
static StringInfo label_file
Definition: xlogfuncs.c:44
Datum pg_current_wal_lsn(PG_FUNCTION_ARGS)
Definition: xlogfuncs.c:224
Datum pg_last_wal_receive_lsn(PG_FUNCTION_ARGS)
Definition: xlogfuncs.c:288
Datum pg_walfile_name(PG_FUNCTION_ARGS)
Definition: xlogfuncs.c:392
Datum pg_current_wal_flush_lsn(PG_FUNCTION_ARGS)
Definition: xlogfuncs.c:266
Datum pg_walfile_name_offset(PG_FUNCTION_ARGS)
Definition: xlogfuncs.c:328
Datum pg_promote(PG_FUNCTION_ARGS)
Definition: xlogfuncs.c:571
Datum pg_get_wal_replay_pause_state(PG_FUNCTION_ARGS)
Definition: xlogfuncs.c:494
static StringInfo tblspc_map_file
Definition: xlogfuncs.c:45
Datum pg_last_wal_replay_lsn(PG_FUNCTION_ARGS)
Definition: xlogfuncs.c:307
Datum pg_wal_replay_pause(PG_FUNCTION_ARGS)
Definition: xlogfuncs.c:419
Datum pg_wal_replay_resume(PG_FUNCTION_ARGS)
Definition: xlogfuncs.c:449
#define PG_STOP_BACKUP_V2_COLS
void SetRecoveryPause(bool recoveryPause)
void WakeupRecovery(void)
bool PromoteIsTriggered(void)
XLogRecPtr GetXLogReplayRecPtr(TimeLineID *replayTLI)
RecoveryPauseState GetRecoveryPauseState(void)
TimestampTz GetLatestXTime(void)
@ RECOVERY_PAUSED
Definition: xlogrecovery.h:48
@ RECOVERY_NOT_PAUSED
Definition: xlogrecovery.h:46
@ RECOVERY_PAUSE_REQUESTED
Definition: xlogrecovery.h:47