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 1sSEgU-005Veo-MJ for pgsql-hackers@arkaria.postgresql.org; Fri, 12 Jul 2024 11:43:30 +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 1sSEgT-007hSp-Df for pgsql-hackers@arkaria.postgresql.org; Fri, 12 Jul 2024 11:43:29 +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 1sSEgS-007hSh-QP for pgsql-hackers@lists.postgresql.org; Fri, 12 Jul 2024 11:43:29 +0000 Received: from mail-oa1-x2a.google.com ([2001:4860:4864:20::2a]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sSEgQ-001h8R-3q for pgsql-hackers@postgresql.org; Fri, 12 Jul 2024 11:43:27 +0000 Received: by mail-oa1-x2a.google.com with SMTP id 586e51a60fabf-25cba5eea69so901254fac.2 for ; Fri, 12 Jul 2024 04:43:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leadboat.com; s=google; t=1720784605; x=1721389405; darn=postgresql.org; h=user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=hFqLirIqlXjE7wovB3eIGVzKtqJZNHBiCPQ0JNc8W7M=; b=EnuMV/K6C8nZIafmc8g74N3EU6RWoZFk3qrlsIotQKXsRIg579+iLpVJcNN1oiT7Mn CpNrSmaNrfqNS0/RxtdX33aR72SvJXVQVSZOr4kjXBqWZfJPQi3mdG+2jltUw4fzOcna JfjKQKWvxcqKfECvLptjRFwiBMFSvexq4VxrU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720784605; x=1721389405; h=user-agent:in-reply-to:content-transfer-encoding :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=hFqLirIqlXjE7wovB3eIGVzKtqJZNHBiCPQ0JNc8W7M=; b=ugHe/yo9d4mzo1MZn5+nu0V3A9t1GV+jRL4DoMAy6N2xLG3HHxGMkw4Sd1Mep8vImE ULp5QEk9H76OAtDM+/CcQ5MUYMMKqwPjI9ZSvPJ8CpaTgYR4Q2VpyrjYITYDAQviq8Fi G+uRQSwkTDDY9zQlLyV88FM2akPP9CGof6D3uAGl6yQGUdF+mxACERcSYPewLYYb1EEn 3LqP04/K8AwjbBNEtXxI9ndmYRCgaH/+O69HoRypr00JlaUWWLbT1LE55N7H9nWTazt4 kvaeVKKmyzfhgEekxQlk0bUABtU9gvXd8VD7aGJI7SYz/zYQGglABNcelQpyfDAOMts1 3kgg== X-Forwarded-Encrypted: i=1; AJvYcCU5JifuW5b0A5wnFPxgXw9RfJjnv4Nh11GL9TKmmvMXwgHsl+l9NBeziAZXeRtISDJgd97z4jprpTN/wTC6UIaew3mfcW53GQfkyFQ8 X-Gm-Message-State: AOJu0YzQFhsGu9KHOay50s2KpRXEByENyLovprw4Tp8/6T67T3dPTn8Z Fe+JV2HhRzmmLgz53tMmviO/i2FvWg/88ilNICzDE9Hep2sp1pYDO/o+dV86xw== X-Google-Smtp-Source: AGHT+IEOvXrUVfZ0q0iN/YpO+wJJOG0gMfv+dG8OnJBdvDxzkTkCbpd89bjWVAUFJOLEyiduKet9SA== X-Received: by 2002:a05:6870:d88a:b0:25e:b825:94db with SMTP id 586e51a60fabf-25eb825965amr8298058fac.48.1720784605059; Fri, 12 Jul 2024 04:43:25 -0700 (PDT) Received: from google.com ([2600:1702:a20:5750::48]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-25ea9f9012asm2160534fac.9.2024.07.12.04.43.23 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Jul 2024 04:43:24 -0700 (PDT) Date: Fri, 12 Jul 2024 04:43:22 -0700 From: Noah Misch To: Thomas Munro Cc: Andres Freund , Tom Lane , Nathan Bossart , Melanie Plageman , Michael Paquier , Fujii Masao , "pgsql-hackers@postgresql.org" Subject: Re: race condition when writing pg_control Message-ID: <20240712114322.08.nmisch@google.com> References: <20200603020259.GA89559@paquier.xyz> <20240516183558.GA1620903@nathanxps13> <2136775.1715885450@sss.pgh.pa.us> <20240516185805.hnbt2tr23q7xbx3m@awork3.anarazel.de> <2138498.1715886091@sss.pgh.pa.us> <20240516190744.6beu43cjdvrml6uw@awork3.anarazel.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit 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 Sat, May 18, 2024 at 05:29:12PM +1200, Thomas Munro wrote: > On Fri, May 17, 2024 at 4:46 PM Thomas Munro wrote: > > The specific problem here is that LocalProcessControlFile() runs in > > every launched child for EXEC_BACKEND builds. Windows uses > > EXEC_BACKEND, and Windows' NTFS file system is one of the two file > > systems known to this list to have the concurrent read/write data > > mashing problem (the other being ext4). > First idea idea I've come up with to avoid all of that: pass a copy of > the "proto-controlfile", to coin a term for the one read early in > postmaster startup by LocalProcessControlFile(). As far as I know, > the only reason we need it is to suck some settings out of it that > don't change while a cluster is running (mostly can't change after > initdb, and checksums can only be {en,dis}abled while down). Right? > Children can just "import" that sucker instead of calling > LocalProcessControlFile() to figure out the size of WAL segments yada > yada, I think? Later they will attach to the real one in shared > memory for all future purposes, once normal interlocking is allowed. I like that strategy, particularly because it recreates what !EXEC_BACKEND backends inherit from the postmaster. It might prevent future bugs that would have been specific to EXEC_BACKEND. > I dunno. Draft patch attached. Better plans welcome. This passes CI > on Linux systems afflicted by EXEC_BACKEND, and Windows. Thoughts? Looks reasonable. I didn't check over every detail, given the draft status.