Обсуждение: BUG #18331: Why is the session lock (DEFAULT_LOCKMETHOD) not automatically released during process exit?

Поиск
Список
Период
Сортировка
The following bug has been logged on the website:

Bug reference:      18331
Logged by:          Why is the session lock (DEFAULT_LOCKMETHOD) not automatically released
during process exit?
Email address:      dafoer_x@163.com
PostgreSQL version: 16.1
Operating system:   centos_x86
Description:

I have some doubts about the implementation of session locks. Can you help
me clarify my questions?

The comment for the function LockRelationIdForSession mentions “It will be
removed  when UnlockRelationIdForSession() is called, or if an
ereport(ERROR) occurs,  or if the backend exits.”
However, the callback function ShutdownPostgres, which is triggered during
process exit, only cleans up locks of type USER_LOCKMETHOD. Is it possible
to automatically clean up session locks of type DEFAULT_LOCKMETHOD?

What risks or implications would there be if session locks of type
USER_LOCKMETHOD were automatically cleaned up during process exit?


PG Bug reporting form <noreply@postgresql.org> writes:
> The comment for the function LockRelationIdForSession mentions “It will be
> removed  when UnlockRelationIdForSession() is called, or if an
> ereport(ERROR) occurs,  or if the backend exits.”
> However, the callback function ShutdownPostgres, which is triggered during
> process exit, only cleans up locks of type USER_LOCKMETHOD. Is it possible
> to automatically clean up session locks of type DEFAULT_LOCKMETHOD?

I think you are looking in the wrong place.  Normal locks are released
in the transaction-ending code.  We need the special case in
ShutdownPostgres because that's not true for user locks.

            regards, tom lane