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 1tMJYJ-003SFc-JC for pgsql-hackers@arkaria.postgresql.org; Sat, 14 Dec 2024 04:14:51 +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 1tMJYG-00Gh2O-Ux for pgsql-hackers@arkaria.postgresql.org; Sat, 14 Dec 2024 04:14:50 +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 1tMJYG-00Gh2F-IN for pgsql-hackers@lists.postgresql.org; Sat, 14 Dec 2024 04:14:49 +0000 Received: from mail-io1-xd31.google.com ([2607:f8b0:4864:20::d31]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1tMJYF-002jjt-6J for pgsql-hackers@postgresql.org; Sat, 14 Dec 2024 04:14:48 +0000 Received: by mail-io1-xd31.google.com with SMTP id ca18e2360f4ac-844dae6a0caso71969939f.1 for ; Fri, 13 Dec 2024 20:14:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734149686; x=1734754486; 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=aFm+LlT3Jb0AA7cARs6PjttuxMlZTSZ9SWzFivzW/Sk=; b=FJVyVx9kcJ8WOW++LBUr1QbXAxn2J1tfSVk/kR4S/1yDfXTW4sPJDgFJ7olzK6Rh9P 4bOSIfXFluwyl6zBSNl7j9et9rjx63T1ycaMlXzIRUysjr/+qNvMpzEa3ylhOHs03lo1 5F2w5bPEBuaQZvIAJFLeRgRCfjXqZOTiQPU1kOMBl+rUDQhJeN6q3S4PoYmyhijhlpwZ Q3dZZm9TycvwOhyP3yMyeiaAcOEEaxFR3BhDBLV8PnsJWx8MlGb3IMF391jidaz2imdR CRn6fj0+5O7CfjGmxyGzhp4NT9H740HmHDFONQvn4k1fJ4SPOkYpScQ59TfoPttnEzsK AVAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734149686; x=1734754486; 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=aFm+LlT3Jb0AA7cARs6PjttuxMlZTSZ9SWzFivzW/Sk=; b=X4T8QezFRlDlTGlL/Q4F3LFCJAB72RIxI/GP/Q2Q2/gL85XazYQ6WILU6XasxFSozt sw8C9qfQMeIMg+sV0GnCivBDeJndKozvZo5FgY8yogNQ2CnYmy0jhbAeYjRc9d3qjKbh RUs54J0D3f8ZOflgKuSb3mtE9aBNql7g48cB3jMX8ZdGuH6NdV9lwlvhd3jkhU+9C97u ZFUHV3Wi2qpQOm91yAegMW1/RaW6KLmdmpwlejK+EMOTucY83Gvk6ohG2+LP3fKWcOdB nISZbJfjbwf/mu2QIuy93IGMpC7/kyESXzJDFMckDUNMOuQR3MISic1MlA1S9cWWDwp3 9Nfw== X-Gm-Message-State: AOJu0Yw9RD2k07LC/F7cCpjrRUOMT0P1OJjITsw4dKLiMLbqx5i6Wycb a6X5lJdI8QolDP0K1mVRT6tnZIJ3VznqPicdLPDD3OY1faotmvSF X-Gm-Gg: ASbGnctr1/HanByVLMCk5HQE3KH5fAk6OJLOreYYKjkVbn0KNiY3Cmtgwi8QEUtPL6i sl3mzsj8BPINDuN/D/eFEUMb4w7lkzOFXgMN0/+cCiqPWaFGvmt/bSx2uzdv5DWVFn4xtXUr7li SLMZT/HIVX4tDB2pe7lhr2k+zWyv8OSXPf53IlbPcsMfyc1FpMtEudj0AOrZhPS2us4E5IK/2bQ +ZF/AlGeoOzSI02CJzbSTi+zihwIHdrLA3UNjYGYKCmZcr4aoTw6XYzyj1bFj/okMEzA3I4DA6m /diQgG5UPpA1uc/4vLQ0ECwroEo7mX+8CryJtl1a6J2KwRA= X-Google-Smtp-Source: AGHT+IGBqzLX7yrqPxdn96VY9VAHx34Ktj4fEXJAeUwOu6fy+y9KoGB2oAZJVFcQeL2Se4ybhZGBAg== X-Received: by 2002:a05:6e02:1489:b0:3a3:b45b:fb92 with SMTP id e9e14a558f8ab-3aff2fbeacdmr62269265ab.23.1734149686253; Fri, 13 Dec 2024 20:14:46 -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-3b248134383sm2825055ab.21.2024.12.13.20.14.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Dec 2024 20:14:45 -0800 (PST) Date: Fri, 13 Dec 2024 22:14:43 -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> <20241214031505.05.nmisch@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20241214031505.05.nmisch@google.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, Dec 13, 2024 at 07:15:05PM -0800, Noah Misch wrote: > On Thu, Dec 12, 2024 at 10:07:00AM -0600, Nathan Bossart wrote: >> 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. I just noticed that InitProcessGlobals() is relatively new. It was added in v12 by commit 197e4af. >> 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. > > I don't feel strongly either way. I did write it the option-1 way originally. > Then I started thinking about changes at a distance causing the other > InitProcessGlobals() tasks to palloc or elog. We could do option-1 in master > and keep the back branches in their current state. I don't feel strongly either way, either. I don't think it's important enough to diverge from the back-branches. -- nathan