Re: isTempNamespaceInUse() is incorrect with its handling ofMyBackendId - Mailing list pgsql-hackers

From Michael Paquier
Subject Re: isTempNamespaceInUse() is incorrect with its handling ofMyBackendId
Date
Msg-id 20200113131452.GB41902@paquier.xyz
Whole thread Raw
In response to Re: isTempNamespaceInUse() is incorrect with its handling ofMyBackendId  (Julien Rouhaud <rjuju123@gmail.com>)
Responses Re: isTempNamespaceInUse() is incorrect with its handling ofMyBackendId  (Julien Rouhaud <rjuju123@gmail.com>)
List pgsql-hackers
On Mon, Jan 13, 2020 at 01:09:01PM +0100, Julien Rouhaud wrote:
> But that means an extraneous call to BackendIdGetProc() in that
> case, it seems better to avoid it if we already have the information.

Note that you cannot make a direct comparison of the result from
GetTempNamespaceBackendId() with MyBackendId, because it is critical
to be able to handle the case of a session which has not created yet
an object on its own temp namespace (this way any temp objects from
previous connections which used the same backend slot can be marked as
orphaned and discarded by autovacuum, the whole point of 246a6c8).  So
in order to get a fast-exit path we could do the following:
- Add a routine GetTempNamespace which returns myTempNamespace (the
result can be InvalidOid).
- Add an assertion at the beginning of isTempNamespaceInUse() to make
sure that it never gets called with InvalidOid as input argument.
- Return true as a first step of GetTempNamespaceBackendId() if
namespaceId matches GetTempNamespace().

What do you think?
--
Michael

Attachment

pgsql-hackers by date:

Previous
From: Julien Rouhaud
Date:
Subject: Re: pg_basebackup fails on databases with high OIDs
Next
From: Michael Paquier
Date:
Subject: Re: Add pg_file_sync() to adminpack