You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-06-18 23:57:33 +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:
81
src/postgres/interface/v091.c
Normal file
81
src/postgres/interface/v091.c
Normal file
@ -0,0 +1,81 @@
|
||||
/***********************************************************************************************************************************
|
||||
PostgreSQL 9.1 Interface
|
||||
***********************************************************************************************************************************/
|
||||
#include "common/debug.h"
|
||||
#include "common/log.h"
|
||||
#include "postgres/interface/v091.h"
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Include PostgreSQL Types
|
||||
***********************************************************************************************************************************/
|
||||
#include "postgres/interface/v091.auto.c"
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Is the control file for this version of PostgreSQL?
|
||||
***********************************************************************************************************************************/
|
||||
bool
|
||||
pgInterfaceIs091(const Buffer *controlFile)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(BUFFER, controlFile);
|
||||
|
||||
FUNCTION_TEST_ASSERT(controlFile != NULL);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
ControlFileData *controlData = (ControlFileData *)bufPtr(controlFile);
|
||||
|
||||
FUNCTION_TEST_RESULT(
|
||||
BOOL, controlData->pg_control_version == PG_CONTROL_VERSION && controlData->catalog_version_no == CATALOG_VERSION_NO);
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Get information from pg_control in a common format
|
||||
***********************************************************************************************************************************/
|
||||
PgControl
|
||||
pgInterfaceControl091(const Buffer *controlFile)
|
||||
{
|
||||
FUNCTION_DEBUG_BEGIN(logLevelTrace);
|
||||
FUNCTION_DEBUG_PARAM(BUFFER, controlFile);
|
||||
|
||||
FUNCTION_TEST_ASSERT(controlFile != NULL);
|
||||
FUNCTION_TEST_ASSERT(pgInterfaceIs091(controlFile));
|
||||
FUNCTION_DEBUG_END();
|
||||
|
||||
PgControl result = {0};
|
||||
ControlFileData *controlData = (ControlFileData *)bufPtr(controlFile);
|
||||
|
||||
result.systemId = controlData->system_identifier;
|
||||
result.controlVersion = controlData->pg_control_version;
|
||||
result.catalogVersion = controlData->catalog_version_no;
|
||||
|
||||
result.pageSize = controlData->blcksz;
|
||||
result.walSegmentSize = controlData->xlog_seg_size;
|
||||
|
||||
FUNCTION_DEBUG_RESULT(PG_CONTROL, result);
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Create pg_control for testing
|
||||
***********************************************************************************************************************************/
|
||||
#ifdef DEBUG
|
||||
|
||||
void
|
||||
pgInterfaceControlTest091(PgControl pgControl, Buffer *buffer)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(PG_CONTROL, pgControl);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
ControlFileData *controlData = (ControlFileData *)bufPtr(buffer);
|
||||
|
||||
controlData->system_identifier = pgControl.systemId;
|
||||
controlData->pg_control_version = pgControl.controlVersion == 0 ? PG_CONTROL_VERSION : pgControl.controlVersion;
|
||||
controlData->catalog_version_no = pgControl.catalogVersion == 0 ? CATALOG_VERSION_NO : pgControl.catalogVersion;
|
||||
|
||||
controlData->blcksz = pgControl.pageSize;
|
||||
controlData->xlog_seg_size = pgControl.walSegmentSize;
|
||||
|
||||
FUNCTION_TEST_RESULT_VOID();
|
||||
}
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user