You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-07-05 00:28:52 +02:00
Allow alternative WAL segment sizes for PostgreSQL <= 10.
Alternative WAL segment sizes can be configured in PostgreSQL <= 10 with compile-time options. We have not allowed these before since it was not a well-tested feature of PostgreSQL. However, forks such as Greenplum allow alternative WAL segment sizes at initdb time (which are presumably well-tested) so it makes sense to allow it. Since the PostgreSQL versions in question are all EOL it is not important to have this restriction in place anymore.
This commit is contained in:
committed by
David Steele
parent
e8b965756c
commit
4ac3b82c99
@ -1,2 +1,16 @@
|
||||
<release date="XXXX-XX-XX" version="2.53dev" title="UNDER DEVELOPMENT">
|
||||
<release-core-list>
|
||||
<release-improvement-list>
|
||||
<release-item>
|
||||
<github-pull-request id="2303"/>
|
||||
|
||||
<release-item-contributor-list>
|
||||
<release-item-contributor id="viktor.kurilko"/>
|
||||
<release-item-reviewer id="david.steele"/>
|
||||
</release-item-contributor-list>
|
||||
|
||||
<p>Allow alternative WAL segment sizes for PostgreSQL &le; 10.</p>
|
||||
</release-item>
|
||||
</release-improvement-list>
|
||||
</release-core-list>
|
||||
</release>
|
||||
|
@ -420,7 +420,6 @@ walSegmentNext(const String *const walSegment, const size_t walSegmentSize, cons
|
||||
ASSERT(walSegment != NULL);
|
||||
ASSERT(strSize(walSegment) == 24);
|
||||
ASSERT(UINT32_MAX % walSegmentSize == walSegmentSize - 1);
|
||||
ASSERT(pgVersion >= PG_VERSION_11 || walSegmentSize == PG_WAL_SEGMENT_SIZE_DEFAULT);
|
||||
|
||||
// Extract WAL parts
|
||||
uint32_t timeline;
|
||||
|
@ -169,20 +169,12 @@ pgDbIsSystemId(const unsigned int id)
|
||||
Check expected WAL segment size for older PostgreSQL versions
|
||||
***********************************************************************************************************************************/
|
||||
static void
|
||||
pgWalSegmentSizeCheck(const unsigned int pgVersion, const unsigned int walSegmentSize)
|
||||
pgWalSegmentSizeCheck(const unsigned int walSegmentSize)
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(UINT, pgVersion);
|
||||
FUNCTION_TEST_PARAM(UINT, walSegmentSize);
|
||||
FUNCTION_TEST_END();
|
||||
|
||||
if (pgVersion < PG_VERSION_11 && walSegmentSize != PG_WAL_SEGMENT_SIZE_DEFAULT)
|
||||
{
|
||||
THROW_FMT(
|
||||
FormatError, "wal segment size is %u but must be %u for " PG_NAME " <= " PG_VERSION_10_Z, walSegmentSize,
|
||||
PG_WAL_SEGMENT_SIZE_DEFAULT);
|
||||
}
|
||||
|
||||
// Check that the WAL segment size is valid
|
||||
if (!IsValidWalSegSize(walSegmentSize))
|
||||
{
|
||||
@ -326,7 +318,7 @@ pgControlFromBuffer(const Buffer *const controlFile, const String *const pgVersi
|
||||
pgControlCrcValidate(controlFile, interface, pgVersionForce != NULL);
|
||||
|
||||
// Check the segment size
|
||||
pgWalSegmentSizeCheck(result.version, result.walSegmentSize);
|
||||
pgWalSegmentSizeCheck(result.walSegmentSize);
|
||||
|
||||
// Check the page size
|
||||
pgPageSizeCheck(result.pageSize);
|
||||
@ -529,7 +521,7 @@ pgWalFromBuffer(const Buffer *const walBuffer, const String *const pgVersionForc
|
||||
result.version = interface->version;
|
||||
|
||||
// Check the segment size
|
||||
pgWalSegmentSizeCheck(result.version, result.size);
|
||||
pgWalSegmentSizeCheck(result.size);
|
||||
|
||||
FUNCTION_LOG_RETURN(PG_WAL, result);
|
||||
}
|
||||
|
@ -86,14 +86,6 @@ something far larger needed but <= the minimum read size on just about any syste
|
||||
***********************************************************************************************************************************/
|
||||
#define PG_WAL_HEADER_SIZE ((unsigned int)(512))
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Define default wal segment size
|
||||
|
||||
Before PostgreSQL 11 WAL segment size could only be changed at compile time and is not known to be well-tested, so only the default
|
||||
WAL segment size is supported for versions below 11.
|
||||
***********************************************************************************************************************************/
|
||||
#define PG_WAL_SEGMENT_SIZE_DEFAULT ((unsigned int)(16 * 1024 * 1024))
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Checkpoint written into pg_control on restore. This will prevent PostgreSQL from starting if backup_label is not present.
|
||||
***********************************************************************************************************************************/
|
||||
|
@ -206,7 +206,7 @@ hrnPgControlToBuffer(const unsigned int controlVersion, const unsigned int crc,
|
||||
pgControl.pageSize = pgControl.pageSize == 0 ? pgPageSize8 : pgControl.pageSize;
|
||||
pgControl.walSegmentSize =
|
||||
pgControl.walSegmentSize == UINT_MAX ?
|
||||
0 : (pgControl.walSegmentSize == 0 ? PG_WAL_SEGMENT_SIZE_DEFAULT : pgControl.walSegmentSize);
|
||||
0 : (pgControl.walSegmentSize == 0 ? HRN_PG_WAL_SEGMENT_SIZE_DEFAULT : pgControl.walSegmentSize);
|
||||
pgControl.catalogVersion =
|
||||
pgControl.catalogVersion == 0 ? hrnPgInterfaceVersion(pgControl.version)->catalogVersion() : pgControl.catalogVersion;
|
||||
pgControl.systemId = pgControl.systemId < 100 ? hrnPgSystemId(pgControl.version) + pgControl.systemId : pgControl.systemId;
|
||||
@ -238,7 +238,7 @@ hrnPgWalToBuffer(Buffer *const walBuffer, const unsigned int magic, PgWal pgWal)
|
||||
|
||||
// Set default WAL segment size if not specified
|
||||
if (pgWal.size == 0)
|
||||
pgWal.size = PG_WAL_SEGMENT_SIZE_DEFAULT;
|
||||
pgWal.size = HRN_PG_WAL_SEGMENT_SIZE_DEFAULT;
|
||||
|
||||
// Set default system id if not specified
|
||||
if (pgWal.systemId < 100)
|
||||
|
@ -14,6 +14,11 @@ Control file size used to create pg_control
|
||||
***********************************************************************************************************************************/
|
||||
#define HRN_PG_CONTROL_SIZE 8192
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Default wal segment size
|
||||
***********************************************************************************************************************************/
|
||||
#define HRN_PG_WAL_SEGMENT_SIZE_DEFAULT ((unsigned int)(16 * 1024 * 1024))
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
System id constants by version
|
||||
***********************************************************************************************************************************/
|
||||
|
@ -404,7 +404,7 @@ testRun(void)
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
TEST_TITLE("Single WAL");
|
||||
|
||||
archiveIdResult->pgWalInfo.size = PG_WAL_SEGMENT_SIZE_DEFAULT;
|
||||
archiveIdResult->pgWalInfo.size = HRN_PG_WAL_SEGMENT_SIZE_DEFAULT;
|
||||
archiveIdResult->pgWalInfo.version = PG_VERSION_94;
|
||||
|
||||
strLstAddZ(walFileList, "000000020000000200000000-daa497dba64008db824607940609ba1cd7c6c501.gz");
|
||||
|
@ -121,13 +121,6 @@ testRun(void)
|
||||
TEST_RESULT_UINT(info.checkpoint, 0xEEFFEEFFAABBAABB, "check checkpoint");
|
||||
TEST_RESULT_UINT(info.timeline, 47, "check timeline");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
HRN_PG_CONTROL_PUT(storageTest, PG_VERSION_94, .walSegmentSize = 1024 * 1024);
|
||||
|
||||
TEST_ERROR(
|
||||
pgControlFromFile(storageTest, NULL), FormatError,
|
||||
"wal segment size is 1048576 but must be 16777216 for PostgreSQL <= 10");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
HRN_PG_CONTROL_PUT(storageTest, PG_VERSION_11, .walSegmentSize = UINT_MAX); // UINT_MAX forces size to 0
|
||||
|
||||
@ -478,37 +471,30 @@ testRun(void)
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
memset(bufPtr(result), 0, bufSize(result));
|
||||
HRN_PG_WAL_TO_BUFFER(result, PG_VERSION_11, .systemId = 0xECAFECAF, .size = PG_WAL_SEGMENT_SIZE_DEFAULT * 2);
|
||||
HRN_PG_WAL_TO_BUFFER(result, PG_VERSION_11, .systemId = 0xECAFECAF, .size = HRN_PG_WAL_SEGMENT_SIZE_DEFAULT * 2);
|
||||
storagePutP(storageNewWriteP(storageTest, walFile), result);
|
||||
|
||||
PgWal info = {0};
|
||||
TEST_ASSIGN(info, pgWalFromFile(walFile, storageTest, NULL), "get wal info v11");
|
||||
TEST_RESULT_UINT(info.systemId, 0xECAFECAF, " check system id");
|
||||
TEST_RESULT_UINT(info.version, PG_VERSION_11, " check version");
|
||||
TEST_RESULT_UINT(info.size, PG_WAL_SEGMENT_SIZE_DEFAULT * 2, " check size");
|
||||
TEST_RESULT_UINT(info.size, HRN_PG_WAL_SEGMENT_SIZE_DEFAULT * 2, " check size");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
memset(bufPtr(result), 0, bufSize(result));
|
||||
HRN_PG_WAL_TO_BUFFER(result, PG_VERSION_96, .systemId = 0xEAEAEAEA, .size = PG_WAL_SEGMENT_SIZE_DEFAULT * 2);
|
||||
|
||||
TEST_ERROR(
|
||||
pgWalFromBuffer(result, NULL), FormatError, "wal segment size is 33554432 but must be 16777216 for PostgreSQL <= 10");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
memset(bufPtr(result), 0, bufSize(result));
|
||||
HRN_PG_WAL_TO_BUFFER(result, PG_VERSION_94, .systemId = 0xEAEAEAEA, .size = PG_WAL_SEGMENT_SIZE_DEFAULT);
|
||||
HRN_PG_WAL_TO_BUFFER(result, PG_VERSION_94, .systemId = 0xEAEAEAEA, .size = HRN_PG_WAL_SEGMENT_SIZE_DEFAULT);
|
||||
storagePutP(storageNewWriteP(storageTest, walFile), result);
|
||||
|
||||
TEST_ASSIGN(info, pgWalFromFile(walFile, storageTest, NULL), "get wal info v9.4");
|
||||
TEST_RESULT_UINT(info.systemId, 0xEAEAEAEA, " check system id");
|
||||
TEST_RESULT_UINT(info.version, PG_VERSION_94, " check version");
|
||||
TEST_RESULT_UINT(info.size, PG_WAL_SEGMENT_SIZE_DEFAULT, " check size");
|
||||
TEST_RESULT_UINT(info.size, HRN_PG_WAL_SEGMENT_SIZE_DEFAULT, " check size");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
TEST_TITLE("force WAL version");
|
||||
|
||||
memset(bufPtr(result), 0, bufSize(result));
|
||||
HRN_PG_WAL_OVERRIDE_TO_BUFFER(result, PG_VERSION_15, 777, .systemId = 0xFAFAFAFA, .size = PG_WAL_SEGMENT_SIZE_DEFAULT);
|
||||
HRN_PG_WAL_OVERRIDE_TO_BUFFER(result, PG_VERSION_15, 777, .systemId = 0xFAFAFAFA, .size = HRN_PG_WAL_SEGMENT_SIZE_DEFAULT);
|
||||
storagePutP(storageNewWriteP(storageTest, walFile), result);
|
||||
|
||||
TEST_ERROR(
|
||||
@ -519,7 +505,7 @@ testRun(void)
|
||||
TEST_ASSIGN(info, pgWalFromFile(walFile, storageTest, STRDEF(PG_VERSION_15_Z)), "force wal info v15");
|
||||
TEST_RESULT_UINT(info.systemId, 0xFAFAFAFA, "check system id");
|
||||
TEST_RESULT_UINT(info.version, PG_VERSION_15, " check version");
|
||||
TEST_RESULT_UINT(info.size, PG_WAL_SEGMENT_SIZE_DEFAULT, " check size");
|
||||
TEST_RESULT_UINT(info.size, HRN_PG_WAL_SEGMENT_SIZE_DEFAULT, " check size");
|
||||
}
|
||||
|
||||
// *****************************************************************************************************************************
|
||||
|
Reference in New Issue
Block a user