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 1tMIcd-003LjY-3a for pgsql-hackers@arkaria.postgresql.org; Sat, 14 Dec 2024 03:15:15 +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 1tMIca-00GA5M-9p for pgsql-hackers@arkaria.postgresql.org; Sat, 14 Dec 2024 03:15:13 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tMIcZ-00GA5B-Om for pgsql-hackers@lists.postgresql.org; Sat, 14 Dec 2024 03:15:13 +0000 Received: from mail-pg1-x530.google.com ([2607:f8b0:4864:20::530]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1tMIcY-002kVK-5S for pgsql-hackers@postgresql.org; Sat, 14 Dec 2024 03:15:12 +0000 Received: by mail-pg1-x530.google.com with SMTP id 41be03b00d2f7-801c7e6518eso794360a12.2 for ; Fri, 13 Dec 2024 19:15:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leadboat.com; s=google; t=1734146108; x=1734750908; darn=postgresql.org; h=user-agent: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=yo27fhm90ipbJPCMQHv27Fpl1Jqmh4+qmVNUb/ifBEs=; b=UeUT41npx7Z6PnfqY4w4STpgQLuqBlPnE1A/R+6kDyHqhOa0LYymGNXTbsG1FHR5bR g/0umWZj04hgA9dQpafJKwcnkWq5kD66VIAmPCPkUvC9Tcyr5i92US4cxUyCSGe0UHX1 I0s/pbvCoMsdwh+OYXfJZARR9fnxYaiYjq8aE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734146108; x=1734750908; h=user-agent: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=yo27fhm90ipbJPCMQHv27Fpl1Jqmh4+qmVNUb/ifBEs=; b=h/Pde/ugMTI//+PWy+mUhVeTk4kpwOORjsg/+Fmjc72yU215bStTOEtsnFzfPN8M1x 8I8OHmjEp8UYsn2KFL4vPe+FmaJB2BmaFVwzfmdgD/SFNyo6WRvSSUbZJHqh0vet3WI1 tWFbjraMp5QPNp5AJbwAJI6CGEqckSDEmXXxAYe5N1GnfgyR+nTVQ0b3BFiR7scKcty+ 7SmhCnozCxrpc4b2/EZnu1M8mHoRA7mO0+hZ6kE2mpTztSzXZwXBoiLx9UzdXF9IRY43 uM1RhiQ8HULdpPEP1viclgA6ZtvghWvZbigDvOmUUdn8jN6BXjiMWgQyHSej1aGYyq/p Wv2g== X-Gm-Message-State: AOJu0YxH7509Nbdmb7hC9or0TGDA4mpQYDmTbyV+MXUtxvdwQmCwpc3n Pu8xZ93n9dF517jI5tT58EE4I7FukJilNGhHzbBGmd7+kkNXJNEcW6jbhcpGNw== X-Gm-Gg: ASbGncu//zDtDamP2uRiKb3q69UjUuhDIZh5c+5TLF90+r+u1yZZjioAQgL7KE9BlfK 3GrOy6BtIqDjy+BUwuFetVaBXe6NI6tRsgF6iaDkm8PzXgyyTB+Y7PGBdWzRhfvhV9SZfnxB2xv gmXyMeTFay3KStlCHSlSUalAIY8+NsOZJSI+iTLxuVDRzVoMVKOL6GuGgMaGaz/ZiJ+qx9zYTNp BNgqoXzLmQVuqS6F/54kn3NexgH4L2VYnmHKm51XdCo7a3rehg= X-Google-Smtp-Source: AGHT+IExLGxT+bm6/Y1vZ7GiuSvhyrEj6nGAUogfKFKiptLMqApY093L/5dB6WR9WDu5TL5vk8ZrKA== X-Received: by 2002:a17:90b:134f:b0:2ee:d824:b559 with SMTP id 98e67ed59e1d1-2f2901b3199mr6706987a91.28.1734146107787; Fri, 13 Dec 2024 19:15:07 -0800 (PST) Received: from google.com ([2600:1702:a20:5750::48]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2f2a1ebb715sm501254a91.24.2024.12.13.19.15.07 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Dec 2024 19:15:07 -0800 (PST) Date: Fri, 13 Dec 2024 19:15:05 -0800 From: Noah Misch To: Nathan Bossart Cc: pgsql-hackers@postgresql.org Subject: Re: Fix early elog(FATAL) Message-ID: <20241214031505.05.nmisch@google.com> 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: User-Agent: Mutt/2.2.12 (2023-09-09) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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. > > 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.