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 1tLliW-00Gszc-0o for pgsql-hackers@arkaria.postgresql.org; Thu, 12 Dec 2024 16:07:08 +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 1tLliT-00DHol-EM for pgsql-hackers@arkaria.postgresql.org; Thu, 12 Dec 2024 16:07:06 +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 1tLliT-00DHob-1u for pgsql-hackers@lists.postgresql.org; Thu, 12 Dec 2024 16:07:06 +0000 Received: from mail-il1-x132.google.com ([2607:f8b0:4864:20::132]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1tLliR-002TLM-IE for pgsql-hackers@postgresql.org; Thu, 12 Dec 2024 16:07:04 +0000 Received: by mail-il1-x132.google.com with SMTP id e9e14a558f8ab-3ab37d98dd4so2570485ab.3 for ; Thu, 12 Dec 2024 08:07:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734019623; x=1734624423; darn=postgresql.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=BOTqpn4XPb8sgFGRbVOE2V2vS+I23dEc2kamXp+hCBQ=; b=cegGD/CTnq0Ge3agfsxYP9FlNVu6UjoLwXKuV48qXaJrZ19ZA684+R3IMXTb3rjL/P mkblpXfaesDFnF8SaCJEDyVyJHLnUmKRIGMESMnrT/b3AqTwYf8W2uW8m2MYGjVkby+z G0gg/WM31A4XdPsaAaR/sIiYb9wBBBEugqxt+I1zhBAjbo6LW99GgHxflitov5OfaDtd hdKu9wIAD7hPK2F7n/vwnP9GjoMGcHL/vwDugnRE8Op49XU8/eLNaTHm2QvKam2GVTRK euEYpBmbrmEunrNG1c8TBB4qk6NX/VD9ojfpmSLIt7MhBZSvTk2f9o7gMKY7KnS4Dh1+ 7Dhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734019623; x=1734624423; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=BOTqpn4XPb8sgFGRbVOE2V2vS+I23dEc2kamXp+hCBQ=; b=PGKM+j5ev2ZtJ8LgtD1TcbG2Xhbms5lQLnbrcVKQi3iXUGW/AIJ1JTvlUFqIkiv9jA 3T50idfrk4bxPV563icEXWsg6ytLWqbD1GBLXI1QbTXEIM8VTgAyBuHhDSB/OW0hD3a0 zRLg6Ul4r+Yck6GhwNOQYeUpKpTbo655TmbO7jKQXhiKf8NEBK4HEX0gvD4GmzfZZCT7 Ja3Gehyv8CPjpIjREx7puNNdsuBoFSC22R0KNNS/BDoDpLM5J+05RZy8EUpLZknt7hQb z36HpabM0PA78AVWJAHe9PoQzNXDE5cMCWKXDqaYJzG8s9Uwt1VSr4dXxXgCIVdw4RjZ fkhw== X-Gm-Message-State: AOJu0YzqyXL7zOoFX6r1nGhW5dR8vG/mWWm7QUZVt/zeef5XaZXSB49k GclyydOVIGlS0qcVLu7Mj2kqAtmAfzpjDp84G2omSrBxrqROvtUqpco2vw== X-Gm-Gg: ASbGncvRQGk+WV3asQY16M4TXDdaSd4fGX75hckBO5UaXQZU/QqowhLHu7ndeJLVVlF SrhndTg5v2nNWOc2rAVKYyANRfnWzwD3TgnLRZEGXoU7fMLt6rExhI45ZYBd2bOPQBIdWQbQ3DO VFDm7mZCrg4Ch2e/uVHazdZ/I9iHKr520cPdQ6Zmaiujh6gaaBkpmRD0bfptNvexHLelKFuNdGq pvvrYUHbJ2do3fjE59ZYIt5FNztHnWGqRETN9rH3cEF6rI2Yx/GO4VeDvspYyHVX09tpmf+i8hF WoNADpX1Os+I2L5Atm9g1ZoNSyf3OPxxvEzZ5C4WnCcmXWo= X-Google-Smtp-Source: AGHT+IGyLBberq7xJHrPCp0nXrpSoDn5vNX1DbVPino17osXjqWj33eGORL2k6L3KQ74K43YT6bJbw== X-Received: by 2002:a05:6e02:b2c:b0:3a7:c5ff:e60b with SMTP id e9e14a558f8ab-3ae55e0e536mr9392305ab.6.1734019622670; Thu, 12 Dec 2024 08:07:02 -0800 (PST) Received: from nathan (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-3a808d8ed40sm44525425ab.16.2024.12.12.08.07.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Dec 2024 08:07:02 -0800 (PST) Date: Thu, 12 Dec 2024 10:07:00 -0600 From: Nathan Bossart To: Noah Misch Cc: pgsql-hackers@postgresql.org Subject: Re: Fix early elog(FATAL) Message-ID: References: <20241208034614.45.nmisch@google.com> <20241212033414.e0.nmisch@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20241212033414.e0.nmisch@google.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, Dec 11, 2024 at 07:34:14PM -0800, Noah Misch wrote: > On Tue, Dec 10, 2024 at 04:18:19PM -0600, Nathan Bossart wrote: >> FWIW I'd probably vote for option 1. That keeps the initialization of the >> globals together, reduces the call sites, and fixes the bug. I'd worry a >> little about moving the MyProcPid assignments out of that function without >> adding a bunch of commentary to explain why. > > Can you say more about that? A comment about MyProcPid could say "fork() is > the one thing that changes the getpid() return value". To me, the things > InitProcessGlobals() sets are all different. MyProcPid can be set without > elog(ERROR) and gets invalidated at fork(). The others reasonably could > elog(ERROR). (They currently don't.) The random state could have a different > lifecycle. If we had a builtin pooler that reused processes, we'd > reinitialize random state at each process reuse, not at each fork(). So I see > the grouping of (MyProcPid, MyStartTimestamp, random seed) as mostly an > accident of history. Fair enough. I suppose part of my hesitation stems from expecting hackers to be more likely to remember to call InitProcessGlobals() than to initialize MyProcPid. But given your change requires initializing MyProcPid in exactly 2 places, and there are unlikely to be more in the near future, I might be overthinking it. -- nathan