agora inbox for pgpool-committers@postgresql.org
help / color / mirror / Atom feedpgpool: Fix lock release leak in pool_search_relcache.
5+ messages / 1 participants
[nested] [flat]
* pgpool: Fix lock release leak in pool_search_relcache.
@ 2026-03-19 06:35 Tatsuo Ishii <ishii@postgresql.org>
0 siblings, 0 replies; 5+ messages in thread
From: Tatsuo Ishii @ 2026-03-19 06:35 UTC (permalink / raw)
To: pgpool-committers@lists.postgresql.org
Fix lock release leak in pool_search_relcache.
pool_search_relcache did not release lock in a certain code path.
When the local relation cache does not hit, it searches the shared
relation cache if enable_shared_relcache is on. If the lock for query
cache has been already held (thus the variable "locked" is set to
true), it acquires a shared lock, then releases it and acquires an
exclusive lock to call pool_catalog_commit_cache, which needs an
exclusive lock. Since in this code path variable "locked" is set to
true, subsequent code:
if (pool_config->enable_shared_relcache && !locked)
{
pool_shmem_unlock();
POOL_SETMASK(&oldmask);
}
does not reach inside the if statement -- lock is not released. I
think to fix this, the following code requires "locked = false;"
pool_shmem_unlock();
pool_shmem_lock(POOL_MEMQ_EXCLUSIVE_LOCK);
pool_catalog_commit_cache(backend, query, query_cache_data, query_cache_len);
Also I made following changes:
- the variable name "locked" is confusing. To clarify the role of the
variable, its name is changed to "locked_by_others".
- Fix per_node_statement_log is called even though actual query is
not sent to backend.
Discussion: https://www.postgresql.org/message-id/20260317.182615.1046517700474336117.ishii%40postgresql.org
Backpatch-through: v4.4 where shared lock was introduced.
Branch
------
V4_4_STABLE
Details
-------
https://git.postgresql.org/gitweb?p=pgpool2.git;a=commitdiff;h=4095caec0af96a47e0d06f64a10362fbbf32c...
Modified Files
--------------
src/utils/pool_relcache.c | 23 +++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)
^ permalink raw reply [nested|flat] 5+ messages in thread
* pgpool: Fix lock release leak in pool_search_relcache.
@ 2026-03-19 06:35 Tatsuo Ishii <ishii@postgresql.org>
0 siblings, 0 replies; 5+ messages in thread
From: Tatsuo Ishii @ 2026-03-19 06:35 UTC (permalink / raw)
To: pgpool-committers@lists.postgresql.org
Fix lock release leak in pool_search_relcache.
pool_search_relcache did not release lock in a certain code path.
When the local relation cache does not hit, it searches the shared
relation cache if enable_shared_relcache is on. If the lock for query
cache has been already held (thus the variable "locked" is set to
true), it acquires a shared lock, then releases it and acquires an
exclusive lock to call pool_catalog_commit_cache, which needs an
exclusive lock. Since in this code path variable "locked" is set to
true, subsequent code:
if (pool_config->enable_shared_relcache && !locked)
{
pool_shmem_unlock();
POOL_SETMASK(&oldmask);
}
does not reach inside the if statement -- lock is not released. I
think to fix this, the following code requires "locked = false;"
pool_shmem_unlock();
pool_shmem_lock(POOL_MEMQ_EXCLUSIVE_LOCK);
pool_catalog_commit_cache(backend, query, query_cache_data, query_cache_len);
Also I made following changes:
- the variable name "locked" is confusing. To clarify the role of the
variable, its name is changed to "locked_by_others".
- Fix per_node_statement_log is called even though actual query is
not sent to backend.
Discussion: https://www.postgresql.org/message-id/20260317.182615.1046517700474336117.ishii%40postgresql.org
Backpatch-through: v4.4 where shared lock was introduced.
Branch
------
V4_5_STABLE
Details
-------
https://git.postgresql.org/gitweb?p=pgpool2.git;a=commitdiff;h=16c340a944551b51e787b824352294a676a5a...
Modified Files
--------------
src/utils/pool_relcache.c | 23 +++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)
^ permalink raw reply [nested|flat] 5+ messages in thread
* pgpool: Fix lock release leak in pool_search_relcache.
@ 2026-03-19 06:36 Tatsuo Ishii <ishii@postgresql.org>
0 siblings, 0 replies; 5+ messages in thread
From: Tatsuo Ishii @ 2026-03-19 06:36 UTC (permalink / raw)
To: pgpool-committers@lists.postgresql.org
Fix lock release leak in pool_search_relcache.
pool_search_relcache did not release lock in a certain code path.
When the local relation cache does not hit, it searches the shared
relation cache if enable_shared_relcache is on. If the lock for query
cache has been already held (thus the variable "locked" is set to
true), it acquires a shared lock, then releases it and acquires an
exclusive lock to call pool_catalog_commit_cache, which needs an
exclusive lock. Since in this code path variable "locked" is set to
true, subsequent code:
if (pool_config->enable_shared_relcache && !locked)
{
pool_shmem_unlock();
POOL_SETMASK(&oldmask);
}
does not reach inside the if statement -- lock is not released. I
think to fix this, the following code requires "locked = false;"
pool_shmem_unlock();
pool_shmem_lock(POOL_MEMQ_EXCLUSIVE_LOCK);
pool_catalog_commit_cache(backend, query, query_cache_data, query_cache_len);
Also I made following changes:
- the variable name "locked" is confusing. To clarify the role of the
variable, its name is changed to "locked_by_others".
- Fix per_node_statement_log is called even though actual query is
not sent to backend.
Discussion: https://www.postgresql.org/message-id/20260317.182615.1046517700474336117.ishii%40postgresql.org
Backpatch-through: v4.4 where shared lock was introduced.
Branch
------
V4_6_STABLE
Details
-------
https://git.postgresql.org/gitweb?p=pgpool2.git;a=commitdiff;h=a804cc786298df1c9ff1015f22e5648b45a11...
Modified Files
--------------
src/utils/pool_relcache.c | 23 +++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)
^ permalink raw reply [nested|flat] 5+ messages in thread
* pgpool: Fix lock release leak in pool_search_relcache.
@ 2026-03-19 06:36 Tatsuo Ishii <ishii@postgresql.org>
0 siblings, 0 replies; 5+ messages in thread
From: Tatsuo Ishii @ 2026-03-19 06:36 UTC (permalink / raw)
To: pgpool-committers@lists.postgresql.org
Fix lock release leak in pool_search_relcache.
pool_search_relcache did not release lock in a certain code path.
When the local relation cache does not hit, it searches the shared
relation cache if enable_shared_relcache is on. If the lock for query
cache has been already held (thus the variable "locked" is set to
true), it acquires a shared lock, then releases it and acquires an
exclusive lock to call pool_catalog_commit_cache, which needs an
exclusive lock. Since in this code path variable "locked" is set to
true, subsequent code:
if (pool_config->enable_shared_relcache && !locked)
{
pool_shmem_unlock();
POOL_SETMASK(&oldmask);
}
does not reach inside the if statement -- lock is not released. I
think to fix this, the following code requires "locked = false;"
pool_shmem_unlock();
pool_shmem_lock(POOL_MEMQ_EXCLUSIVE_LOCK);
pool_catalog_commit_cache(backend, query, query_cache_data, query_cache_len);
Also I made following changes:
- the variable name "locked" is confusing. To clarify the role of the
variable, its name is changed to "locked_by_others".
- Fix per_node_statement_log is called even though actual query is
not sent to backend.
Discussion: https://www.postgresql.org/message-id/20260317.182615.1046517700474336117.ishii%40postgresql.org
Backpatch-through: v4.4 where shared lock was introduced.
Branch
------
V4_7_STABLE
Details
-------
https://git.postgresql.org/gitweb?p=pgpool2.git;a=commitdiff;h=c6bc879559933ae7820cdcaaa4260ec5fabf1...
Modified Files
--------------
src/utils/pool_relcache.c | 22 ++++++++++++++--------
1 file changed, 14 insertions(+), 8 deletions(-)
^ permalink raw reply [nested|flat] 5+ messages in thread
* pgpool: Fix lock release leak in pool_search_relcache.
@ 2026-03-19 06:36 Tatsuo Ishii <ishii@postgresql.org>
0 siblings, 0 replies; 5+ messages in thread
From: Tatsuo Ishii @ 2026-03-19 06:36 UTC (permalink / raw)
To: pgpool-committers@lists.postgresql.org
Fix lock release leak in pool_search_relcache.
pool_search_relcache did not release lock in a certain code path.
When the local relation cache does not hit, it searches the shared
relation cache if enable_shared_relcache is on. If the lock for query
cache has been already held (thus the variable "locked" is set to
true), it acquires a shared lock, then releases it and acquires an
exclusive lock to call pool_catalog_commit_cache, which needs an
exclusive lock. Since in this code path variable "locked" is set to
true, subsequent code:
if (pool_config->enable_shared_relcache && !locked)
{
pool_shmem_unlock();
POOL_SETMASK(&oldmask);
}
does not reach inside the if statement -- lock is not released. I
think to fix this, the following code requires "locked = false;"
pool_shmem_unlock();
pool_shmem_lock(POOL_MEMQ_EXCLUSIVE_LOCK);
pool_catalog_commit_cache(backend, query, query_cache_data, query_cache_len);
Also I made following changes:
- the variable name "locked" is confusing. To clarify the role of the
variable, its name is changed to "locked_by_others".
- Fix per_node_statement_log is called even though actual query is
not sent to backend.
Discussion: https://www.postgresql.org/message-id/20260317.182615.1046517700474336117.ishii%40postgresql.org
Backpatch-through: v4.4 where shared lock was introduced.
Branch
------
master
Details
-------
https://git.postgresql.org/gitweb?p=pgpool2.git;a=commitdiff;h=80cef775919905ce1b1a0ff99fe28ee288327...
Modified Files
--------------
src/utils/pool_relcache.c | 22 ++++++++++++++--------
1 file changed, 14 insertions(+), 8 deletions(-)
^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2026-03-19 06:36 UTC | newest]
Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-03-19 06:35 pgpool: Fix lock release leak in pool_search_relcache. Tatsuo Ishii <ishii@postgresql.org>
2026-03-19 06:35 pgpool: Fix lock release leak in pool_search_relcache. Tatsuo Ishii <ishii@postgresql.org>
2026-03-19 06:36 pgpool: Fix lock release leak in pool_search_relcache. Tatsuo Ishii <ishii@postgresql.org>
2026-03-19 06:36 pgpool: Fix lock release leak in pool_search_relcache. Tatsuo Ishii <ishii@postgresql.org>
2026-03-19 06:36 pgpool: Fix lock release leak in pool_search_relcache. Tatsuo Ishii <ishii@postgresql.org>
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox