mirror of
https://github.com/postgres/postgres.git
synced 2026-03-15 15:14:05 -04:00
A manifest is a JSON document which includes (1) the file name, size, last modification time, and an optional checksum for each file backed up, (2) timelines and LSNs for whatever WAL will need to be replayed to make the backup consistent, and (3) a checksum for the manifest itself. By default, we use CRC-32C when checksumming data files, because we are trying to detect corruption and user error, not foil an adversary. However, pg_basebackup and the server-side BASE_BACKUP command now have options to select a different algorithm, so users wanting a cryptographic hash function can select SHA-224, SHA-256, SHA-384, or SHA-512. Users not wanting file checksums at all can disable them, or disable generating of the backup manifest altogether. Using a cryptographic hash function in place of CRC-32C consumes significantly more CPU cycles, which may slow down backups in some cases. A new tool called pg_validatebackup can validate a backup against the manifest. If no checksums are present, it can still check that the right files exist and that they have the expected sizes. If checksums are present, it can also verify that each file has the expected checksum. Additionally, it calls pg_waldump to verify that the expected WAL files are present and parseable. Only plain format backups can be validated directly, but tar format backups can be validated after extracting them. Robert Haas, with help, ideas, review, and testing from David Steele, Stephen Frost, Andrew Dunstan, Rushabh Lathia, Suraj Kharage, Tushar Ahuja, Rajkumar Raghuwanshi, Mark Dilger, Davinder Singh, Jeevan Chalke, Amit Kapila, Andres Freund, and Noah Misch. Discussion: http://postgr.es/m/CA+TgmoZV8dw1H2bzZ9xkKwdrk8+XYa+DC9H=F7heO2zna5T6qg@mail.gmail.com
74 lines
1.9 KiB
C
74 lines
1.9 KiB
C
/*-------------------------------------------------------------------------
|
|
*
|
|
* walsender.h
|
|
* Exports from replication/walsender.c.
|
|
*
|
|
* Portions Copyright (c) 2010-2020, PostgreSQL Global Development Group
|
|
*
|
|
* src/include/replication/walsender.h
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
#ifndef _WALSENDER_H
|
|
#define _WALSENDER_H
|
|
|
|
#include <signal.h>
|
|
|
|
/*
|
|
* What to do with a snapshot in create replication slot command.
|
|
*/
|
|
typedef enum
|
|
{
|
|
CRS_EXPORT_SNAPSHOT,
|
|
CRS_NOEXPORT_SNAPSHOT,
|
|
CRS_USE_SNAPSHOT
|
|
} CRSSnapshotAction;
|
|
|
|
/* global state */
|
|
extern bool am_walsender;
|
|
extern bool am_cascading_walsender;
|
|
extern bool am_db_walsender;
|
|
extern bool wake_wal_senders;
|
|
|
|
/* user-settable parameters */
|
|
extern int max_wal_senders;
|
|
extern int wal_sender_timeout;
|
|
extern bool log_replication_commands;
|
|
|
|
extern void InitWalSender(void);
|
|
extern bool exec_replication_command(const char *query_string);
|
|
extern void WalSndErrorCleanup(void);
|
|
extern void WalSndResourceCleanup(bool isCommit);
|
|
extern void WalSndSignals(void);
|
|
extern Size WalSndShmemSize(void);
|
|
extern void WalSndShmemInit(void);
|
|
extern void WalSndWakeup(void);
|
|
extern void WalSndInitStopping(void);
|
|
extern void WalSndWaitStopping(void);
|
|
extern void HandleWalSndInitStopping(void);
|
|
extern void WalSndRqstFileReload(void);
|
|
|
|
/*
|
|
* Remember that we want to wakeup walsenders later
|
|
*
|
|
* This is separated from doing the actual wakeup because the writeout is done
|
|
* while holding contended locks.
|
|
*/
|
|
#define WalSndWakeupRequest() \
|
|
do { wake_wal_senders = true; } while (0)
|
|
|
|
/*
|
|
* wakeup walsenders if there is work to be done
|
|
*/
|
|
#define WalSndWakeupProcessRequests() \
|
|
do \
|
|
{ \
|
|
if (wake_wal_senders) \
|
|
{ \
|
|
wake_wal_senders = false; \
|
|
if (max_wal_senders > 0) \
|
|
WalSndWakeup(); \
|
|
} \
|
|
} while (0)
|
|
|
|
#endif /* _WALSENDER_H */
|