Re: isTempNamespaceInUse() is incorrect with its handling ofMyBackendId

Поиск
Список
Период
Сортировка
От Michael Paquier
Тема Re: isTempNamespaceInUse() is incorrect with its handling ofMyBackendId
Дата
Msg-id 20200113131452.GB41902@paquier.xyz
обсуждение исходный текст
Ответ на Re: isTempNamespaceInUse() is incorrect with its handling ofMyBackendId  (Julien Rouhaud <rjuju123@gmail.com>)
Ответы Re: isTempNamespaceInUse() is incorrect with its handling ofMyBackendId
Список 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

Вложения

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Julien Rouhaud
Дата:
Сообщение: Re: pg_basebackup fails on databases with high OIDs
Следующее
От: Michael Paquier
Дата:
Сообщение: Re: Add pg_file_sync() to adminpack