pgsql: Fix bug in LWLock statistics mechanism. - Mailing list pgsql-committers

From Fujii Masao
Subject pgsql: Fix bug in LWLock statistics mechanism.
Date
Msg-id E1izZzN-0006MN-D2@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Fix bug in LWLock statistics mechanism.

Previously PostgreSQL built with -DLWLOCK_STATS could report
more than one LWLock statistics entries for the same backend
process and the same LWLock. This is strange and only one
statistics should be output in that case, instead.

The cause of this issue is that the key variable used for
LWLock stats hash table was not fully initialized. The key
consists of two fields and they were initialized. But
the following 4 bytes allocated in the key variable for
the alignment was not initialized. So even if the same key
was specified, hash_search(HASH_ENTER) could not find
the existing entry for that key and created new one.

This commit fixes this issue by initializing the key
variable with zero. As the side effect of this commit,
the volume of LWLock statistics output would be reduced
very much.

Back-patch to v10, where commit 3761fe3c20 introduced the issue.

Author: Fujii Masao
Reviewed-by: Julien Rouhaud, Kyotaro Horiguchi
Discussion: https://postgr.es/m/26359edb-798a-568f-d93a-6aafac49752d@oss.nttdata.com

Branch
------
REL_10_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/c17abac60eb23f0441cbf481ac5ea58905877084

Modified Files
--------------
src/backend/storage/lmgr/lwlock.c | 1 +
1 file changed, 1 insertion(+)


pgsql-committers by date:

Previous
From: Michael Paquier
Date:
Subject: pgsql: Add leader_pid to pg_stat_activity
Next
From: Fujii Masao
Date:
Subject: pgsql: Fix bug in LWLock statistics mechanism.