diff --git a/doc/xml/release/2024/2.53.xml b/doc/xml/release/2024/2.53.xml index f3fff3d5f..a37890679 100644 --- a/doc/xml/release/2024/2.53.xml +++ b/doc/xml/release/2024/2.53.xml @@ -1,2 +1,16 @@ + + + + + + + + + + +

Allow alternative WAL segment sizes for PostgreSQL ≤ 10.

+
+
+
diff --git a/src/command/archive/common.c b/src/command/archive/common.c index 9618bbd9b..39b42d91f 100644 --- a/src/command/archive/common.c +++ b/src/command/archive/common.c @@ -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; diff --git a/src/postgres/interface.c b/src/postgres/interface.c index f083efe86..127ef3fa5 100644 --- a/src/postgres/interface.c +++ b/src/postgres/interface.c @@ -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); } diff --git a/src/postgres/interface.h b/src/postgres/interface.h index fbfac61c8..e628591b6 100644 --- a/src/postgres/interface.h +++ b/src/postgres/interface.h @@ -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. ***********************************************************************************************************************************/ diff --git a/test/src/common/harnessPostgres.c b/test/src/common/harnessPostgres.c index e2cd94744..091507b1d 100644 --- a/test/src/common/harnessPostgres.c +++ b/test/src/common/harnessPostgres.c @@ -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) diff --git a/test/src/common/harnessPostgres.h b/test/src/common/harnessPostgres.h index bc91aa113..f8dcfc1d5 100644 --- a/test/src/common/harnessPostgres.h +++ b/test/src/common/harnessPostgres.h @@ -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 ***********************************************************************************************************************************/ diff --git a/test/src/module/command/verifyTest.c b/test/src/module/command/verifyTest.c index 0b6d2d896..43a790fad 100644 --- a/test/src/module/command/verifyTest.c +++ b/test/src/module/command/verifyTest.c @@ -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"); diff --git a/test/src/module/postgres/interfaceTest.c b/test/src/module/postgres/interfaceTest.c index 33eb212f0..39c6e0ec3 100644 --- a/test/src/module/postgres/interfaceTest.c +++ b/test/src/module/postgres/interfaceTest.c @@ -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"); } // *****************************************************************************************************************************