Re: race condition in pg_class

Noah Misch <noah@leadboat.com>

From: Noah Misch <noah@leadboat.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Smolkin Grigory <smallkeen@gmail.com>, pgsql-hackers@postgresql.org
Date: 2025-09-11T18:57:29Z
Lists: pgsql-hackers

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Replace tests of ALTER DATABASE RESET TABLESPACE.

  2. meson: Flush stdout in testwrap

  3. Fix catcache invalidation of a list entry that's being built

  4. Stop reading uninitialized memory in heap_inplace_lock().

  5. Fix use of uninitialized value in previous commit.

  6. Back-patch "Refactor code in tablecmds.c to check and process tablespace moves"

  7. Fix data loss at inplace update after heap_update().

  8. For inplace update durability, make heap_update() callers wait.

  9. Warn if LOCKTAG_TUPLE is held at commit, under debug_assertions.

  10. Don't lose partitioned table reltuples=0 after relhassubclass=f.

  11. Fix new assertion for MERGE view_name ... DO NOTHING.

  12. Remove configuration-dependent output from new inplace-inval test.

  13. AccessExclusiveLock new relations just after assigning the OID.

  14. Cope with inplace update making catcache stale during TOAST fetch.

  15. Expand comments and add an assertion in nodeModifyTable.c.

  16. Improve test coverage for changes to inplace-updated catalogs.

  17. Lock before setting relhassubclass on RELKIND_PARTITIONED_INDEX.

  18. Lock owned sequences during ALTER TABLE SET { LOGGED | UNLOGGED }.

  19. Make TAP todo_start effects the same under Meson and prove_check.

  20. Add an injection_points isolation test suite.

  21. Add wait event type "InjectionPoint", a custom type like "Extension".

  22. Create waitfuncs.c for pg_isolation_test_session_is_blocked().

  23. Rework planning and execution of UPDATE and DELETE.

Attachments

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.