result = pg_malloc(sizeof(manifest_data *) * n_backups); for (i = 0; i < n_backups; ++i)
result[i] = load_backup_manifest(backup_directories[i]);
return result;
}
/* *Parsethebackup_manifestfileinthenamedbackupdirectory.Constructa *hashtablewithinformationaboutallthefilesitmentions,andalinked *listofalltheWALrangesitmentions. * *Ifthebackup_manifestfilesimplydoesn'texist,logsawarningandreturns *NULL.Anyothererror,oranyerrorparsingthecontentsofthefile,is *fatal.
*/
manifest_data *
load_backup_manifest(char *backup_directory)
{ char pathname[MAXPGPATH]; int fd; struct stat statbuf;
off_t estimate;
uint32 initial_size;
manifest_files_hash *ht; char *buffer; int rc;
JsonManifestParseContext context;
manifest_data *result; int chunk_size = READ_CHUNK_SIZE;
/* Open the manifest file. */
snprintf(pathname, MAXPGPATH, "%s/backup_manifest", backup_directory); if ((fd = open(pathname, O_RDONLY | PG_BINARY, 0)) < 0)
{ if (errno == ENOENT)
{
pg_log_warning("file \"%s\" does not exist", pathname); return NULL;
}
pg_fatal("could not open file \"%s\": %m", pathname);
}
/* Figure out how big the manifest is. */ if (fstat(fd, &statbuf) != 0)
pg_fatal("could not stat file \"%s\": %m", pathname);
/* Guess how large to make the hash table based on the manifest size. */
estimate = statbuf.st_size / ESTIMATED_BYTES_PER_MANIFEST_LINE;
initial_size = Min(PG_UINT32_MAX, Max(estimate, 256));
/* Create the hash table. */
ht = manifest_files_create(initial_size, NULL);
/* *Thiscallbacktovalidatethemanifestversionnumberforincrementalbackup.
*/ staticvoid
combinebackup_version_cb(JsonManifestParseContext *context, int manifest_version)
{ /* Incremental backups supported on manifest version 2 or later */ if (manifest_version == 1)
pg_fatal("backup manifest version 1 does not support incremental backup");
}
/* Make a new entry in the hash table for this file. */
m = manifest_files_insert(manifest->files, pathname, &found); if (found)
pg_fatal("duplicate path name in backup manifest: \"%s\"", pathname);
/* Allocate and initialize a struct describing this WAL range. */
range = palloc(sizeof(manifest_wal_range));
range->tli = tli;
range->start_lsn = start_lsn;
range->end_lsn = end_lsn;
range->prev = manifest->last_wal_range;
range->next = NULL;
/* Add it to the end of the list. */ if (manifest->first_wal_range == NULL)
manifest->first_wal_range = range; else
manifest->last_wal_range->next = range;
manifest->last_wal_range = range;
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.16 Sekunden
(vorverarbeitet am 2026-08-07)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.