PostgreSQL Source Code  git master
basebackup_incremental.c File Reference
Include dependency graph for basebackup_incremental.c:

Go to the source code of this file.

Data Structures

struct  backup_wal_range
 
struct  backup_file_entry
 
struct  IncrementalBackupInfo
 

Macros

#define BLOCKS_PER_READ   512
 
#define MIN_CHUNK   1024
 
#define MAX_CHUNK   (128 * 1024)
 
#define SH_PREFIX   backup_file
 
#define SH_ELEMENT_TYPE   backup_file_entry
 
#define SH_KEY_TYPE   const char *
 
#define SH_KEY   path
 
#define SH_HASH_KEY(tb, key)   hash_string_pointer(key)
 
#define SH_EQUAL(tb, a, b)   (strcmp(a, b) == 0)
 
#define SH_SCOPE   static inline
 
#define SH_DECLARE
 
#define SH_DEFINE
 

Functions

static uint32 hash_string_pointer (const char *s)
 
static void manifest_process_version (JsonManifestParseContext *context, int manifest_version)
 
static void manifest_process_system_identifier (JsonManifestParseContext *context, uint64 manifest_system_identifier)
 
static void manifest_process_file (JsonManifestParseContext *context, const char *pathname, size_t size, pg_checksum_type checksum_type, int checksum_length, uint8 *checksum_payload)
 
static void manifest_process_wal_range (JsonManifestParseContext *context, TimeLineID tli, XLogRecPtr start_lsn, XLogRecPtr end_lsn)
 
static void manifest_report_error (JsonManifestParseContext *context, const char *fmt,...) pg_attribute_printf(2
 
static void pg_attribute_noreturn ()
 
static int compare_block_numbers (const void *a, const void *b)
 
IncrementalBackupInfoCreateIncrementalBackupInfo (MemoryContext mcxt)
 
void AppendIncrementalManifestData (IncrementalBackupInfo *ib, const char *data, int len)
 
void FinalizeIncrementalManifest (IncrementalBackupInfo *ib)
 
void PrepareForIncrementalBackup (IncrementalBackupInfo *ib, BackupState *backup_state)
 
char * GetIncrementalFilePath (Oid dboid, Oid spcoid, RelFileNumber relfilenumber, ForkNumber forknum, unsigned segno)
 
FileBackupMethod GetFileBackupMethod (IncrementalBackupInfo *ib, const char *path, Oid dboid, Oid spcoid, RelFileNumber relfilenumber, ForkNumber forknum, unsigned segno, size_t size, unsigned *num_blocks_required, BlockNumber *relative_block_numbers, unsigned *truncation_block_length)
 
size_t GetIncrementalHeaderSize (unsigned num_blocks_required)
 
size_t GetIncrementalFileSize (unsigned num_blocks_required)
 

Macro Definition Documentation

◆ BLOCKS_PER_READ

#define BLOCKS_PER_READ   512

Definition at line 34 of file basebackup_incremental.c.

◆ MAX_CHUNK

#define MAX_CHUNK   (128 * 1024)

Definition at line 42 of file basebackup_incremental.c.

◆ MIN_CHUNK

#define MIN_CHUNK   1024

Definition at line 41 of file basebackup_incremental.c.

◆ SH_DECLARE

#define SH_DECLARE

Definition at line 72 of file basebackup_incremental.c.

◆ SH_DEFINE

#define SH_DEFINE

Definition at line 73 of file basebackup_incremental.c.

◆ SH_ELEMENT_TYPE

#define SH_ELEMENT_TYPE   backup_file_entry

Definition at line 66 of file basebackup_incremental.c.

◆ SH_EQUAL

#define SH_EQUAL (   tb,
  a,
  b 
)    (strcmp(a, b) == 0)

Definition at line 70 of file basebackup_incremental.c.

◆ SH_HASH_KEY

#define SH_HASH_KEY (   tb,
  key 
)    hash_string_pointer(key)

Definition at line 69 of file basebackup_incremental.c.

◆ SH_KEY

#define SH_KEY   path

Definition at line 68 of file basebackup_incremental.c.

◆ SH_KEY_TYPE

#define SH_KEY_TYPE   const char *

Definition at line 67 of file basebackup_incremental.c.

◆ SH_PREFIX

#define SH_PREFIX   backup_file

Definition at line 65 of file basebackup_incremental.c.

◆ SH_SCOPE

#define SH_SCOPE   static inline

Definition at line 71 of file basebackup_incremental.c.

Function Documentation

◆ AppendIncrementalManifestData()

void AppendIncrementalManifestData ( IncrementalBackupInfo ib,
const char *  data,
int  len 
)

Definition at line 196 of file basebackup_incremental.c.

198 {
199  MemoryContext oldcontext;
200 
201  /* Switch to our memory context. */
202  oldcontext = MemoryContextSwitchTo(ib->mcxt);
203 
204  if (ib->buf.len > MIN_CHUNK && ib->buf.len + len > MAX_CHUNK)
205  {
206  /*
207  * time for an incremental parse. We'll do all but the last MIN_CHUNK
208  * so that we have enough left for the final piece.
209  */
211  ib->inc_state, ib->buf.data, ib->buf.len - MIN_CHUNK, false);
212  /* now remove what we just parsed */
213  memmove(ib->buf.data, ib->buf.data + (ib->buf.len - MIN_CHUNK),
214  MIN_CHUNK + 1);
215  ib->buf.len = MIN_CHUNK;
216  }
217 
219 
220  /* Switch back to previous memory context. */
221  MemoryContextSwitchTo(oldcontext);
222 }
#define MAX_CHUNK
#define MIN_CHUNK
void json_parse_manifest_incremental_chunk(JsonManifestParseIncrementalState *incstate, const char *chunk, size_t size, bool is_last)
const void size_t len
const void * data
MemoryContextSwitchTo(old_ctx)
void appendBinaryStringInfo(StringInfo str, const void *data, int datalen)
Definition: stringinfo.c:233
JsonManifestParseIncrementalState * inc_state

References appendBinaryStringInfo(), IncrementalBackupInfo::buf, StringInfoData::data, data, IncrementalBackupInfo::inc_state, json_parse_manifest_incremental_chunk(), StringInfoData::len, len, MAX_CHUNK, IncrementalBackupInfo::mcxt, MemoryContextSwitchTo(), and MIN_CHUNK.

Referenced by HandleUploadManifestPacket().

◆ compare_block_numbers()

static int compare_block_numbers ( const void *  a,
const void *  b 
)
static

Definition at line 1118 of file basebackup_incremental.c.

1119 {
1120  BlockNumber aa = *(BlockNumber *) a;
1121  BlockNumber bb = *(BlockNumber *) b;
1122 
1123  return pg_cmp_u32(aa, bb);
1124 }
uint32 BlockNumber
Definition: block.h:31
static int pg_cmp_u32(uint32 a, uint32 b)
Definition: int.h:489
int b
Definition: isn.c:70
int a
Definition: isn.c:69

References a, b, and pg_cmp_u32().

Referenced by GetFileBackupMethod().

◆ CreateIncrementalBackupInfo()

IncrementalBackupInfo* CreateIncrementalBackupInfo ( MemoryContext  mcxt)

Definition at line 154 of file basebackup_incremental.c.

155 {
157  MemoryContext oldcontext;
159 
160  oldcontext = MemoryContextSwitchTo(mcxt);
161 
162  ib = palloc0(sizeof(IncrementalBackupInfo));
163  ib->mcxt = mcxt;
164  initStringInfo(&ib->buf);
165 
166  /*
167  * It's hard to guess how many files a "typical" installation will have in
168  * the data directory, but a fresh initdb creates almost 1000 files as of
169  * this writing, so it seems to make sense for our estimate to
170  * substantially higher.
171  */
172  ib->manifest_files = backup_file_create(mcxt, 10000, NULL);
173 
175  /* Parse the manifest. */
176  context->private_data = ib;
177  context->version_cb = manifest_process_version;
178  context->system_identifier_cb = manifest_process_system_identifier;
179  context->per_file_cb = manifest_process_file;
180  context->per_wal_range_cb = manifest_process_wal_range;
181  context->error_cb = manifest_report_error;
182 
184 
185  MemoryContextSwitchTo(oldcontext);
186 
187  return ib;
188 }
static void manifest_process_version(JsonManifestParseContext *context, int manifest_version)
static void manifest_process_system_identifier(JsonManifestParseContext *context, uint64 manifest_system_identifier)
static void manifest_process_file(JsonManifestParseContext *context, const char *pathname, size_t size, pg_checksum_type checksum_type, int checksum_length, uint8 *checksum_payload)
static void manifest_report_error(JsonManifestParseContext *context, const char *fmt,...) pg_attribute_printf(2
static void manifest_process_wal_range(JsonManifestParseContext *context, TimeLineID tli, XLogRecPtr start_lsn, XLogRecPtr end_lsn)
void * palloc0(Size size)
Definition: mcxt.c:1347
JsonManifestParseIncrementalState * json_parse_manifest_incremental_init(JsonManifestParseContext *context)
tree context
Definition: radixtree.h:1835
void initStringInfo(StringInfo str)
Definition: stringinfo.c:59
backup_file_hash * manifest_files

References IncrementalBackupInfo::buf, context, IncrementalBackupInfo::inc_state, initStringInfo(), json_parse_manifest_incremental_init(), IncrementalBackupInfo::manifest_files, manifest_process_file(), manifest_process_system_identifier(), manifest_process_version(), manifest_process_wal_range(), manifest_report_error(), IncrementalBackupInfo::mcxt, MemoryContextSwitchTo(), and palloc0().

Referenced by UploadManifest().

◆ FinalizeIncrementalManifest()

void FinalizeIncrementalManifest ( IncrementalBackupInfo ib)

Definition at line 229 of file basebackup_incremental.c.

230 {
231  MemoryContext oldcontext;
232 
233  /* Switch to our memory context. */
234  oldcontext = MemoryContextSwitchTo(ib->mcxt);
235 
236  /* Parse the last chunk of the manifest */
238  ib->inc_state, ib->buf.data, ib->buf.len, true);
239 
240  /* Done with the buffer, so release memory. */
241  pfree(ib->buf.data);
242  ib->buf.data = NULL;
243 
244  /* Done with inc_state, so release that memory too */
246 
247  /* Switch back to previous memory context. */
248  MemoryContextSwitchTo(oldcontext);
249 }
void pfree(void *pointer)
Definition: mcxt.c:1521
void json_parse_manifest_incremental_shutdown(JsonManifestParseIncrementalState *incstate)

References IncrementalBackupInfo::buf, StringInfoData::data, IncrementalBackupInfo::inc_state, json_parse_manifest_incremental_chunk(), json_parse_manifest_incremental_shutdown(), StringInfoData::len, IncrementalBackupInfo::mcxt, MemoryContextSwitchTo(), and pfree().

Referenced by UploadManifest().

◆ GetFileBackupMethod()

FileBackupMethod GetFileBackupMethod ( IncrementalBackupInfo ib,
const char *  path,
Oid  dboid,
Oid  spcoid,
RelFileNumber  relfilenumber,
ForkNumber  forknum,
unsigned  segno,
size_t  size,
unsigned *  num_blocks_required,
BlockNumber relative_block_numbers,
unsigned *  truncation_block_length 
)

Definition at line 745 of file basebackup_incremental.c.

752 {
753  BlockNumber limit_block;
754  BlockNumber start_blkno;
755  BlockNumber stop_blkno;
756  RelFileLocator rlocator;
757  BlockRefTableEntry *brtentry;
758  unsigned i;
759  unsigned nblocks;
760 
761  /* Should only be called after PrepareForIncrementalBackup. */
762  Assert(ib->buf.data == NULL);
763 
764  /*
765  * dboid could be InvalidOid if shared rel, but spcoid and relfilenumber
766  * should have legal values.
767  */
768  Assert(OidIsValid(spcoid));
769  Assert(RelFileNumberIsValid(relfilenumber));
770 
771  /*
772  * If the file size is too large or not a multiple of BLCKSZ, then
773  * something weird is happening, so give up and send the whole file.
774  */
775  if ((size % BLCKSZ) != 0 || size / BLCKSZ > RELSEG_SIZE)
776  return BACK_UP_FILE_FULLY;
777 
778  /*
779  * The free-space map fork is not properly WAL-logged, so we need to
780  * backup the entire file every time.
781  */
782  if (forknum == FSM_FORKNUM)
783  return BACK_UP_FILE_FULLY;
784 
785  /*
786  * If this file was not part of the prior backup, back it up fully.
787  *
788  * If this file was created after the prior backup and before the start of
789  * the current backup, then the WAL summary information will tell us to
790  * back up the whole file. However, if this file was created after the
791  * start of the current backup, then the WAL summary won't know anything
792  * about it. Without this logic, we would erroneously conclude that it was
793  * OK to send it incrementally.
794  *
795  * Note that the file could have existed at the time of the prior backup,
796  * gotten deleted, and then a new file with the same name could have been
797  * created. In that case, this logic won't prevent the file from being
798  * backed up incrementally. But, if the deletion happened before the start
799  * of the current backup, the limit block will be 0, inducing a full
800  * backup. If the deletion happened after the start of the current backup,
801  * reconstruction will erroneously combine blocks from the current
802  * lifespan of the file with blocks from the previous lifespan -- but in
803  * this type of case, WAL replay to reach backup consistency should remove
804  * and recreate the file anyway, so the initial bogus contents should not
805  * matter.
806  */
807  if (backup_file_lookup(ib->manifest_files, path) == NULL)
808  {
809  char *ipath;
810 
811  ipath = GetIncrementalFilePath(dboid, spcoid, relfilenumber,
812  forknum, segno);
813  if (backup_file_lookup(ib->manifest_files, ipath) == NULL)
814  return BACK_UP_FILE_FULLY;
815  }
816 
817  /*
818  * Look up the special block reference table entry for the database as a
819  * whole.
820  */
821  rlocator.spcOid = spcoid;
822  rlocator.dbOid = dboid;
823  rlocator.relNumber = 0;
824  if (BlockRefTableGetEntry(ib->brtab, &rlocator, MAIN_FORKNUM,
825  &limit_block) != NULL)
826  {
827  /*
828  * According to the WAL summary, this database OID/tablespace OID
829  * pairing has been created since the previous backup. So, everything
830  * in it must be backed up fully.
831  */
832  return BACK_UP_FILE_FULLY;
833  }
834 
835  /* Look up the block reference table entry for this relfilenode. */
836  rlocator.relNumber = relfilenumber;
837  brtentry = BlockRefTableGetEntry(ib->brtab, &rlocator, forknum,
838  &limit_block);
839 
840  /*
841  * If there is no entry, then there have been no WAL-logged changes to the
842  * relation since the predecessor backup was taken, so we can back it up
843  * incrementally and need not include any modified blocks.
844  *
845  * However, if the file is zero-length, we should do a full backup,
846  * because an incremental file is always more than zero length, and it's
847  * silly to take an incremental backup when a full backup would be
848  * smaller.
849  */
850  if (brtentry == NULL)
851  {
852  if (size == 0)
853  return BACK_UP_FILE_FULLY;
854  *num_blocks_required = 0;
855  *truncation_block_length = size / BLCKSZ;
857  }
858 
859  /*
860  * If the limit_block is less than or equal to the point where this
861  * segment starts, send the whole file.
862  */
863  if (limit_block <= segno * RELSEG_SIZE)
864  return BACK_UP_FILE_FULLY;
865 
866  /*
867  * Get relevant entries from the block reference table entry.
868  *
869  * We shouldn't overflow computing the start or stop block numbers, but if
870  * it manages to happen somehow, detect it and throw an error.
871  */
872  start_blkno = segno * RELSEG_SIZE;
873  stop_blkno = start_blkno + (size / BLCKSZ);
874  if (start_blkno / RELSEG_SIZE != segno || stop_blkno < start_blkno)
875  ereport(ERROR,
876  errcode(ERRCODE_INTERNAL_ERROR),
877  errmsg_internal("overflow computing block number bounds for segment %u with size %zu",
878  segno, size));
879 
880  /*
881  * This will write *absolute* block numbers into the output array, but
882  * we'll transpose them below.
883  */
884  nblocks = BlockRefTableEntryGetBlocks(brtentry, start_blkno, stop_blkno,
885  relative_block_numbers, RELSEG_SIZE);
886  Assert(nblocks <= RELSEG_SIZE);
887 
888  /*
889  * If we're going to have to send nearly all of the blocks, then just send
890  * the whole file, because that won't require much extra storage or
891  * transfer and will speed up and simplify backup restoration. It's not
892  * clear what threshold is most appropriate here and perhaps it ought to
893  * be configurable, but for now we're just going to say that if we'd need
894  * to send 90% of the blocks anyway, give up and send the whole file.
895  *
896  * NB: If you change the threshold here, at least make sure to back up the
897  * file fully when every single block must be sent, because there's
898  * nothing good about sending an incremental file in that case.
899  */
900  if (nblocks * BLCKSZ > size * 0.9)
901  return BACK_UP_FILE_FULLY;
902 
903  /*
904  * Looks like we can send an incremental file, so sort the block numbers
905  * and then transpose them from absolute block numbers to relative block
906  * numbers if necessary.
907  *
908  * NB: If the block reference table was using the bitmap representation
909  * for a given chunk, the block numbers in that chunk will already be
910  * sorted, but when the array-of-offsets representation is used, we can
911  * receive block numbers here out of order.
912  */
913  qsort(relative_block_numbers, nblocks, sizeof(BlockNumber),
915  if (start_blkno != 0)
916  {
917  for (i = 0; i < nblocks; ++i)
918  relative_block_numbers[i] -= start_blkno;
919  }
920  *num_blocks_required = nblocks;
921 
922  /*
923  * The truncation block length is the minimum length of the reconstructed
924  * file. Any block numbers below this threshold that are not present in
925  * the backup need to be fetched from the prior backup. At or above this
926  * threshold, blocks should only be included in the result if they are
927  * present in the backup. (This may require inserting zero blocks if the
928  * blocks included in the backup are non-consecutive.)
929  */
930  *truncation_block_length = size / BLCKSZ;
931  if (BlockNumberIsValid(limit_block))
932  {
933  unsigned relative_limit = limit_block - segno * RELSEG_SIZE;
934 
935  if (*truncation_block_length < relative_limit)
936  *truncation_block_length = relative_limit;
937  }
938 
939  /* Send it incrementally. */
941 }
static int compare_block_numbers(const void *a, const void *b)
char * GetIncrementalFilePath(Oid dboid, Oid spcoid, RelFileNumber relfilenumber, ForkNumber forknum, unsigned segno)
@ BACK_UP_FILE_INCREMENTALLY
@ BACK_UP_FILE_FULLY
int BlockRefTableEntryGetBlocks(BlockRefTableEntry *entry, BlockNumber start_blkno, BlockNumber stop_blkno, BlockNumber *blocks, int nblocks)
Definition: blkreftable.c:369
BlockRefTableEntry * BlockRefTableGetEntry(BlockRefTable *brtab, const RelFileLocator *rlocator, ForkNumber forknum, BlockNumber *limit_block)
Definition: blkreftable.c:340
static bool BlockNumberIsValid(BlockNumber blockNumber)
Definition: block.h:71
#define Assert(condition)
Definition: c.h:858
#define OidIsValid(objectId)
Definition: c.h:775
int errmsg_internal(const char *fmt,...)
Definition: elog.c:1157
int errcode(int sqlerrcode)
Definition: elog.c:853
#define ERROR
Definition: elog.h:39
#define ereport(elevel,...)
Definition: elog.h:149
int i
Definition: isn.c:73
#define qsort(a, b, c, d)
Definition: port.h:453
@ FSM_FORKNUM
Definition: relpath.h:51
@ MAIN_FORKNUM
Definition: relpath.h:50
#define RelFileNumberIsValid(relnumber)
Definition: relpath.h:27
static pg_noinline void Size size
Definition: slab.c:607
RelFileNumber relNumber

References Assert, BACK_UP_FILE_FULLY, BACK_UP_FILE_INCREMENTALLY, BlockNumberIsValid(), BlockRefTableEntryGetBlocks(), BlockRefTableGetEntry(), IncrementalBackupInfo::brtab, IncrementalBackupInfo::buf, compare_block_numbers(), StringInfoData::data, RelFileLocator::dbOid, ereport, errcode(), errmsg_internal(), ERROR, FSM_FORKNUM, GetIncrementalFilePath(), i, MAIN_FORKNUM, IncrementalBackupInfo::manifest_files, OidIsValid, qsort, RelFileNumberIsValid, RelFileLocator::relNumber, size, and RelFileLocator::spcOid.

Referenced by sendDir().

◆ GetIncrementalFilePath()

char* GetIncrementalFilePath ( Oid  dboid,
Oid  spcoid,
RelFileNumber  relfilenumber,
ForkNumber  forknum,
unsigned  segno 
)

Definition at line 705 of file basebackup_incremental.c.

707 {
708  char *path;
709  char *lastslash;
710  char *ipath;
711 
712  path = GetRelationPath(dboid, spcoid, relfilenumber, INVALID_PROC_NUMBER,
713  forknum);
714 
715  lastslash = strrchr(path, '/');
716  Assert(lastslash != NULL);
717  *lastslash = '\0';
718 
719  if (segno > 0)
720  ipath = psprintf("%s/INCREMENTAL.%s.%u", path, lastslash + 1, segno);
721  else
722  ipath = psprintf("%s/INCREMENTAL.%s", path, lastslash + 1);
723 
724  pfree(path);
725 
726  return ipath;
727 }
#define INVALID_PROC_NUMBER
Definition: procnumber.h:26
char * psprintf(const char *fmt,...)
Definition: psprintf.c:46
char * GetRelationPath(Oid dbOid, Oid spcOid, RelFileNumber relNumber, int procNumber, ForkNumber forkNumber)
Definition: relpath.c:141

References Assert, GetRelationPath(), INVALID_PROC_NUMBER, pfree(), and psprintf().

Referenced by GetFileBackupMethod().

◆ GetIncrementalFileSize()

size_t GetIncrementalFileSize ( unsigned  num_blocks_required)

Definition at line 977 of file basebackup_incremental.c.

978 {
979  size_t result;
980 
981  /* Make sure we're not going to overflow. */
982  Assert(num_blocks_required <= RELSEG_SIZE);
983 
984  /*
985  * Header with three four byte quantities (magic number, truncation block
986  * length, block count) followed by block numbers, rounded to a multiple
987  * of BLCKSZ (for files with block data), followed by block contents.
988  */
989  result = GetIncrementalHeaderSize(num_blocks_required);
990  result += BLCKSZ * num_blocks_required;
991 
992  return result;
993 }
size_t GetIncrementalHeaderSize(unsigned num_blocks_required)

References Assert, and GetIncrementalHeaderSize().

Referenced by sendDir().

◆ GetIncrementalHeaderSize()

size_t GetIncrementalHeaderSize ( unsigned  num_blocks_required)

Definition at line 949 of file basebackup_incremental.c.

950 {
951  size_t result;
952 
953  /* Make sure we're not going to overflow. */
954  Assert(num_blocks_required <= RELSEG_SIZE);
955 
956  /*
957  * Three four byte quantities (magic number, truncation block length,
958  * block count) followed by block numbers.
959  */
960  result = 3 * sizeof(uint32) + (sizeof(BlockNumber) * num_blocks_required);
961 
962  /*
963  * Round the header size to a multiple of BLCKSZ - when not a multiple of
964  * BLCKSZ, add the missing fraction of a block. But do this only if the
965  * file will store data for some blocks, otherwise keep it small.
966  */
967  if ((num_blocks_required > 0) && (result % BLCKSZ != 0))
968  result += BLCKSZ - (result % BLCKSZ);
969 
970  return result;
971 }
unsigned int uint32
Definition: c.h:506

References Assert.

Referenced by GetIncrementalFileSize().

◆ hash_string_pointer()

static uint32 hash_string_pointer ( const char *  s)
static

Definition at line 999 of file basebackup_incremental.c.

1000 {
1001  unsigned char *ss = (unsigned char *) s;
1002 
1003  return hash_bytes(ss, strlen(s));
1004 }
uint32 hash_bytes(const unsigned char *k, int keylen)
Definition: hashfn.c:146

References hash_bytes().

◆ manifest_process_file()

static void manifest_process_file ( JsonManifestParseContext context,
const char *  pathname,
size_t  size,
pg_checksum_type  checksum_type,
int  checksum_length,
uint8 checksum_payload 
)
static

Definition at line 1046 of file basebackup_incremental.c.

1051 {
1052  IncrementalBackupInfo *ib = context->private_data;
1053  backup_file_entry *entry;
1054  bool found;
1055 
1056  entry = backup_file_insert(ib->manifest_files, pathname, &found);
1057  if (!found)
1058  {
1059  entry->path = MemoryContextStrdup(ib->manifest_files->ctx,
1060  pathname);
1061  entry->size = size;
1062  }
1063 }
char * MemoryContextStrdup(MemoryContext context, const char *string)
Definition: mcxt.c:1683
size_t size
const char * path

References context, IncrementalBackupInfo::manifest_files, MemoryContextStrdup(), backup_file_entry::path, backup_file_entry::size, and size.

Referenced by CreateIncrementalBackupInfo().

◆ manifest_process_system_identifier()

static void manifest_process_system_identifier ( JsonManifestParseContext context,
uint64  manifest_system_identifier 
)
static

Definition at line 1024 of file basebackup_incremental.c.

1026 {
1027  uint64 system_identifier;
1028 
1029  /* Get system identifier of current system */
1030  system_identifier = GetSystemIdentifier();
1031 
1032  if (manifest_system_identifier != system_identifier)
1033  context->error_cb(context,
1034  "manifest system identifier is %llu, but database system identifier is %llu",
1035  (unsigned long long) manifest_system_identifier,
1036  (unsigned long long) system_identifier);
1037 }
uint64 GetSystemIdentifier(void)
Definition: xlog.c:4533

References context, and GetSystemIdentifier().

Referenced by CreateIncrementalBackupInfo().

◆ manifest_process_version()

static void manifest_process_version ( JsonManifestParseContext context,
int  manifest_version 
)
static

Definition at line 1010 of file basebackup_incremental.c.

1012 {
1013  /* Incremental backups don't work with manifest version 1 */
1014  if (manifest_version == 1)
1015  context->error_cb(context,
1016  "backup manifest version 1 does not support incremental backup");
1017 }

References context.

Referenced by CreateIncrementalBackupInfo().

◆ manifest_process_wal_range()

static void manifest_process_wal_range ( JsonManifestParseContext context,
TimeLineID  tli,
XLogRecPtr  start_lsn,
XLogRecPtr  end_lsn 
)
static

Definition at line 1073 of file basebackup_incremental.c.

1076 {
1077  IncrementalBackupInfo *ib = context->private_data;
1079 
1080  range->tli = tli;
1081  range->start_lsn = start_lsn;
1082  range->end_lsn = end_lsn;
1084 }
List * lappend(List *list, void *datum)
Definition: list.c:339
void * palloc(Size size)
Definition: mcxt.c:1317
static struct cvec * range(struct vars *v, chr a, chr b, int cases)
Definition: regc_locale.c:412

References context, lappend(), IncrementalBackupInfo::manifest_wal_ranges, palloc(), and range().

Referenced by CreateIncrementalBackupInfo().

◆ manifest_report_error()

static void manifest_report_error ( JsonManifestParseContext context,
const char *  fmt,
  ... 
)
static

Definition at line 1091 of file basebackup_incremental.c.

1092 {
1093  StringInfoData errbuf;
1094 
1095  initStringInfo(&errbuf);
1096 
1097  for (;;)
1098  {
1099  va_list ap;
1100  int needed;
1101 
1102  va_start(ap, fmt);
1103  needed = appendStringInfoVA(&errbuf, fmt, ap);
1104  va_end(ap);
1105  if (needed == 0)
1106  break;
1107  enlargeStringInfo(&errbuf, needed);
1108  }
1109 
1110  ereport(ERROR,
1111  errmsg_internal("%s", errbuf.data));
1112 }
static void const char * fmt
va_end(args)
va_start(args, fmt)
int appendStringInfoVA(StringInfo str, const char *fmt, va_list args)
Definition: stringinfo.c:139
void enlargeStringInfo(StringInfo str, int needed)
Definition: stringinfo.c:289

References appendStringInfoVA(), StringInfoData::data, enlargeStringInfo(), ereport, errmsg_internal(), ERROR, fmt, initStringInfo(), va_end(), and va_start().

Referenced by CreateIncrementalBackupInfo().

◆ pg_attribute_noreturn()

static void pg_attribute_noreturn ( )

◆ PrepareForIncrementalBackup()

void PrepareForIncrementalBackup ( IncrementalBackupInfo ib,
BackupState backup_state 
)

Definition at line 265 of file basebackup_incremental.c.

267 {
268  MemoryContext oldcontext;
270  List *all_wslist,
271  *required_wslist = NIL;
272  ListCell *lc;
273  TimeLineHistoryEntry **tlep;
274  int num_wal_ranges;
275  int i;
276  bool found_backup_start_tli = false;
277  TimeLineID earliest_wal_range_tli = 0;
278  XLogRecPtr earliest_wal_range_start_lsn = InvalidXLogRecPtr;
279  TimeLineID latest_wal_range_tli = 0;
280  XLogRecPtr summarized_lsn;
281  XLogRecPtr pending_lsn;
282  XLogRecPtr prior_pending_lsn = InvalidXLogRecPtr;
283  int deadcycles = 0;
284  TimestampTz initial_time,
285  current_time;
286 
287  Assert(ib->buf.data == NULL);
288 
289  /* Switch to our memory context. */
290  oldcontext = MemoryContextSwitchTo(ib->mcxt);
291 
292  /*
293  * A valid backup manifest must always contain at least one WAL range
294  * (usually exactly one, unless the backup spanned a timeline switch).
295  */
296  num_wal_ranges = list_length(ib->manifest_wal_ranges);
297  if (num_wal_ranges == 0)
298  ereport(ERROR,
299  (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
300  errmsg("manifest contains no required WAL ranges")));
301 
302  /*
303  * Match up the TLIs that appear in the WAL ranges of the backup manifest
304  * with those that appear in this server's timeline history. We expect
305  * every backup_wal_range to match to a TimeLineHistoryEntry; if it does
306  * not, that's an error.
307  *
308  * This loop also decides which of the WAL ranges is the manifest is most
309  * ancient and which one is the newest, according to the timeline history
310  * of this server, and stores TLIs of those WAL ranges into
311  * earliest_wal_range_tli and latest_wal_range_tli. It also updates
312  * earliest_wal_range_start_lsn to the start LSN of the WAL range for
313  * earliest_wal_range_tli.
314  *
315  * Note that the return value of readTimeLineHistory puts the latest
316  * timeline at the beginning of the list, not the end. Hence, the earliest
317  * TLI is the one that occurs nearest the end of the list returned by
318  * readTimeLineHistory, and the latest TLI is the one that occurs closest
319  * to the beginning.
320  */
322  tlep = palloc0(num_wal_ranges * sizeof(TimeLineHistoryEntry *));
323  for (i = 0; i < num_wal_ranges; ++i)
324  {
326  bool saw_earliest_wal_range_tli = false;
327  bool saw_latest_wal_range_tli = false;
328 
329  /* Search this server's history for this WAL range's TLI. */
330  foreach(lc, expectedTLEs)
331  {
332  TimeLineHistoryEntry *tle = lfirst(lc);
333 
334  if (tle->tli == range->tli)
335  {
336  tlep[i] = tle;
337  break;
338  }
339 
340  if (tle->tli == earliest_wal_range_tli)
341  saw_earliest_wal_range_tli = true;
342  if (tle->tli == latest_wal_range_tli)
343  saw_latest_wal_range_tli = true;
344  }
345 
346  /*
347  * An incremental backup can only be taken relative to a backup that
348  * represents a previous state of this server. If the backup requires
349  * WAL from a timeline that's not in our history, that definitely
350  * isn't the case.
351  */
352  if (tlep[i] == NULL)
353  ereport(ERROR,
354  (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
355  errmsg("timeline %u found in manifest, but not in this server's history",
356  range->tli)));
357 
358  /*
359  * If we found this TLI in the server's history before encountering
360  * the latest TLI seen so far in the server's history, then this TLI
361  * is the latest one seen so far.
362  *
363  * If on the other hand we saw the earliest TLI seen so far before
364  * finding this TLI, this TLI is earlier than the earliest one seen so
365  * far. And if this is the first TLI for which we've searched, it's
366  * also the earliest one seen so far.
367  *
368  * On the first loop iteration, both things should necessarily be
369  * true.
370  */
371  if (!saw_latest_wal_range_tli)
372  latest_wal_range_tli = range->tli;
373  if (earliest_wal_range_tli == 0 || saw_earliest_wal_range_tli)
374  {
375  earliest_wal_range_tli = range->tli;
376  earliest_wal_range_start_lsn = range->start_lsn;
377  }
378  }
379 
380  /*
381  * Propagate information about the prior backup into the backup_label that
382  * will be generated for this backup.
383  */
384  backup_state->istartpoint = earliest_wal_range_start_lsn;
385  backup_state->istarttli = earliest_wal_range_tli;
386 
387  /*
388  * Sanity check start and end LSNs for the WAL ranges in the manifest.
389  *
390  * Commonly, there won't be any timeline switches during the prior backup
391  * at all, but if there are, they should happen at the same LSNs that this
392  * server switched timelines.
393  *
394  * Whether there are any timeline switches during the prior backup or not,
395  * the prior backup shouldn't require any WAL from a timeline prior to the
396  * start of that timeline. It also shouldn't require any WAL from later
397  * than the start of this backup.
398  *
399  * If any of these sanity checks fail, one possible explanation is that
400  * the user has generated WAL on the same timeline with the same LSNs more
401  * than once. For instance, if two standbys running on timeline 1 were
402  * both promoted and (due to a broken archiving setup) both selected new
403  * timeline ID 2, then it's possible that one of these checks might trip.
404  *
405  * Note that there are lots of ways for the user to do something very bad
406  * without tripping any of these checks, and they are not intended to be
407  * comprehensive. It's pretty hard to see how we could be certain of
408  * anything here. However, if there's a problem staring us right in the
409  * face, it's best to report it, so we do.
410  */
411  for (i = 0; i < num_wal_ranges; ++i)
412  {
414 
415  if (range->tli == earliest_wal_range_tli)
416  {
417  if (range->start_lsn < tlep[i]->begin)
418  ereport(ERROR,
419  (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
420  errmsg("manifest requires WAL from initial timeline %u starting at %X/%X, but that timeline begins at %X/%X",
421  range->tli,
422  LSN_FORMAT_ARGS(range->start_lsn),
423  LSN_FORMAT_ARGS(tlep[i]->begin))));
424  }
425  else
426  {
427  if (range->start_lsn != tlep[i]->begin)
428  ereport(ERROR,
429  (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
430  errmsg("manifest requires WAL from continuation timeline %u starting at %X/%X, but that timeline begins at %X/%X",
431  range->tli,
432  LSN_FORMAT_ARGS(range->start_lsn),
433  LSN_FORMAT_ARGS(tlep[i]->begin))));
434  }
435 
436  if (range->tli == latest_wal_range_tli)
437  {
438  if (range->end_lsn > backup_state->startpoint)
439  ereport(ERROR,
440  (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
441  errmsg("manifest requires WAL from final timeline %u ending at %X/%X, but this backup starts at %X/%X",
442  range->tli,
443  LSN_FORMAT_ARGS(range->end_lsn),
445  errhint("This can happen for incremental backups on a standby if there was little activity since the previous backup.")));
446  }
447  else
448  {
449  if (range->end_lsn != tlep[i]->end)
450  ereport(ERROR,
451  (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
452  errmsg("manifest requires WAL from non-final timeline %u ending at %X/%X, but this server switched timelines at %X/%X",
453  range->tli,
454  LSN_FORMAT_ARGS(range->end_lsn),
455  LSN_FORMAT_ARGS(tlep[i]->end))));
456  }
457 
458  }
459 
460  /*
461  * Wait for WAL summarization to catch up to the backup start LSN (but
462  * time out if it doesn't do so quickly enough).
463  */
464  initial_time = current_time = GetCurrentTimestamp();
465  while (1)
466  {
467  long timeout_in_ms = 10000;
468  long elapsed_seconds;
469 
470  /*
471  * Align the wait time to prevent drift. This doesn't really matter,
472  * but we'd like the warnings about how long we've been waiting to say
473  * 10 seconds, 20 seconds, 30 seconds, 40 seconds ... without ever
474  * drifting to something that is not a multiple of ten.
475  */
476  timeout_in_ms -=
477  TimestampDifferenceMilliseconds(initial_time, current_time) %
478  timeout_in_ms;
479 
480  /* Wait for up to 10 seconds. */
482  timeout_in_ms, &pending_lsn);
483 
484  /* If WAL summarization has progressed sufficiently, stop waiting. */
485  if (summarized_lsn >= backup_state->startpoint)
486  break;
487 
488  /*
489  * Keep track of the number of cycles during which there has been no
490  * progression of pending_lsn. If pending_lsn is not advancing, that
491  * means that not only are no new files appearing on disk, but we're
492  * not even incorporating new records into the in-memory state.
493  */
494  if (pending_lsn > prior_pending_lsn)
495  {
496  prior_pending_lsn = pending_lsn;
497  deadcycles = 0;
498  }
499  else
500  ++deadcycles;
501 
502  /*
503  * If we've managed to wait for an entire minute without the WAL
504  * summarizer absorbing a single WAL record, error out; probably
505  * something is wrong.
506  *
507  * We could consider also erroring out if the summarizer is taking too
508  * long to catch up, but it's not clear what rate of progress would be
509  * acceptable and what would be too slow. So instead, we just try to
510  * error out in the case where there's no progress at all. That seems
511  * likely to catch a reasonable number of the things that can go wrong
512  * in practice (e.g. the summarizer process is completely hung, say
513  * because somebody hooked up a debugger to it or something) without
514  * giving up too quickly when the system is just slow.
515  */
516  if (deadcycles >= 6)
517  ereport(ERROR,
518  (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
519  errmsg("WAL summarization is not progressing"),
520  errdetail("Summarization is needed through %X/%X, but is stuck at %X/%X on disk and %X/%X in memory.",
522  LSN_FORMAT_ARGS(summarized_lsn),
523  LSN_FORMAT_ARGS(pending_lsn))));
524 
525  /*
526  * Otherwise, just let the user know what's happening.
527  */
528  current_time = GetCurrentTimestamp();
529  elapsed_seconds =
530  TimestampDifferenceMilliseconds(initial_time, current_time) / 1000;
532  (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
533  errmsg("still waiting for WAL summarization through %X/%X after %ld seconds",
535  elapsed_seconds),
536  errdetail("Summarization has reached %X/%X on disk and %X/%X in memory.",
537  LSN_FORMAT_ARGS(summarized_lsn),
538  LSN_FORMAT_ARGS(pending_lsn))));
539  }
540 
541  /*
542  * Retrieve a list of all WAL summaries on any timeline that overlap with
543  * the LSN range of interest. We could instead call GetWalSummaries() once
544  * per timeline in the loop that follows, but that would involve reading
545  * the directory multiple times. It should be mildly faster - and perhaps
546  * a bit safer - to do it just once.
547  */
548  all_wslist = GetWalSummaries(0, earliest_wal_range_start_lsn,
550 
551  /*
552  * We need WAL summaries for everything that happened during the prior
553  * backup and everything that happened afterward up until the point where
554  * the current backup started.
555  */
556  foreach(lc, expectedTLEs)
557  {
558  TimeLineHistoryEntry *tle = lfirst(lc);
559  XLogRecPtr tli_start_lsn = tle->begin;
560  XLogRecPtr tli_end_lsn = tle->end;
561  XLogRecPtr tli_missing_lsn = InvalidXLogRecPtr;
562  List *tli_wslist;
563 
564  /*
565  * Working through the history of this server from the current
566  * timeline backwards, we skip everything until we find the timeline
567  * where this backup started. Most of the time, this means we won't
568  * skip anything at all, as it's unlikely that the timeline has
569  * changed since the beginning of the backup moments ago.
570  */
571  if (tle->tli == backup_state->starttli)
572  {
573  found_backup_start_tli = true;
574  tli_end_lsn = backup_state->startpoint;
575  }
576  else if (!found_backup_start_tli)
577  continue;
578 
579  /*
580  * Find the summaries that overlap the LSN range of interest for this
581  * timeline. If this is the earliest timeline involved, the range of
582  * interest begins with the start LSN of the prior backup; otherwise,
583  * it begins at the LSN at which this timeline came into existence. If
584  * this is the latest TLI involved, the range of interest ends at the
585  * start LSN of the current backup; otherwise, it ends at the point
586  * where we switched from this timeline to the next one.
587  */
588  if (tle->tli == earliest_wal_range_tli)
589  tli_start_lsn = earliest_wal_range_start_lsn;
590  tli_wslist = FilterWalSummaries(all_wslist, tle->tli,
591  tli_start_lsn, tli_end_lsn);
592 
593  /*
594  * There is no guarantee that the WAL summaries we found cover the
595  * entire range of LSNs for which summaries are required, or indeed
596  * that we found any WAL summaries at all. Check whether we have a
597  * problem of that sort.
598  */
599  if (!WalSummariesAreComplete(tli_wslist, tli_start_lsn, tli_end_lsn,
600  &tli_missing_lsn))
601  {
602  if (XLogRecPtrIsInvalid(tli_missing_lsn))
603  ereport(ERROR,
604  (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
605  errmsg("WAL summaries are required on timeline %u from %X/%X to %X/%X, but no summaries for that timeline and LSN range exist",
606  tle->tli,
607  LSN_FORMAT_ARGS(tli_start_lsn),
608  LSN_FORMAT_ARGS(tli_end_lsn))));
609  else
610  ereport(ERROR,
611  (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
612  errmsg("WAL summaries are required on timeline %u from %X/%X to %X/%X, but the summaries for that timeline and LSN range are incomplete",
613  tle->tli,
614  LSN_FORMAT_ARGS(tli_start_lsn),
615  LSN_FORMAT_ARGS(tli_end_lsn)),
616  errdetail("The first unsummarized LSN in this range is %X/%X.",
617  LSN_FORMAT_ARGS(tli_missing_lsn))));
618  }
619 
620  /*
621  * Remember that we need to read these summaries.
622  *
623  * Technically, it's possible that this could read more files than
624  * required, since tli_wslist in theory could contain redundant
625  * summaries. For instance, if we have a summary from 0/10000000 to
626  * 0/20000000 and also one from 0/00000000 to 0/30000000, then the
627  * latter subsumes the former and the former could be ignored.
628  *
629  * We ignore this possibility because the WAL summarizer only tries to
630  * generate summaries that do not overlap. If somehow they exist,
631  * we'll do a bit of extra work but the results should still be
632  * correct.
633  */
634  required_wslist = list_concat(required_wslist, tli_wslist);
635 
636  /*
637  * Timelines earlier than the one in which the prior backup began are
638  * not relevant.
639  */
640  if (tle->tli == earliest_wal_range_tli)
641  break;
642  }
643 
644  /*
645  * Read all of the required block reference table files and merge all of
646  * the data into a single in-memory block reference table.
647  *
648  * See the comments for struct IncrementalBackupInfo for some thoughts on
649  * memory usage.
650  */
652  foreach(lc, required_wslist)
653  {
654  WalSummaryFile *ws = lfirst(lc);
655  WalSummaryIO wsio;
656  BlockRefTableReader *reader;
657  RelFileLocator rlocator;
658  ForkNumber forknum;
659  BlockNumber limit_block;
661 
662  wsio.file = OpenWalSummaryFile(ws, false);
663  wsio.filepos = 0;
664  ereport(DEBUG1,
665  (errmsg_internal("reading WAL summary file \"%s\"",
666  FilePathName(wsio.file))));
668  FilePathName(wsio.file),
669  ReportWalSummaryError, NULL);
670  while (BlockRefTableReaderNextRelation(reader, &rlocator, &forknum,
671  &limit_block))
672  {
673  BlockRefTableSetLimitBlock(ib->brtab, &rlocator,
674  forknum, limit_block);
675 
676  while (1)
677  {
678  unsigned nblocks;
679  unsigned i;
680 
681  nblocks = BlockRefTableReaderGetBlocks(reader, blocks,
683  if (nblocks == 0)
684  break;
685 
686  for (i = 0; i < nblocks; ++i)
687  BlockRefTableMarkBlockModified(ib->brtab, &rlocator,
688  forknum, blocks[i]);
689  }
690  }
692  FileClose(wsio.file);
693  }
694 
695  /* Switch back to previous memory context. */
696  MemoryContextSwitchTo(oldcontext);
697 }
List * readTimeLineHistory(TimeLineID targetTLI)
Definition: timeline.c:76
long TimestampDifferenceMilliseconds(TimestampTz start_time, TimestampTz stop_time)
Definition: timestamp.c:1767
TimestampTz GetCurrentTimestamp(void)
Definition: timestamp.c:1655
#define BLOCKS_PER_READ
BlockRefTableReader * CreateBlockRefTableReader(io_callback_fn read_callback, void *read_callback_arg, char *error_filename, report_error_fn error_callback, void *error_callback_arg)
Definition: blkreftable.c:577
bool BlockRefTableReaderNextRelation(BlockRefTableReader *reader, RelFileLocator *rlocator, ForkNumber *forknum, BlockNumber *limit_block)
Definition: blkreftable.c:613
void BlockRefTableMarkBlockModified(BlockRefTable *brtab, const RelFileLocator *rlocator, ForkNumber forknum, BlockNumber blknum)
Definition: blkreftable.c:297
unsigned BlockRefTableReaderGetBlocks(BlockRefTableReader *reader, BlockNumber *blocks, int nblocks)
Definition: blkreftable.c:689
void BlockRefTableSetLimitBlock(BlockRefTable *brtab, const RelFileLocator *rlocator, ForkNumber forknum, BlockNumber limit_block)
Definition: blkreftable.c:262
void DestroyBlockRefTableReader(BlockRefTableReader *reader)
Definition: blkreftable.c:773
void(*) BlockRefTable CreateEmptyBlockRefTable)(void)
int64 TimestampTz
Definition: timestamp.h:39
int errdetail(const char *fmt,...)
Definition: elog.c:1203
int errhint(const char *fmt,...)
Definition: elog.c:1317
int errmsg(const char *fmt,...)
Definition: elog.c:1070
#define WARNING
Definition: elog.h:36
#define DEBUG1
Definition: elog.h:30
void FileClose(File file)
Definition: fd.c:1978
char * FilePathName(File file)
Definition: fd.c:2461
List * list_concat(List *list1, const List *list2)
Definition: list.c:561
#define lfirst(lc)
Definition: pg_list.h:172
static int list_length(const List *l)
Definition: pg_list.h:152
#define NIL
Definition: pg_list.h:68
static void * list_nth(const List *list, int n)
Definition: pg_list.h:299
ForkNumber
Definition: relpath.h:48
TimeLineID istarttli
Definition: xlogbackup.h:32
TimeLineID starttli
Definition: xlogbackup.h:27
XLogRecPtr startpoint
Definition: xlogbackup.h:26
XLogRecPtr istartpoint
Definition: xlogbackup.h:31
Definition: pg_list.h:54
XLogRecPtr begin
Definition: timeline.h:28
TimeLineID tli
Definition: timeline.h:27
XLogRecPtr end
Definition: timeline.h:29
off_t filepos
Definition: walsummary.h:24
XLogRecPtr WaitForWalSummarization(XLogRecPtr lsn, long timeout, XLogRecPtr *pending_lsn)
File OpenWalSummaryFile(WalSummaryFile *ws, bool missing_ok)
Definition: walsummary.c:205
List * GetWalSummaries(TimeLineID tli, XLogRecPtr start_lsn, XLogRecPtr end_lsn)
Definition: walsummary.c:43
bool WalSummariesAreComplete(List *wslist, XLogRecPtr start_lsn, XLogRecPtr end_lsn, XLogRecPtr *missing_lsn)
Definition: walsummary.c:138
int ReadWalSummary(void *wal_summary_io, void *data, int length)
Definition: walsummary.c:273
List * FilterWalSummaries(List *wslist, TimeLineID tli, XLogRecPtr start_lsn, XLogRecPtr end_lsn)
Definition: walsummary.c:100
void ReportWalSummaryError(void *callback_arg, char *fmt,...)
Definition: walsummary.c:322
#define LSN_FORMAT_ARGS(lsn)
Definition: xlogdefs.h:43
#define XLogRecPtrIsInvalid(r)
Definition: xlogdefs.h:29
uint64 XLogRecPtr
Definition: xlogdefs.h:21
#define InvalidXLogRecPtr
Definition: xlogdefs.h:28
uint32 TimeLineID
Definition: xlogdefs.h:59
static BackupState * backup_state
Definition: xlogfuncs.c:40
static List * expectedTLEs
Definition: xlogrecovery.c:123

References Assert, backup_state, TimeLineHistoryEntry::begin, BlockRefTableMarkBlockModified(), BlockRefTableReaderGetBlocks(), BlockRefTableReaderNextRelation(), BlockRefTableSetLimitBlock(), BLOCKS_PER_READ, IncrementalBackupInfo::brtab, IncrementalBackupInfo::buf, CreateBlockRefTableReader(), StringInfoData::data, DEBUG1, DestroyBlockRefTableReader(), TimeLineHistoryEntry::end, ereport, errcode(), errdetail(), errhint(), errmsg(), errmsg_internal(), ERROR, expectedTLEs, WalSummaryIO::file, FileClose(), FilePathName(), WalSummaryIO::filepos, FilterWalSummaries(), GetCurrentTimestamp(), GetWalSummaries(), i, InvalidXLogRecPtr, BackupState::istartpoint, BackupState::istarttli, lfirst, list_concat(), list_length(), list_nth(), LSN_FORMAT_ARGS, IncrementalBackupInfo::manifest_wal_ranges, IncrementalBackupInfo::mcxt, MemoryContextSwitchTo(), NIL, OpenWalSummaryFile(), palloc0(), range(), readTimeLineHistory(), ReadWalSummary(), ReportWalSummaryError(), BackupState::startpoint, BackupState::starttli, TimestampDifferenceMilliseconds(), TimeLineHistoryEntry::tli, WaitForWalSummarization(), WalSummariesAreComplete(), WARNING, and XLogRecPtrIsInvalid.

Referenced by perform_base_backup().