From 48d89c9c1b485f429dc89fc11a179d18d056d86e Mon Sep 17 00:00:00 2001 From: Karina <55838532+Green-Chan@users.noreply.github.com> Date: Thu, 24 Apr 2025 14:11:49 +0300 Subject: [PATCH] Adjust max_prepared_transactions only when it is default (#7712) DESCRIPTION: Adjusts max_prepared_transactions only when it's set to default on PG >= 16 Fixes #7711. Change AdjustMaxPreparedTransactions to really check if max_prepared_transactions is explicitly set by user, and only adjust max_prepared_transactions when it is default. This fixes 021_twophase test failure with loaded Citus library after postgres/postgres@b39c5272. Co-authored-by: Karina Litskevich --- .../distributed/transaction/transaction_management.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/backend/distributed/transaction/transaction_management.c b/src/backend/distributed/transaction/transaction_management.c index d12657772..16c5c56fa 100644 --- a/src/backend/distributed/transaction/transaction_management.c +++ b/src/backend/distributed/transaction/transaction_management.c @@ -802,8 +802,18 @@ AdjustMaxPreparedTransactions(void) * (connections * 2 currently). If the user explicitly configured 2PC, we * leave the configuration alone - there might have been intent behind the * decision. + * + * find_option is declared static in guc.c for older versions, so we can't + * really check if max_prepared_xacts is configured by the user explicitly, + * so check if it's value is default. */ +#if PG_VERSION_NUM >= PG_VERSION_16 + struct config_generic *gconf = find_option("max_prepared_transactions", + false, false, ERROR); + if (gconf->source == PGC_S_DEFAULT) +#else if (max_prepared_xacts == 0) +#endif { char newvalue[12];