Skip to content

Commit 64efec7

Browse files
committed
Add history reset
1 parent 46af7da commit 64efec7

File tree

4 files changed

+43
-0
lines changed

4 files changed

+43
-0
lines changed

collector.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -961,6 +961,12 @@ pgws_collector_main(Datum main_arg)
961961
}
962962
shm_mq_detach(mqh);
963963
}
964+
else if (request == HISTORY_RESET)
965+
{
966+
/* Reset history */
967+
pfree(observations.items);
968+
alloc_history(&observations, pgws_historySize);
969+
}
964970
else if (request == PROFILE_RESET)
965971
{
966972
/* Reset profile hash */

pg_wait_sampling--1.1--1.2.sql

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,14 @@ CREATE VIEW pg_wait_sampling_profile_extended AS
102102

103103
GRANT SELECT ON pg_wait_sampling_profile_extended TO PUBLIC;
104104

105+
CREATE FUNCTION pg_wait_sampling_reset_history()
106+
RETURNS void
107+
AS 'MODULE_PATHNAME'
108+
LANGUAGE C VOLATILE STRICT;
109+
110+
-- Don't want this to be available to non-superusers.
111+
REVOKE ALL ON FUNCTION pg_wait_sampling_reset_history() FROM PUBLIC;
112+
105113
--CREATE VIEW pg_wait_sampling_profile AS
106114
-- SELECT pid, event_type, event, queryid, SUM(count) FROM pg_wait_sampling_profile_extended
107115
-- GROUP BY pid, event_type, event, queryid;

pg_wait_sampling.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1439,6 +1439,34 @@ pg_wait_sampling_reset_profile(PG_FUNCTION_ARGS)
14391439
PG_RETURN_VOID();
14401440
}
14411441

1442+
PG_FUNCTION_INFO_V1(pg_wait_sampling_reset_history);
1443+
Datum
1444+
pg_wait_sampling_reset_history(PG_FUNCTION_ARGS)
1445+
{
1446+
LOCKTAG collectorTag;
1447+
1448+
check_shmem();
1449+
1450+
pgws_init_lock_tag(&queueTag, PGWS_QUEUE_LOCK);
1451+
1452+
LockAcquire(&queueTag, ExclusiveLock, false, false);
1453+
1454+
pgws_init_lock_tag(&collectorTag, PGWS_COLLECTOR_LOCK);
1455+
LockAcquire(&collectorTag, ExclusiveLock, false, false);
1456+
pgws_collector_hdr->request = HISTORY_RESET;
1457+
LockRelease(&collectorTag, ExclusiveLock, false);
1458+
1459+
if (!pgws_collector_hdr->latch)
1460+
ereport(ERROR, (errcode(ERRCODE_INTERNAL_ERROR),
1461+
errmsg("pg_wait_sampling collector wasn't started")));
1462+
1463+
SetLatch(pgws_collector_hdr->latch);
1464+
1465+
LockRelease(&queueTag, ExclusiveLock, false);
1466+
1467+
PG_RETURN_VOID();
1468+
}
1469+
14421470
//TODO OBSOLETE
14431471
PG_FUNCTION_INFO_V1(pg_wait_sampling_get_history);
14441472
Datum

pg_wait_sampling.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ typedef enum
100100
{
101101
NO_REQUEST,
102102
HISTORY_REQUEST,
103+
HISTORY_RESET,
103104
PROFILE_REQUEST,
104105
PROFILE_RESET
105106
} SHMRequest;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy