1/*-------------------------------------------------------------------------
3 * basebackup_incremental.c
4 * code for incremental backup support
6 * This code isn't actually in charge of taking an incremental backup;
7 * the actual construction of the incremental backup happens in
8 * basebackup.c. Here, we're concerned with providing the necessary
9 * supports for that operation. In particular, we need to parse the
10 * backup manifest supplied by the user taking the incremental backup
11 * and extract the required information from it.
13 * Portions Copyright (c) 2010-2025, PostgreSQL Global Development Group
16 * src/backend/backup/basebackup_incremental.c
18 *-------------------------------------------------------------------------
32 #define BLOCKS_PER_READ 512
35 * We expect to find the last lines of the manifest, including the checksum,
36 * in the last MIN_CHUNK bytes of the manifest. We trigger an incremental
37 * parse step if we are about to overflow MAX_CHUNK bytes.
39 #define MIN_CHUNK 1024
40 #define MAX_CHUNK (128 * 1024)
43 * Details extracted from the WAL ranges present in the supplied backup manifest.
53 * Details extracted from the file list present in the supplied backup manifest.
63 #define SH_PREFIX backup_file
64 #define SH_ELEMENT_TYPE backup_file_entry
65 #define SH_KEY_TYPE const char *
67 #define SH_HASH_KEY(tb, key) hash_string_pointer(key)
68 #define SH_EQUAL(tb, a, b) (strcmp(a, b) == 0)
69 #define SH_SCOPE static inline
76 /* Memory context for this object and its subsidiary objects. */
79 /* Temporary buffer for storing the manifest while parsing it. */
82 /* WAL ranges extracted from the backup manifest. */
86 * Files extracted from the backup manifest.
88 * We don't really need this information, because we use WAL summaries to
89 * figure out what's changed. It would be unsafe to just rely on the list
90 * of files that existed before, because it's possible for a file to be
91 * removed and a new one created with the same name and different
92 * contents. In such cases, the whole file must still be sent. We can tell
93 * from the WAL summaries whether that happened, but not from the file
96 * Nonetheless, this data is useful for sanity checking. If a file that we
97 * think we shouldn't need to send is not present in the manifest for the
98 * prior backup, something has gone terribly wrong. We retain the file
99 * names and sizes, but not the checksums or last modified times, for
100 * which we have no use.
102 * One significant downside of storing this data is that it consumes
103 * memory. If that turns out to be a problem, we might have to decide not
104 * to retain this information, or to make it optional.
109 * Block-reference table for the incremental backup.
111 * It's possible that storing the entire block-reference table in memory
112 * will be a problem for some users. The in-memory format that we're using
113 * here is pretty efficient, converging to little more than 1 bit per
114 * block for relation forks with large numbers of modified blocks. It's
115 * possible, however, that if you try to perform an incremental backup of
116 * a database with a sufficiently large number of relations on a
117 * sufficiently small machine, you could run out of memory here. If that
118 * turns out to be a problem in practice, we'll need to be more clever.
123 * State object for incremental JSON parsing
129 int manifest_version);
131 uint64 manifest_system_identifier);
133 const char *pathname,
137 uint8 *checksum_payload);
148 * Create a new object for storing information extracted from the manifest
149 * supplied when creating an incremental backup.
165 * It's hard to guess how many files a "typical" installation will have in
166 * the data directory, but a fresh initdb creates almost 1000 files as of
167 * this writing, so it seems to make sense for our estimate to
168 * substantially higher.
173 /* Parse the manifest. */
189 * Before taking an incremental backup, the caller must supply the backup
190 * manifest from a prior backup. Each chunk of manifest data received
191 * from the client should be passed to this function.
199 /* Switch to our memory context. */
205 * time for an incremental parse. We'll do all but the last MIN_CHUNK
206 * so that we have enough left for the final piece.
210 /* now remove what we just parsed */
218 /* Switch back to previous memory context. */
223 * Finalize an IncrementalBackupInfo object after all manifest data has
224 * been supplied via calls to AppendIncrementalManifestData.
231 /* Switch to our memory context. */
234 /* Parse the last chunk of the manifest */
238 /* Done with the buffer, so release memory. */
242 /* Done with inc_state, so release that memory too */
245 /* Switch back to previous memory context. */
250 * Prepare to take an incremental backup.
252 * Before this function is called, AppendIncrementalManifestData and
253 * FinalizeIncrementalManifest should have already been called to pass all
254 * the manifest data to this object.
256 * This function performs sanity checks on the data extracted from the
257 * manifest and figures out for which WAL ranges we need summaries, and
258 * whether those summaries are available. Then, it reads and combines the
259 * data from those summary files. It also updates the backup_state with the
260 * reference TLI and LSN for the prior backup.
269 *required_wslist =
NIL;
274 bool found_backup_start_tli =
false;
281 /* Switch to our memory context. */
285 * A valid backup manifest must always contain at least one WAL range
286 * (usually exactly one, unless the backup spanned a timeline switch).
289 if (num_wal_ranges == 0)
291 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
292 errmsg(
"manifest contains no required WAL ranges")));
295 * Match up the TLIs that appear in the WAL ranges of the backup manifest
296 * with those that appear in this server's timeline history. We expect
297 * every backup_wal_range to match to a TimeLineHistoryEntry; if it does
298 * not, that's an error.
300 * This loop also decides which of the WAL ranges is the manifest is most
301 * ancient and which one is the newest, according to the timeline history
302 * of this server, and stores TLIs of those WAL ranges into
303 * earliest_wal_range_tli and latest_wal_range_tli. It also updates
304 * earliest_wal_range_start_lsn to the start LSN of the WAL range for
305 * earliest_wal_range_tli.
307 * Note that the return value of readTimeLineHistory puts the latest
308 * timeline at the beginning of the list, not the end. Hence, the earliest
309 * TLI is the one that occurs nearest the end of the list returned by
310 * readTimeLineHistory, and the latest TLI is the one that occurs closest
315 for (
i = 0;
i < num_wal_ranges; ++
i)
318 bool saw_earliest_wal_range_tli =
false;
319 bool saw_latest_wal_range_tli =
false;
321 /* Search this server's history for this WAL range's TLI. */
332 if (tle->
tli == earliest_wal_range_tli)
333 saw_earliest_wal_range_tli =
true;
334 if (tle->
tli == latest_wal_range_tli)
335 saw_latest_wal_range_tli =
true;
339 * An incremental backup can only be taken relative to a backup that
340 * represents a previous state of this server. If the backup requires
341 * WAL from a timeline that's not in our history, that definitely
346 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
347 errmsg(
"timeline %u found in manifest, but not in this server's history",
351 * If we found this TLI in the server's history before encountering
352 * the latest TLI seen so far in the server's history, then this TLI
353 * is the latest one seen so far.
355 * If on the other hand we saw the earliest TLI seen so far before
356 * finding this TLI, this TLI is earlier than the earliest one seen so
357 * far. And if this is the first TLI for which we've searched, it's
358 * also the earliest one seen so far.
360 * On the first loop iteration, both things should necessarily be
363 if (!saw_latest_wal_range_tli)
364 latest_wal_range_tli =
range->tli;
365 if (earliest_wal_range_tli == 0 || saw_earliest_wal_range_tli)
367 earliest_wal_range_tli =
range->tli;
368 earliest_wal_range_start_lsn =
range->start_lsn;
373 * Propagate information about the prior backup into the backup_label that
374 * will be generated for this backup.
380 * Sanity check start and end LSNs for the WAL ranges in the manifest.
382 * Commonly, there won't be any timeline switches during the prior backup
383 * at all, but if there are, they should happen at the same LSNs that this
384 * server switched timelines.
386 * Whether there are any timeline switches during the prior backup or not,
387 * the prior backup shouldn't require any WAL from a timeline prior to the
388 * start of that timeline. It also shouldn't require any WAL from later
389 * than the start of this backup.
391 * If any of these sanity checks fail, one possible explanation is that
392 * the user has generated WAL on the same timeline with the same LSNs more
393 * than once. For instance, if two standbys running on timeline 1 were
394 * both promoted and (due to a broken archiving setup) both selected new
395 * timeline ID 2, then it's possible that one of these checks might trip.
397 * Note that there are lots of ways for the user to do something very bad
398 * without tripping any of these checks, and they are not intended to be
399 * comprehensive. It's pretty hard to see how we could be certain of
400 * anything here. However, if there's a problem staring us right in the
401 * face, it's best to report it, so we do.
403 for (
i = 0;
i < num_wal_ranges; ++
i)
407 if (
range->tli == earliest_wal_range_tli)
411 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
412 errmsg(
"manifest requires WAL from initial timeline %u starting at %X/%08X, but that timeline begins at %X/%08X",
421 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
422 errmsg(
"manifest requires WAL from continuation timeline %u starting at %X/%08X, but that timeline begins at %X/%08X",
428 if (
range->tli == latest_wal_range_tli)
432 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
433 errmsg(
"manifest requires WAL from final timeline %u ending at %X/%08X, but this backup starts at %X/%08X",
437 errhint(
"This can happen for incremental backups on a standby if there was little activity since the previous backup.")));
443 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
444 errmsg(
"manifest requires WAL from non-final timeline %u ending at %X/%08X, but this server switched timelines at %X/%08X",
453 * Wait for WAL summarization to catch up to the backup start LSN. This
454 * will throw an error if the WAL summarizer appears to be stuck. If WAL
455 * summarization gets disabled while we're waiting, this will return
456 * immediately, and we'll error out further down if the WAL summaries are
462 * Retrieve a list of all WAL summaries on any timeline that overlap with
463 * the LSN range of interest. We could instead call GetWalSummaries() once
464 * per timeline in the loop that follows, but that would involve reading
465 * the directory multiple times. It should be mildly faster - and perhaps
466 * a bit safer - to do it just once.
472 * We need WAL summaries for everything that happened during the prior
473 * backup and everything that happened afterward up until the point where
474 * the current backup started.
485 * Working through the history of this server from the current
486 * timeline backwards, we skip everything until we find the timeline
487 * where this backup started. Most of the time, this means we won't
488 * skip anything at all, as it's unlikely that the timeline has
489 * changed since the beginning of the backup moments ago.
493 found_backup_start_tli =
true;
496 else if (!found_backup_start_tli)
500 * Find the summaries that overlap the LSN range of interest for this
501 * timeline. If this is the earliest timeline involved, the range of
502 * interest begins with the start LSN of the prior backup; otherwise,
503 * it begins at the LSN at which this timeline came into existence. If
504 * this is the latest TLI involved, the range of interest ends at the
505 * start LSN of the current backup; otherwise, it ends at the point
506 * where we switched from this timeline to the next one.
508 if (tle->
tli == earliest_wal_range_tli)
509 tli_start_lsn = earliest_wal_range_start_lsn;
511 tli_start_lsn, tli_end_lsn);
514 * There is no guarantee that the WAL summaries we found cover the
515 * entire range of LSNs for which summaries are required, or indeed
516 * that we found any WAL summaries at all. Check whether we have a
517 * problem of that sort.
524 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
525 errmsg(
"WAL summaries are required on timeline %u from %X/%08X to %X/%08X, but no summaries for that timeline and LSN range exist",
531 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
532 errmsg(
"WAL summaries are required on timeline %u from %X/%08X to %X/%08X, but the summaries for that timeline and LSN range are incomplete",
536 errdetail(
"The first unsummarized LSN in this range is %X/%08X.",
541 * Remember that we need to read these summaries.
543 * Technically, it's possible that this could read more files than
544 * required, since tli_wslist in theory could contain redundant
545 * summaries. For instance, if we have a summary from 0/10000000 to
546 * 0/20000000 and also one from 0/00000000 to 0/30000000, then the
547 * latter subsumes the former and the former could be ignored.
549 * We ignore this possibility because the WAL summarizer only tries to
550 * generate summaries that do not overlap. If somehow they exist,
551 * we'll do a bit of extra work but the results should still be
554 required_wslist =
list_concat(required_wslist, tli_wslist);
557 * Timelines earlier than the one in which the prior backup began are
560 if (tle->
tli == earliest_wal_range_tli)
565 * Read all of the required block reference table files and merge all of
566 * the data into a single in-memory block reference table.
568 * See the comments for struct IncrementalBackupInfo for some thoughts on
572 foreach(lc, required_wslist)
594 forknum, limit_block);
606 for (
i = 0;
i < nblocks; ++
i)
615 /* Switch back to previous memory context. */
620 * Get the pathname that should be used when a file is sent incrementally.
622 * The result is a palloc'd string.
635 lastslash = strrchr(path.
str,
'/');
636 Assert(lastslash != NULL);
640 ipath =
psprintf(
"%s/INCREMENTAL.%s.%u", path.
str, lastslash + 1, segno);
642 ipath =
psprintf(
"%s/INCREMENTAL.%s", path.
str, lastslash + 1);
648 * How should we back up a particular file as part of an incremental backup?
650 * If the return value is BACK_UP_FILE_FULLY, caller should back up the whole
651 * file just as if this were not an incremental backup. The contents of the
652 * relative_block_numbers array are unspecified in this case.
654 * If the return value is BACK_UP_FILE_INCREMENTALLY, caller should include
655 * an incremental file in the backup instead of the entire file. On return,
656 * *num_blocks_required will be set to the number of blocks that need to be
657 * sent, and the actual block numbers will have been stored in
658 * relative_block_numbers, which should be an array of at least RELSEG_SIZE.
659 * In addition, *truncation_block_length will be set to the value that should
660 * be included in the incremental file.
666 unsigned segno,
size_t size,
667 unsigned *num_blocks_required,
669 unsigned *truncation_block_length)
679 /* Should only be called after PrepareForIncrementalBackup. */
683 * dboid could be InvalidOid if shared rel, but spcoid and relfilenumber
684 * should have legal values.
690 * If the file size is too large or not a multiple of BLCKSZ, then
691 * something weird is happening, so give up and send the whole file.
693 if ((size % BLCKSZ) != 0 || size / BLCKSZ > RELSEG_SIZE)
697 * The free-space map fork is not properly WAL-logged, so we need to
698 * backup the entire file every time.
704 * If this file was not part of the prior backup, back it up fully.
706 * If this file was created after the prior backup and before the start of
707 * the current backup, then the WAL summary information will tell us to
708 * back up the whole file. However, if this file was created after the
709 * start of the current backup, then the WAL summary won't know anything
710 * about it. Without this logic, we would erroneously conclude that it was
711 * OK to send it incrementally.
713 * Note that the file could have existed at the time of the prior backup,
714 * gotten deleted, and then a new file with the same name could have been
715 * created. In that case, this logic won't prevent the file from being
716 * backed up incrementally. But, if the deletion happened before the start
717 * of the current backup, the limit block will be 0, inducing a full
718 * backup. If the deletion happened after the start of the current backup,
719 * reconstruction will erroneously combine blocks from the current
720 * lifespan of the file with blocks from the previous lifespan -- but in
721 * this type of case, WAL replay to reach backup consistency should remove
722 * and recreate the file anyway, so the initial bogus contents should not
736 * Look up the special block reference table entry for the database as a
740 rlocator.
dbOid = dboid;
743 &limit_block) != NULL)
746 * According to the WAL summary, this database OID/tablespace OID
747 * pairing has been created since the previous backup. So, everything
748 * in it must be backed up fully.
753 /* Look up the block reference table entry for this relfilenode. */
759 * If there is no entry, then there have been no WAL-logged changes to the
760 * relation since the predecessor backup was taken, so we can back it up
761 * incrementally and need not include any modified blocks.
763 * However, if the file is zero-length, we should do a full backup,
764 * because an incremental file is always more than zero length, and it's
765 * silly to take an incremental backup when a full backup would be
768 if (brtentry == NULL)
772 *num_blocks_required = 0;
773 *truncation_block_length = size / BLCKSZ;
778 * If the limit_block is less than or equal to the point where this
779 * segment starts, send the whole file.
781 if (limit_block <= segno * RELSEG_SIZE)
785 * Get relevant entries from the block reference table entry.
787 * We shouldn't overflow computing the start or stop block numbers, but if
788 * it manages to happen somehow, detect it and throw an error.
790 start_blkno = segno * RELSEG_SIZE;
791 stop_blkno = start_blkno + (size / BLCKSZ);
792 if (start_blkno / RELSEG_SIZE != segno || stop_blkno < start_blkno)
794 errcode(ERRCODE_INTERNAL_ERROR),
795 errmsg_internal(
"overflow computing block number bounds for segment %u with size %zu",
799 * This will write *absolute* block numbers into the output array, but
800 * we'll transpose them below.
803 relative_block_numbers, RELSEG_SIZE);
804 Assert(nblocks <= RELSEG_SIZE);
807 * If we're going to have to send nearly all of the blocks, then just send
808 * the whole file, because that won't require much extra storage or
809 * transfer and will speed up and simplify backup restoration. It's not
810 * clear what threshold is most appropriate here and perhaps it ought to
811 * be configurable, but for now we're just going to say that if we'd need
812 * to send 90% of the blocks anyway, give up and send the whole file.
814 * NB: If you change the threshold here, at least make sure to back up the
815 * file fully when every single block must be sent, because there's
816 * nothing good about sending an incremental file in that case.
818 if (nblocks * BLCKSZ > size * 0.9)
822 * Looks like we can send an incremental file, so sort the block numbers
823 * and then transpose them from absolute block numbers to relative block
824 * numbers if necessary.
826 * NB: If the block reference table was using the bitmap representation
827 * for a given chunk, the block numbers in that chunk will already be
828 * sorted, but when the array-of-offsets representation is used, we can
829 * receive block numbers here out of order.
833 if (start_blkno != 0)
835 for (
i = 0;
i < nblocks; ++
i)
836 relative_block_numbers[
i] -= start_blkno;
838 *num_blocks_required = nblocks;
841 * The truncation block length is the minimum length of the reconstructed
842 * file. Any block numbers below this threshold that are not present in
843 * the backup need to be fetched from the prior backup. At or above this
844 * threshold, blocks should only be included in the result if they are
845 * present in the backup. (This may require inserting zero blocks if the
846 * blocks included in the backup are non-consecutive.)
848 *truncation_block_length = size / BLCKSZ;
851 unsigned relative_limit = limit_block - segno * RELSEG_SIZE;
853 if (*truncation_block_length < relative_limit)
854 *truncation_block_length = relative_limit;
857 /* Send it incrementally. */
862 * Compute the size for a header of an incremental file containing a given
863 * number of blocks. The header is rounded to a multiple of BLCKSZ, but
864 * only if the file will store some block data.
871 /* Make sure we're not going to overflow. */
872 Assert(num_blocks_required <= RELSEG_SIZE);
875 * Three four byte quantities (magic number, truncation block length,
876 * block count) followed by block numbers.
881 * Round the header size to a multiple of BLCKSZ - when not a multiple of
882 * BLCKSZ, add the missing fraction of a block. But do this only if the
883 * file will store data for some blocks, otherwise keep it small.
885 if ((num_blocks_required > 0) && (result % BLCKSZ != 0))
886 result += BLCKSZ - (result % BLCKSZ);
892 * Compute the size for an incremental file containing a given number of blocks.
899 /* Make sure we're not going to overflow. */
900 Assert(num_blocks_required <= RELSEG_SIZE);
903 * Header with three four byte quantities (magic number, truncation block
904 * length, block count) followed by block numbers, rounded to a multiple
905 * of BLCKSZ (for files with block data), followed by block contents.
908 result += BLCKSZ * num_blocks_required;
914 * Helper function for filemap hash table.
919 unsigned char *ss = (
unsigned char *) s;
925 * This callback to validate the manifest version for incremental backup.
929 int manifest_version)
931 /* Incremental backups don't work with manifest version 1 */
932 if (manifest_version == 1)
934 "backup manifest version 1 does not support incremental backup");
938 * This callback to validate the manifest system identifier against the current
943 uint64 manifest_system_identifier)
947 /* Get system identifier of current system */
950 if (manifest_system_identifier != system_identifier)
952 "system identifier in backup manifest is %" PRIu64
", but database system identifier is %" PRIu64,
953 manifest_system_identifier,
958 * This callback is invoked for each file mentioned in the backup manifest.
960 * We store the path to each file and the size of each file for sanity-checking
961 * purposes. For further details, see comments for IncrementalBackupInfo.
965 const char *pathname,
uint64 size,
968 uint8 *checksum_payload)
984 * This callback is invoked for each WAL range mentioned in the backup
987 * We're just interested in learning the oldest LSN and the corresponding TLI
988 * that appear in any WAL range.
999 range->start_lsn = start_lsn;
1000 range->end_lsn = end_lsn;
1005 * This callback is invoked if an error occurs while parsing the backup
1033 * Quicksort comparator for block numbers.
List * readTimeLineHistory(TimeLineID targetTLI)
void AppendIncrementalManifestData(IncrementalBackupInfo *ib, const char *data, int len)
static void manifest_process_version(JsonManifestParseContext *context, int manifest_version)
static pg_noreturn void static int compare_block_numbers(const void *a, const void *b)
static uint32 hash_string_pointer(const char *s)
size_t GetIncrementalHeaderSize(unsigned num_blocks_required)
static void manifest_process_system_identifier(JsonManifestParseContext *context, uint64 manifest_system_identifier)
size_t GetIncrementalFileSize(unsigned num_blocks_required)
static void manifest_process_file(JsonManifestParseContext *context, const char *pathname, uint64 size, pg_checksum_type checksum_type, int checksum_length, uint8 *checksum_payload)
IncrementalBackupInfo * CreateIncrementalBackupInfo(MemoryContext mcxt)
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)
static pg_noreturn void manifest_report_error(JsonManifestParseContext *context, const char *fmt,...) pg_attribute_printf(2
char * GetIncrementalFilePath(Oid dboid, Oid spcoid, RelFileNumber relfilenumber, ForkNumber forknum, unsigned segno)
static void manifest_process_wal_range(JsonManifestParseContext *context, TimeLineID tli, XLogRecPtr start_lsn, XLogRecPtr end_lsn)
void PrepareForIncrementalBackup(IncrementalBackupInfo *ib, BackupState *backup_state)
void FinalizeIncrementalManifest(IncrementalBackupInfo *ib)
@ BACK_UP_FILE_INCREMENTALLY
BlockRefTableEntry * BlockRefTableGetEntry(BlockRefTable *brtab, const RelFileLocator *rlocator, ForkNumber forknum, BlockNumber *limit_block)
bool BlockRefTableReaderNextRelation(BlockRefTableReader *reader, RelFileLocator *rlocator, ForkNumber *forknum, BlockNumber *limit_block)
int BlockRefTableEntryGetBlocks(BlockRefTableEntry *entry, BlockNumber start_blkno, BlockNumber stop_blkno, BlockNumber *blocks, int nblocks)
void BlockRefTableMarkBlockModified(BlockRefTable *brtab, const RelFileLocator *rlocator, ForkNumber forknum, BlockNumber blknum)
BlockRefTableReader * CreateBlockRefTableReader(io_callback_fn read_callback, void *read_callback_arg, char *error_filename, report_error_fn error_callback, void *error_callback_arg)
unsigned BlockRefTableReaderGetBlocks(BlockRefTableReader *reader, BlockNumber *blocks, int nblocks)
void BlockRefTableSetLimitBlock(BlockRefTable *brtab, const RelFileLocator *rlocator, ForkNumber forknum, BlockNumber limit_block)
void DestroyBlockRefTableReader(BlockRefTableReader *reader)
void(*) BlockRefTable CreateEmptyBlockRefTable)(void)
static bool BlockNumberIsValid(BlockNumber blockNumber)
#define pg_attribute_printf(f, a)
#define OidIsValid(objectId)
int errmsg_internal(const char *fmt,...)
int errdetail(const char *fmt,...)
int errhint(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
char * FilePathName(File file)
void FileClose(File file)
uint32 hash_bytes(const unsigned char *k, int keylen)
Assert(PointerIsAligned(start, uint64))
static int pg_cmp_u32(uint32 a, uint32 b)
List * lappend(List *list, void *datum)
List * list_concat(List *list1, const List *list2)
char * MemoryContextStrdup(MemoryContext context, const char *string)
void pfree(void *pointer)
void * palloc0(Size size)
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
JsonManifestParseIncrementalState * json_parse_manifest_incremental_init(JsonManifestParseContext *context)
void json_parse_manifest_incremental_shutdown(JsonManifestParseIncrementalState *incstate)
void json_parse_manifest_incremental_chunk(JsonManifestParseIncrementalState *incstate, const char *chunk, size_t size, bool is_last)
static int list_length(const List *l)
static void * list_nth(const List *list, int n)
#define qsort(a, b, c, d)
#define INVALID_PROC_NUMBER
char * psprintf(const char *fmt,...)
static struct cvec * range(struct vars *v, chr a, chr b, int cases)
RelPathStr GetRelationPath(Oid dbOid, Oid spcOid, RelFileNumber relNumber, int procNumber, ForkNumber forkNumber)
#define RelFileNumberIsValid(relnumber)
int appendStringInfoVA(StringInfo str, const char *fmt, va_list args)
void enlargeStringInfo(StringInfo str, int needed)
void appendBinaryStringInfo(StringInfo str, const void *data, int datalen)
void initStringInfo(StringInfo str)
List * manifest_wal_ranges
backup_file_hash * manifest_files
JsonManifestParseIncrementalState * inc_state
json_manifest_per_wal_range_callback per_wal_range_cb
json_manifest_system_identifier_callback system_identifier_cb
json_manifest_error_callback error_cb
json_manifest_per_file_callback per_file_cb
json_manifest_version_callback version_cb
char str[REL_PATH_STR_MAXLEN+1]
void WaitForWalSummarization(XLogRecPtr lsn)
File OpenWalSummaryFile(WalSummaryFile *ws, bool missing_ok)
bool WalSummariesAreComplete(List *wslist, XLogRecPtr start_lsn, XLogRecPtr end_lsn, XLogRecPtr *missing_lsn)
int ReadWalSummary(void *wal_summary_io, void *data, int length)
List * GetWalSummaries(TimeLineID tli, XLogRecPtr start_lsn, XLogRecPtr end_lsn)
void ReportWalSummaryError(void *callback_arg, char *fmt,...)
List * FilterWalSummaries(List *wslist, TimeLineID tli, XLogRecPtr start_lsn, XLogRecPtr end_lsn)
uint64 GetSystemIdentifier(void)
#define LSN_FORMAT_ARGS(lsn)
#define XLogRecPtrIsInvalid(r)
#define InvalidXLogRecPtr
static BackupState * backup_state
static List * expectedTLEs