Issue - (#51): Postgres process is taking too much CPU.

Jira: PG-141

There is lock conflict, so used LW_EXCLUSIVE instead of LW_SHARED. This
need to be investigated again and check the possibility to use a shared lock.
This commit is contained in:
Ibrar Ahmed
2020-10-12 19:41:48 +00:00
parent b23df84af9
commit 166ee0a25b
2 changed files with 5 additions and 11 deletions

View File

@@ -875,12 +875,15 @@ exit:
Datum
pg_stat_monitor_reset(PG_FUNCTION_ARGS)
{
pgssSharedState *pgss = pgsm_get_ss();
/* Safety check... */
if (!IsHashInitialize())
ereport(ERROR,
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
errmsg("pg_stat_monitor: must be loaded via shared_preload_libraries")));
LWLockAcquire(pgss->lock, LW_EXCLUSIVE);
hash_entry_dealloc(-1);
LWLockRelease(pgss->lock);
PG_RETURN_VOID();
}