You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-07-05 00:28:52 +02:00
Support configurable WAL segment size.
PostgreSQL 11 introduces configurable WAL segment sizes, from 1MB to 1GB. There are two areas that needed to be updated to support this: building the archive-get queue and checking that WAL has been archived after a backup. Both operations require the WAL segment size to properly build a list. Checking the archive after a backup is still implemented in Perl and has an active database connection, so just get the WAL segment size from the database. The archive-get command does not have a connection to the database, so get the WAL segment size from pg_control instead. This requires a deeper inspection of pg_control than has been done in the past, so it seemed best to copy the relevant data structures from each version of PostgreSQL and build a generic interface layer to address them. While this approach is a bit verbose, it has the advantage of being relatively simple, and can easily be updated for new versions of PostgreSQL. Since the integration tests generate pg_control files for testing, teach Perl how to generate files with the correct offsets for both 32-bit and 64-bit architectures.
This commit is contained in:
61
src/postgres/interface.h
Normal file
61
src/postgres/interface.h
Normal file
@ -0,0 +1,61 @@
|
||||
/***********************************************************************************************************************************
|
||||
PostgreSQL Interface
|
||||
***********************************************************************************************************************************/
|
||||
#ifndef POSTGRES_INTERFACE_H
|
||||
#define POSTGRES_INTERFACE_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "common/type/string.h"
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Defines for various Postgres paths and files
|
||||
***********************************************************************************************************************************/
|
||||
#define PG_FILE_PGCONTROL "pg_control"
|
||||
|
||||
#define PG_PATH_GLOBAL "global"
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
PostgreSQL Control File Info
|
||||
***********************************************************************************************************************************/
|
||||
typedef struct PgControl
|
||||
{
|
||||
unsigned int version;
|
||||
uint64_t systemId;
|
||||
|
||||
uint32_t controlVersion;
|
||||
uint32_t catalogVersion;
|
||||
|
||||
unsigned int pageSize;
|
||||
unsigned int walSegmentSize;
|
||||
|
||||
bool pageChecksum;
|
||||
} PgControl;
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Functions
|
||||
***********************************************************************************************************************************/
|
||||
PgControl pgControlFromFile(const String *pgPath);
|
||||
PgControl pgControlFromBuffer(const Buffer *controlFile);
|
||||
unsigned int pgVersionFromStr(const String *version);
|
||||
String *pgVersionToStr(unsigned int version);
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Test Functions
|
||||
***********************************************************************************************************************************/
|
||||
#ifdef DEBUG
|
||||
Buffer *pgControlTestToBuffer(PgControl pgControl);
|
||||
#endif
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Macros for function logging
|
||||
***********************************************************************************************************************************/
|
||||
String *pgControlToLog(const PgControl *pgControl);
|
||||
|
||||
#define FUNCTION_DEBUG_PG_CONTROL_TYPE \
|
||||
PgControl
|
||||
#define FUNCTION_DEBUG_PG_CONTROL_FORMAT(value, buffer, bufferSize) \
|
||||
FUNCTION_DEBUG_STRING_OBJECT_FORMAT(&value, pgControlToLog, buffer, bufferSize)
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user