diff options
author | Michael Paquier <michael@paquier.xyz> | 2023-08-20 15:35:02 +0900 |
---|---|---|
committer | Michael Paquier <michael@paquier.xyz> | 2023-08-20 15:35:02 +0900 |
commit | 1e68e43d3f0ff1dcf4a5926f9d6336b86bda034d (patch) | |
tree | f5ca7fce32380b095180dbdf147d5af176faccdf /src/test | |
parent | a2a6249cf1a4210caac534e8454a1614d0dd081a (diff) | |
download | postgresql-1e68e43d3f0ff1dcf4a5926f9d6336b86bda034d.tar.gz postgresql-1e68e43d3f0ff1dcf4a5926f9d6336b86bda034d.zip |
Add system view pg_wait_events
This new view, wrapped around a SRF, shows some information known about
wait events, as of:
- Name.
- Type (Activity, I/O, Extension, etc.).
- Description.
All the information retrieved comes from wait_event_names.txt, and the
description is the same as the documentation with filters applied to
remove any XML markups. This view is useful when joined with
pg_stat_activity to get the description of a wait event reported.
Custom wait events for extensions are included in the view.
Original idea by Yves Colin.
Author: Bertrand Drouvot
Reviewed-by: Kyotaro Horiguchi, Masahiro Ikeda, Tom Lane, Michael
Paquier
Discussion: https://postgr.es/m/0e2ae164-dc89-03c3-cf7f-de86378053ac@gmail.com
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/modules/worker_spi/t/001_worker_spi.pl | 6 | ||||
-rw-r--r-- | src/test/regress/expected/rules.out | 4 | ||||
-rw-r--r-- | src/test/regress/expected/sysviews.out | 16 | ||||
-rw-r--r-- | src/test/regress/sql/sysviews.sql | 4 |
4 files changed, 30 insertions, 0 deletions
diff --git a/src/test/modules/worker_spi/t/001_worker_spi.pl b/src/test/modules/worker_spi/t/001_worker_spi.pl index 26b8a49beca..2965acd7890 100644 --- a/src/test/modules/worker_spi/t/001_worker_spi.pl +++ b/src/test/modules/worker_spi/t/001_worker_spi.pl @@ -47,6 +47,12 @@ $result = $node->poll_query_until( is($result, 1, 'dynamic bgworker has reported "worker_spi_main" as wait event'); +# Check the wait event used by the dynamic bgworker appears in pg_wait_events +$result = $node->safe_psql('postgres', + q[SELECT count(*) > 0 from pg_wait_events where type = 'Extension' and name = 'worker_spi_main';] +); +is($result, 't', '"worker_spi_main" is reported in pg_wait_events'); + note "testing bgworkers loaded with shared_preload_libraries"; # Create the database first so as the workers can connect to it when diff --git a/src/test/regress/expected/rules.out b/src/test/regress/expected/rules.out index e07afcd4aa6..5058be5411a 100644 --- a/src/test/regress/expected/rules.out +++ b/src/test/regress/expected/rules.out @@ -2631,6 +2631,10 @@ pg_views| SELECT n.nspname AS schemaname, FROM (pg_class c LEFT JOIN pg_namespace n ON ((n.oid = c.relnamespace))) WHERE (c.relkind = 'v'::"char"); +pg_wait_events| SELECT type, + name, + description + FROM pg_get_wait_events() pg_get_wait_events(type, name, description); SELECT tablename, rulename, definition FROM pg_rules WHERE schemaname = 'pg_catalog' ORDER BY tablename, rulename; diff --git a/src/test/regress/expected/sysviews.out b/src/test/regress/expected/sysviews.out index 001c6e7eb9d..aae5d51e1c9 100644 --- a/src/test/regress/expected/sysviews.out +++ b/src/test/regress/expected/sysviews.out @@ -134,6 +134,22 @@ select name, setting from pg_settings where name like 'enable%'; enable_tidscan | on (21 rows) +-- There are always wait event descriptions for various types. +select type, count(*) > 0 as ok FROM pg_wait_events + group by type order by type COLLATE "C"; + type | ok +-----------+---- + Activity | t + BufferPin | t + Client | t + Extension | t + IO | t + IPC | t + LWLock | t + Lock | t + Timeout | t +(9 rows) + -- Test that the pg_timezone_names and pg_timezone_abbrevs views are -- more-or-less working. We can't test their contents in any great detail -- without the outputs changing anytime IANA updates the underlying data, diff --git a/src/test/regress/sql/sysviews.sql b/src/test/regress/sql/sysviews.sql index 351e469c77b..6b4e24601d9 100644 --- a/src/test/regress/sql/sysviews.sql +++ b/src/test/regress/sql/sysviews.sql @@ -55,6 +55,10 @@ select count(*) = 0 as ok from pg_stat_wal_receiver; -- a regression test run. select name, setting from pg_settings where name like 'enable%'; +-- There are always wait event descriptions for various types. +select type, count(*) > 0 as ok FROM pg_wait_events + group by type order by type COLLATE "C"; + -- Test that the pg_timezone_names and pg_timezone_abbrevs views are -- more-or-less working. We can't test their contents in any great detail -- without the outputs changing anytime IANA updates the underlying data, |