Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uY7Ba-001JJb-5D for pgsql-hackers@arkaria.postgresql.org; Sat, 05 Jul 2025 18:00:26 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1uY7BW-008dw8-N9 for pgsql-hackers@arkaria.postgresql.org; Sat, 05 Jul 2025 18:00:23 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uY7BW-008dvz-DG for pgsql-hackers@lists.postgresql.org; Sat, 05 Jul 2025 18:00:23 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1uY7BV-005kPQ-1U for pgsql-hackers@postgresql.org; Sat, 05 Jul 2025 18:00:22 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 565I07Wh061811; Sat, 5 Jul 2025 14:00:07 -0400 From: Tom Lane To: Fujii Masao cc: "Hayato Kuroda (Fujitsu)" , Andy Fan , "'Michael Paquier'" , PostgreSQL Hackers Subject: Re: A assert failure when initdb with track_commit_timestamp=on In-reply-to: <9093.1751736193@sss.pgh.pa.us> References: <87plejmnpy.fsf@163.com> <1f8f703d-72e8-4d05-ab16-ff0403a1d19d@oss.nttdata.com> <87o6u19z9w.fsf@163.com> <3694f39a-7148-4197-91fe-25f3d01222b7@oss.nttdata.com> <249358.1751643017@sss.pgh.pa.us> <262595.1751649473@sss.pgh.pa.us> <75d59502-b571-4df8-9269-fd07cee52dd4@oss.nttdata.com> <9093.1751736193@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Sat, 05 Jul 2025 13:23:13 -0400" MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0" Content-ID: <61711.1751738348.0@sss.pgh.pa.us> Date: Sat, 05 Jul 2025 14:00:07 -0400 Message-ID: <61810.1751738407@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk ------- =_aaaaaaaaaa0 Content-Type: text/plain; charset="us-ascii" Content-ID: <61711.1751738348.1@sss.pgh.pa.us> I wrote: > Fujii Masao writes: >> Or GUC ignore_system_indexes also should be treated in the same way >> as transaction_timeout? > Yes, I'd say we ought to mark that GUC as don't-accept-in-bootstrap > too. I've not done any research about what other GUCs can break > initdb, but now I'm starting to suspect there are several. Here's a fleshed-out implementation of Hayato-san's idea. I've not done anything about reverting 5a6c39b6d, nor have I done any checks to see if there are other GUCs we ought to mark similarly. (But at this point I'd be prepared to bet that there are.) regards, tom lane ------- =_aaaaaaaaaa0 Content-Type: text/x-diff; name="v1-disallow-setting-some-GUCs-in-bootstrap.patch"; charset="us-ascii" Content-ID: <61711.1751738348.2@sss.pgh.pa.us> Content-Description: v1-disallow-setting-some-GUCs-in-bootstrap.patch Content-Transfer-Encoding: quoted-printable diff --git a/src/backend/bootstrap/bootstrap.c b/src/backend/bootstrap/boo= tstrap.c index fc8638c1b61..f6ca9e8632c 100644 --- a/src/backend/bootstrap/bootstrap.c +++ b/src/backend/bootstrap/bootstrap.c @@ -213,6 +213,12 @@ BootstrapModeMain(int argc, char *argv[], bool check_= only) /* Set defaults, to be overridden by explicit options below */ InitializeGUCOptions(); = + /* Override ignore_system_indexes: we have no indexes during bootstrap *= / + IgnoreSystemIndexes =3D true; + + /* Set bootstrap mode; note that this locks down values of some GUCs */ + SetProcessingMode(BootstrapProcessing); + /* an initial --boot or --check should be present */ Assert(argc > 1 && (strcmp(argv[1], "--boot") =3D=3D 0 @@ -321,9 +327,6 @@ BootstrapModeMain(int argc, char *argv[], bool check_o= nly) = CreateDataDirLockFile(false); = - SetProcessingMode(BootstrapProcessing); - IgnoreSystemIndexes =3D true; - InitializeMaxBackends(); = /* diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 667df448732..215a20a1f06 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -3464,6 +3464,15 @@ set_config_with_handle(const char *name, config_han= dle *handle, return 0; } = + /* + * Certain GUCs aren't safe to enable during bootstrap mode. Silently + * ignore attempts to set them to non-default values. + */ + if (unlikely(IsBootstrapProcessingMode()) && + (record->flags & GUC_NOT_IN_BOOTSTRAP) && + source > PGC_S_DYNAMIC_DEFAULT) + changeVal =3D false; + /* * Check if the option can be set at this time. See guc.h for the precis= e * rules. diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/= guc_tables.c index 511dc32d519..064c6ba09e2 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -1089,7 +1089,8 @@ struct config_bool ConfigureNamesBool[] =3D { {"track_commit_timestamp", PGC_POSTMASTER, REPLICATION_SENDING, gettext_noop("Collects transaction commit time."), - NULL + NULL, + GUC_NOT_IN_BOOTSTRAP }, &track_commit_timestamp, false, @@ -1929,7 +1930,7 @@ struct config_bool ConfigureNamesBool[] =3D gettext_noop("Disables reading from system indexes."), gettext_noop("It does not prevent updating the indexes, so it is safe = " "to use. The worst consequence is slowness."), - GUC_NOT_IN_SAMPLE + GUC_NOT_IN_SAMPLE | GUC_NOT_IN_BOOTSTRAP }, &IgnoreSystemIndexes, false, @@ -2763,7 +2764,7 @@ struct config_int ConfigureNamesInt[] =3D {"transaction_timeout", PGC_USERSET, CLIENT_CONN_STATEMENT, gettext_noop("Sets the maximum allowed duration of any transaction wit= hin a session (not a prepared transaction)."), gettext_noop("0 disables the timeout."), - GUC_UNIT_MS + GUC_UNIT_MS | GUC_NOT_IN_BOOTSTRAP }, &TransactionTimeout, 0, 0, INT_MAX, diff --git a/src/include/utils/guc.h b/src/include/utils/guc.h index f619100467d..0e7e97dabf0 100644 --- a/src/include/utils/guc.h +++ b/src/include/utils/guc.h @@ -228,6 +228,7 @@ typedef enum 0x002000 /* can't set in PG_AUTOCONF_FILENAME */ #define GUC_RUNTIME_COMPUTED 0x004000 /* delay processing in 'postgres = -C' */ #define GUC_ALLOW_IN_PARALLEL 0x008000 /* allow setting in parallel mode= */ +#define GUC_NOT_IN_BOOTSTRAP 0x010000 /* can't set in bootstrap mode */ = #define GUC_UNIT_KB 0x01000000 /* value is in kilobytes */ #define GUC_UNIT_BLOCKS 0x02000000 /* value is in blocks */ ------- =_aaaaaaaaaa0--