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 1uwmUE-007HYB-UP for pgsql-hackers@arkaria.postgresql.org; Thu, 11 Sep 2025 18:57:39 +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 1uwmUC-009nYw-FA for pgsql-hackers@arkaria.postgresql.org; Thu, 11 Sep 2025 18:57:36 +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 1uwmUB-009nYm-PS for pgsql-hackers@lists.postgresql.org; Thu, 11 Sep 2025 18:57:36 +0000 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uwmU9-001tVr-2o for pgsql-hackers@postgresql.org; Thu, 11 Sep 2025 18:57:34 +0000 Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-24eb713b2dfso9398105ad.0 for ; Thu, 11 Sep 2025 11:57:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leadboat.com; s=google; t=1757617052; x=1758221852; 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=PKirr6sPXtysjDo3rNrZNv146bq+A1vz0Zsp/BFLeXU=; b=V7SJ5lYs9fapZjEuxhLIHKizybbryYwKb4VWkUKWt2uWeIUaq9U8h7uar9Z/bJRBk0 2UyeocFPtACvCN5HnI6QOQyYWTi0ZEJfXVwwRbc+FGskcSNAQwlua8BWD6g45gBMj3/V Ic9+HgHnYdcJ2o/4EkBNOJcYGqUXiWO21YpIg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757617052; x=1758221852; 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=PKirr6sPXtysjDo3rNrZNv146bq+A1vz0Zsp/BFLeXU=; b=Iy75iPdJRAoDj+CzlHkvIOSAlHTGuMArYoHIhEAG1DFD2srhCcpFYfR4Tn4cpiNow1 bz1eCvsFgAFyVy0LCoTsLvm+b1jNOBum96NjjNpF9lgRiAFzBA3ZMDPElcnYabBvqNex b+um46G5n85T5g3JFlgyG+q8w+OrgnJ5K/L8m6BE60bnUJ4Qyy3gHhLj9NE2Yg8NsLIL zZV4jpVCGtoR4bxrESeAoAHOBSY4UOVRC10KtHt7jEs4PYuEDLDaqXuikItnT6ufYdhQ FYM+ojxzq5dYWvH8qj19J54QNssKj2R4cHgUXGg6Oy2L3aUVYTgeISAuj3s0B0CzZbLS zjcw== X-Forwarded-Encrypted: i=1; AJvYcCVpqZ/uX8JaZlABCrl4p8W0Z+pmynsUNqobWO2M69ICoNa2q5affRoHSvHqebyYzWFdKXxPk/Yz7F0HMS99@postgresql.org X-Gm-Message-State: AOJu0Yx2Rl8eqyhanycTHB7aY9Bq8/4uN6vXrigGTV67nyYlnbIG9epK AEhrBcy1GFt6HJuEjmBHC5BbZnaMj2c5vIVEUlS0k3awHg6ndofJOowPd502MttF7w== X-Gm-Gg: ASbGncs5WHzHywxMOPH7MCoIuUjA1sCDJfhojfbHbDZyu7D5BXVHwUBtkLKmvy4Dg44 laG6TVYzusz3mA6wJ9it+nHwxsbCmKsHgep67XuRbPgWCufVBeGo6fnmcNzGNNwY/pikbIVEXJG dli8M0XuzrSvk7BOIN5MSgILZZkkF3VrPA30Ulif/jTFeRGXiNmnuWbuQEFUl64CKyyF6QV92S0 Xp+5QORZ+7VTPN6iTngoDbT0wZQ1iB4dp/N1WELjOWHn6igoIjXnLAZL09uqj6a9PG8ZvNjh4Qh zpfaMOlqJxa+rawqhSWpYESyCV2i7zMQhKgp4Z6fdSE/Mpa1jj4gps9C2q5zBn4pFFkYYBxS6sq vc2SWCluM6vHNN/NEdcpuZWJV4QIxxNv7wrGOHDeIdumoRMFyj04sdidhsw4dtA== X-Google-Smtp-Source: AGHT+IFye3QC8AeHUniBiVNR9jqaUSF7kiAitnG8DWJDyNKZwvl8HOU384lai9+ejCzdAcf7jtv36Q== X-Received: by 2002:a17:903:388b:b0:250:6d0e:1e40 with SMTP id d9443c01a7336-25d242f2f14mr4250615ad.7.1757617051901; Thu, 11 Sep 2025 11:57:31 -0700 (PDT) Received: from google.com (c-73-15-160-255.hsd1.ca.comcast.net. [73.15.160.255]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-25c3ae293b5sm25247845ad.116.2025.09.11.11.57.30 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Sep 2025 11:57:30 -0700 (PDT) Date: Thu, 11 Sep 2025 11:57:29 -0700 From: Noah Misch To: Tom Lane Cc: Smolkin Grigory , pgsql-hackers@postgresql.org Subject: Re: race condition in pg_class Message-ID: <20250911185729.ad.nmisch@google.com> References: <20231027044404.7e.nmisch@google.com> <20231027184832.9b.nmisch@google.com> <1596629.1698435146@sss.pgh.pa.us> <20231027214946.79.nmisch@google.com> <1617596.1698446455@sss.pgh.pa.us> <20231027232612.99.nmisch@google.com> <20231102030915.d3.nmisch@google.com> <20240512232923.aa.nmisch@google.com> <1802710.1757608564@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="xZJ/d+OgWc8sEYA8" Content-Disposition: inline In-Reply-To: <1802710.1757608564@sss.pgh.pa.us> 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 --xZJ/d+OgWc8sEYA8 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Thu, Sep 11, 2025 at 12:36:04PM -0400, Tom Lane wrote: > inplace010-tests-v1.patch from this message, committed as > 0844b3968, contains this bit: > > new file mode 100644 > index 00000000000..0367c0e37ab > --- /dev/null > +++ b/src/test/regress/sql/database.sql > @@ -0,0 +1,17 @@ > +CREATE DATABASE regression_tbd > + ENCODING utf8 LC_COLLATE "C" LC_CTYPE "C" TEMPLATE template0; > +ALTER DATABASE regression_tbd RENAME TO regression_utf8; > +ALTER DATABASE regression_utf8 SET TABLESPACE regress_tblspace; > +ALTER DATABASE regression_utf8 RESET TABLESPACE; > +ALTER DATABASE regression_utf8 CONNECTION_LIMIT 123; > + > > It emerges that the "ALTER DATABASE regression_utf8 RESET TABLESPACE" > command is a complete no-op [1]. I am guessing that that was not the > behavior you had in mind, and am wondering if we are losing any test > coverage thereby. Did you have a specific reason for manipulating the > TABLESPACE property and not some random GUC setting? I have no specific notes or memories about that RESET TABLESPACE, but I likely wanted "SET TABLESPACE pg_default". RESET TABLESPACE may still have the effect of loading a catcache entry, as a later comment says: -- Test PgDatabaseToastTable. Doing this with GRANT would be slow. BEGIN; UPDATE pg_database SET datacl = array_fill(makeaclitem(10, 10, 'USAGE', false), ARRAY[5e5::int]) WHERE datname = 'regression_utf8'; -- load catcache entry, if nothing else does ALTER DATABASE regression_utf8 RESET TABLESPACE; ROLLBACK; That originated to exercise catcache.c code specific to toast_flatten_tuple() for an inplace-updated catalog. (Commit af8cd16 later removed the inplace-specific code.) SET TABLESPACE rejects transaction blocks, so that would need another way to load a catcache entry. I'm inclined to change it as attached. This doesn't reduce database.sql test coverage of dbcommands.c or catcache.c, so I'll bet it doesn't lose anything vs. the original database.sql commit. Some check-tests runs showed it adding database.sql coverage of catcache.c:1908-1911 and catcache.c:1983-1984, so that's a bonus. > [1] https://www.postgresql.org/message-id/flat/30783e-68c28a00-9-41004480%40130449754 Do you plan to back-patch that? That should dictate whether I back-patch the test change. --xZJ/d+OgWc8sEYA8 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="no-reset-tablespace-v1.patch" diff --git a/src/test/regress/expected/database.out b/src/test/regress/expected/database.out index 4cbdbdf..6b879b0 100644 --- a/src/test/regress/expected/database.out +++ b/src/test/regress/expected/database.out @@ -2,7 +2,7 @@ CREATE DATABASE regression_tbd ENCODING utf8 LC_COLLATE "C" LC_CTYPE "C" TEMPLATE template0; ALTER DATABASE regression_tbd RENAME TO regression_utf8; ALTER DATABASE regression_utf8 SET TABLESPACE regress_tblspace; -ALTER DATABASE regression_utf8 RESET TABLESPACE; +ALTER DATABASE regression_utf8 SET TABLESPACE pg_default; ALTER DATABASE regression_utf8 CONNECTION_LIMIT 123; -- Test PgDatabaseToastTable. Doing this with GRANT would be slow. BEGIN; @@ -10,7 +10,7 @@ UPDATE pg_database SET datacl = array_fill(makeaclitem(10, 10, 'USAGE', false), ARRAY[5e5::int]) WHERE datname = 'regression_utf8'; -- load catcache entry, if nothing else does -ALTER DATABASE regression_utf8 RESET TABLESPACE; +ALTER DATABASE regression_utf8 RENAME TO regression_rename_rolled_back; ROLLBACK; CREATE ROLE regress_datdba_before; CREATE ROLE regress_datdba_after; diff --git a/src/test/regress/sql/database.sql b/src/test/regress/sql/database.sql index 46ad263..4ef3612 100644 --- a/src/test/regress/sql/database.sql +++ b/src/test/regress/sql/database.sql @@ -2,7 +2,7 @@ CREATE DATABASE regression_tbd ENCODING utf8 LC_COLLATE "C" LC_CTYPE "C" TEMPLATE template0; ALTER DATABASE regression_tbd RENAME TO regression_utf8; ALTER DATABASE regression_utf8 SET TABLESPACE regress_tblspace; -ALTER DATABASE regression_utf8 RESET TABLESPACE; +ALTER DATABASE regression_utf8 SET TABLESPACE pg_default; ALTER DATABASE regression_utf8 CONNECTION_LIMIT 123; -- Test PgDatabaseToastTable. Doing this with GRANT would be slow. @@ -11,7 +11,7 @@ UPDATE pg_database SET datacl = array_fill(makeaclitem(10, 10, 'USAGE', false), ARRAY[5e5::int]) WHERE datname = 'regression_utf8'; -- load catcache entry, if nothing else does -ALTER DATABASE regression_utf8 RESET TABLESPACE; +ALTER DATABASE regression_utf8 RENAME TO regression_rename_rolled_back; ROLLBACK; CREATE ROLE regress_datdba_before; --xZJ/d+OgWc8sEYA8--