Re: BUG #18014: Releasing catcache entries makes schema_to_xmlschema() fail when parallel workers are used

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alexander Lakhin <exclusion(at)gmail(dot)com>
Cc: Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #18014: Releasing catcache entries makes schema_to_xmlschema() fail when parallel workers are used
Date: 2023-07-21 19:21:46
Message-ID: 982076.1689967306@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Alexander Lakhin <exclusion(at)gmail(dot)com> writes:
> 21.07.2023 20:20, Tom Lane wrote:
>> I like #2 better if it's not hard to do cleanly. However, I'm not
>> quite sure how we are getting to an inval during relation close;
>> maybe that's not something we want to prevent.

> Yes, there is a detailed comment in LockRelationOid(), that explains why
> AcceptInvalidationMessages() is called. (I've tried to remove that call
> now, just for testing, and get 6 tests failed during `make check`.)

Yes, we certainly want to do that during LockRelationOid. But what
seems to be happening here is an inval while we are closing/unlocking
the catalog we got the syscache entry from. That is, the expected
behavior here is:

SearchSysCacheExists:

* is entry present-and-valid?
No, so...

* open and lock relevant catalog (with possible inval)

* scan catalog, find desired row, create valid syscache entry

* close and unlock catalog

* return success

SearchSysCache1 (from pg_class_aclmask_ext):

* is entry present-and-valid?
Yes, so increment its refcount and return it

There is no inval in the entry-already-present code path in syscache
lookup. So if we are seeing this failure, ISTM it must mean that an
inval is happening during "close and unlock catalog", which seems like
something that we don't want. But I've not traced exactly how that
happens.

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Amit Kapila 2023-07-22 05:25:53 Re: BUG #18027: Logical replication taking forever
Previous Message Alexander Lakhin 2023-07-21 19:00:01 Re: BUG #18014: Releasing catcache entries makes schema_to_xmlschema() fail when parallel workers are used