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.96) (envelope-from ) id 1waaYt-001uXO-0w for pgsql-hackers@arkaria.postgresql.org; Fri, 19 Jun 2026 14:51:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1waaYs-00Gm0Z-0d for pgsql-hackers@arkaria.postgresql.org; Fri, 19 Jun 2026 14:51:14 +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.96) (envelope-from ) id 1waaYr-00Gm0R-2z for pgsql-hackers@lists.postgresql.org; Fri, 19 Jun 2026 14:51:13 +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.98.2) (envelope-from ) id 1waaYq-000000019fe-2USR for pgsql-hackers@lists.postgresql.org; Fri, 19 Jun 2026 14:51:13 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.18.1/8.18.1) with ESMTP id 65JEp26g1472099; Fri, 19 Jun 2026 10:51:02 -0400 From: Tom Lane To: =?utf-8?Q?=C3=81lvaro?= Herrera cc: Andrew Dunstan , PostgreSQL Hackers Subject: Re: fix pg_mkdir_p to tolerate concurrent directory creation In-reply-to: References: Comments: In-reply-to =?utf-8?Q?=C3=81lvaro?= Herrera message dated "Fri, 19 Jun 2026 16:01:47 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1472097.1781880662.1@sss.pgh.pa.us> Date: Fri, 19 Jun 2026 10:51:02 -0400 Message-ID: <1472098.1781880662@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk =?utf-8?Q?=C3=81lvaro?= Herrera writes: > Hmm, should the 'break's in the loop be 'continue's? If you're creating > path a/b/c, and a concurrent process beats you but is only attempting to > do a/b, then with the break you'll fail to create the final c. Maybe I'm confused, but I think it's right as-is. The "break"s are places where we're giving up and reporting a hard error. If we want to continue to the next directory level, we just fall through --- and doing that with "continue" would be wrong because it'd miss the step at the bottom of the loop: if (!last) *p = '/'; regards, tom lane