mirror of https://github.com/citusdata/citus.git
Show IDLE backends in citus_dist_stat_activity (#5700)
* Break the dependency to CitusInitiatedBackend infrastructure With this change, we start to show non-distributed backends as well in citus_dist_stat_activity. I think that (a) it is essential for making citus_lock_waits to work for blocked on DDL commands. (b) it is more expected from the user's perspective. The name of the view is a little inconsistent now (e.g., citus_dist_stat_activity) but we are already planning to improve the names with followup PRs. Also, we have global pids assigned, the CitusInitiatedBackend becomes obsolete.pull/5682/head
parent
defc2d991f
commit
dc6c194916
|
@ -155,7 +155,12 @@ FROM \
|
||||||
get_all_active_transactions() AS dist_txs(database_id, process_id, initiator_node_identifier, worker_query, transaction_number, transaction_stamp, global_pid) \
|
get_all_active_transactions() AS dist_txs(database_id, process_id, initiator_node_identifier, worker_query, transaction_number, transaction_stamp, global_pid) \
|
||||||
ON pg_stat_activity.pid = dist_txs.process_id \
|
ON pg_stat_activity.pid = dist_txs.process_id \
|
||||||
WHERE \
|
WHERE \
|
||||||
dist_txs.worker_query = false;"
|
backend_type = 'client backend' \
|
||||||
|
AND \
|
||||||
|
pg_stat_activity.query NOT ILIKE '%stat_activity%' \
|
||||||
|
AND \
|
||||||
|
pg_stat_activity.application_name NOT SIMILAR TO 'citus_internal gpid=\\d+'; \
|
||||||
|
"
|
||||||
|
|
||||||
#define CITUS_WORKER_STAT_ACTIVITY_QUERY \
|
#define CITUS_WORKER_STAT_ACTIVITY_QUERY \
|
||||||
"\
|
"\
|
||||||
|
@ -186,7 +191,7 @@ SELECT \
|
||||||
dist_txs.global_id \
|
dist_txs.global_id \
|
||||||
FROM \
|
FROM \
|
||||||
pg_stat_activity \
|
pg_stat_activity \
|
||||||
LEFT JOIN \
|
JOIN \
|
||||||
get_all_active_transactions() AS dist_txs(database_id, process_id, initiator_node_identifier, worker_query, transaction_number, transaction_stamp, global_id) \
|
get_all_active_transactions() AS dist_txs(database_id, process_id, initiator_node_identifier, worker_query, transaction_number, transaction_stamp, global_id) \
|
||||||
ON pg_stat_activity.pid = dist_txs.process_id \
|
ON pg_stat_activity.pid = dist_txs.process_id \
|
||||||
WHERE \
|
WHERE \
|
||||||
|
|
|
@ -32,7 +32,7 @@ pg_sleep
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
step s2-view-dist:
|
step s2-view-dist:
|
||||||
SELECT query, query_hostname, query_hostport, distributed_query_host_name, distributed_query_host_port, state, wait_event_type, wait_event, usename, datname FROM citus_dist_stat_activity WHERE query NOT ILIKE '%pg_prepared_xacts%' AND query NOT ILIKE '%COMMIT%' ORDER BY query DESC;
|
SELECT query, query_hostname, query_hostport, distributed_query_host_name, distributed_query_host_port, state, wait_event_type, wait_event, usename, datname FROM citus_dist_stat_activity WHERE query NOT ILIKE '%pg_prepared_xacts%' AND query NOT ILIKE '%COMMIT%' and query not ILIKE '%BEGIN%' and query NOT ILIKE '%pg_catalog.pg_isolation_test_session_is_blocked%' ORDER BY query DESC;
|
||||||
|
|
||||||
query |query_hostname |query_hostport|distributed_query_host_name|distributed_query_host_port|state |wait_event_type|wait_event|usename |datname
|
query |query_hostname |query_hostport|distributed_query_host_name|distributed_query_host_port|state |wait_event_type|wait_event|usename |datname
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
@ -102,7 +102,7 @@ pg_sleep
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
step s2-view-dist:
|
step s2-view-dist:
|
||||||
SELECT query, query_hostname, query_hostport, distributed_query_host_name, distributed_query_host_port, state, wait_event_type, wait_event, usename, datname FROM citus_dist_stat_activity WHERE query NOT ILIKE '%pg_prepared_xacts%' AND query NOT ILIKE '%COMMIT%' ORDER BY query DESC;
|
SELECT query, query_hostname, query_hostport, distributed_query_host_name, distributed_query_host_port, state, wait_event_type, wait_event, usename, datname FROM citus_dist_stat_activity WHERE query NOT ILIKE '%pg_prepared_xacts%' AND query NOT ILIKE '%COMMIT%' and query not ILIKE '%BEGIN%' and query NOT ILIKE '%pg_catalog.pg_isolation_test_session_is_blocked%' ORDER BY query DESC;
|
||||||
|
|
||||||
query |query_hostname |query_hostport|distributed_query_host_name|distributed_query_host_port|state |wait_event_type|wait_event|usename |datname
|
query |query_hostname |query_hostport|distributed_query_host_name|distributed_query_host_port|state |wait_event_type|wait_event|usename |datname
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
@ -166,7 +166,7 @@ pg_sleep
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
step s2-view-dist:
|
step s2-view-dist:
|
||||||
SELECT query, query_hostname, query_hostport, distributed_query_host_name, distributed_query_host_port, state, wait_event_type, wait_event, usename, datname FROM citus_dist_stat_activity WHERE query NOT ILIKE '%pg_prepared_xacts%' AND query NOT ILIKE '%COMMIT%' ORDER BY query DESC;
|
SELECT query, query_hostname, query_hostport, distributed_query_host_name, distributed_query_host_port, state, wait_event_type, wait_event, usename, datname FROM citus_dist_stat_activity WHERE query NOT ILIKE '%pg_prepared_xacts%' AND query NOT ILIKE '%COMMIT%' and query not ILIKE '%BEGIN%' and query NOT ILIKE '%pg_catalog.pg_isolation_test_session_is_blocked%' ORDER BY query DESC;
|
||||||
|
|
||||||
query |query_hostname |query_hostport|distributed_query_host_name|distributed_query_host_port|state |wait_event_type|wait_event|usename |datname
|
query |query_hostname |query_hostport|distributed_query_host_name|distributed_query_host_port|state |wait_event_type|wait_event|usename |datname
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
@ -233,7 +233,7 @@ pg_sleep
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
step s2-view-dist:
|
step s2-view-dist:
|
||||||
SELECT query, query_hostname, query_hostport, distributed_query_host_name, distributed_query_host_port, state, wait_event_type, wait_event, usename, datname FROM citus_dist_stat_activity WHERE query NOT ILIKE '%pg_prepared_xacts%' AND query NOT ILIKE '%COMMIT%' ORDER BY query DESC;
|
SELECT query, query_hostname, query_hostport, distributed_query_host_name, distributed_query_host_port, state, wait_event_type, wait_event, usename, datname FROM citus_dist_stat_activity WHERE query NOT ILIKE '%pg_prepared_xacts%' AND query NOT ILIKE '%COMMIT%' and query not ILIKE '%BEGIN%' and query NOT ILIKE '%pg_catalog.pg_isolation_test_session_is_blocked%' ORDER BY query DESC;
|
||||||
|
|
||||||
query |query_hostname |query_hostport|distributed_query_host_name|distributed_query_host_port|state |wait_event_type|wait_event|usename |datname
|
query |query_hostname |query_hostport|distributed_query_host_name|distributed_query_host_port|state |wait_event_type|wait_event|usename |datname
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
|
|
@ -31,7 +31,7 @@ run_commands_on_session_level_connection_to_node
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
step s2-coordinator-citus_dist_stat_activity:
|
step s2-coordinator-citus_dist_stat_activity:
|
||||||
SELECT global_pid != 0 FROM citus_dist_stat_activity() WHERE query LIKE '%SELECT * FROM dist\_table%';
|
SELECT global_pid != 0 FROM citus_dist_stat_activity() WHERE query LIKE '%SELECT * FROM dist\_table%' and query NOT ILIKE '%run_commands_on_session_level_connection_to_node%';
|
||||||
|
|
||||||
?column?
|
?column?
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
@ -93,7 +93,7 @@ a|b
|
||||||
(0 rows)
|
(0 rows)
|
||||||
|
|
||||||
step s2-coordinator-citus_dist_stat_activity:
|
step s2-coordinator-citus_dist_stat_activity:
|
||||||
SELECT global_pid != 0 FROM citus_dist_stat_activity() WHERE query LIKE '%SELECT * FROM dist\_table%';
|
SELECT global_pid != 0 FROM citus_dist_stat_activity() WHERE query LIKE '%SELECT * FROM dist\_table%' and query NOT ILIKE '%run_commands_on_session_level_connection_to_node%';
|
||||||
|
|
||||||
?column?
|
?column?
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
|
|
@ -83,14 +83,17 @@ pg_sleep
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
step s2-view-dist:
|
step s2-view-dist:
|
||||||
SELECT query, query_hostname, query_hostport, distributed_query_host_name, distributed_query_host_port, state, wait_event_type, wait_event, usename, datname FROM citus_dist_stat_activity WHERE query NOT ILIKE '%pg_prepared_xacts%' AND query NOT ILIKE '%COMMIT%' ORDER BY query DESC;
|
SELECT query, query_hostname, query_hostport, distributed_query_host_name, distributed_query_host_port, state, wait_event_type, wait_event, usename, datname FROM citus_dist_stat_activity WHERE query NOT ILIKE '%pg_prepared_xacts%' AND query NOT ILIKE '%COMMIT%' AND query NOT ILIKE '%pg_isolation_test_session_is_blocked%' AND query NOT ILIKE '%BEGIN%' ORDER BY query DESC;
|
||||||
|
|
||||||
query |query_hostname |query_hostport|distributed_query_host_name|distributed_query_host_port|state |wait_event_type|wait_event|usename |datname
|
query |query_hostname |query_hostport|distributed_query_host_name|distributed_query_host_port|state |wait_event_type|wait_event|usename |datname
|
||||||
---------------------------------------------------------------------
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
SELECT check_distributed_deadlocks();
|
||||||
|
|coordinator_host| 57636| | 0|idle |Client |ClientRead|postgres|regression
|
||||||
|
|
||||||
update ref_table set a = a + 1;
|
update ref_table set a = a + 1;
|
||||||
|coordinator_host| 57636|coordinator_host | 57636|idle in transaction|Client |ClientRead|postgres|regression
|
|coordinator_host| 57636|coordinator_host | 57636|idle in transaction|Client |ClientRead|postgres|regression
|
||||||
(1 row)
|
(2 rows)
|
||||||
|
|
||||||
step s2-view-worker:
|
step s2-view-worker:
|
||||||
SELECT query, query_hostname, query_hostport, distributed_query_host_name,
|
SELECT query, query_hostname, query_hostport, distributed_query_host_name,
|
||||||
|
|
|
@ -71,7 +71,7 @@ step "s2-sleep"
|
||||||
|
|
||||||
step "s2-view-dist"
|
step "s2-view-dist"
|
||||||
{
|
{
|
||||||
SELECT query, query_hostname, query_hostport, distributed_query_host_name, distributed_query_host_port, state, wait_event_type, wait_event, usename, datname FROM citus_dist_stat_activity WHERE query NOT ILIKE '%pg_prepared_xacts%' AND query NOT ILIKE '%COMMIT%' ORDER BY query DESC;
|
SELECT query, query_hostname, query_hostport, distributed_query_host_name, distributed_query_host_port, state, wait_event_type, wait_event, usename, datname FROM citus_dist_stat_activity WHERE query NOT ILIKE '%pg_prepared_xacts%' AND query NOT ILIKE '%COMMIT%' and query not ILIKE '%BEGIN%' and query NOT ILIKE '%pg_catalog.pg_isolation_test_session_is_blocked%' ORDER BY query DESC;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,7 @@ session "s2"
|
||||||
|
|
||||||
step "s2-coordinator-citus_dist_stat_activity"
|
step "s2-coordinator-citus_dist_stat_activity"
|
||||||
{
|
{
|
||||||
SELECT global_pid != 0 FROM citus_dist_stat_activity() WHERE query LIKE '%SELECT * FROM dist\_table%';
|
SELECT global_pid != 0 FROM citus_dist_stat_activity() WHERE query LIKE '%SELECT * FROM dist\_table%' and query NOT ILIKE '%run_commands_on_session_level_connection_to_node%';
|
||||||
}
|
}
|
||||||
|
|
||||||
step "s2-coordinator-citus_worker_stat_activity"
|
step "s2-coordinator-citus_worker_stat_activity"
|
||||||
|
|
|
@ -83,7 +83,7 @@ step "s2-lock-ref-table-placement-on-coordinator"
|
||||||
|
|
||||||
step "s2-view-dist"
|
step "s2-view-dist"
|
||||||
{
|
{
|
||||||
SELECT query, query_hostname, query_hostport, distributed_query_host_name, distributed_query_host_port, state, wait_event_type, wait_event, usename, datname FROM citus_dist_stat_activity WHERE query NOT ILIKE '%pg_prepared_xacts%' AND query NOT ILIKE '%COMMIT%' ORDER BY query DESC;
|
SELECT query, query_hostname, query_hostport, distributed_query_host_name, distributed_query_host_port, state, wait_event_type, wait_event, usename, datname FROM citus_dist_stat_activity WHERE query NOT ILIKE '%pg_prepared_xacts%' AND query NOT ILIKE '%COMMIT%' AND query NOT ILIKE '%pg_isolation_test_session_is_blocked%' AND query NOT ILIKE '%BEGIN%' ORDER BY query DESC;
|
||||||
}
|
}
|
||||||
|
|
||||||
step "s2-view-worker"
|
step "s2-view-worker"
|
||||||
|
@ -114,6 +114,7 @@ step "s2-active-transactions"
|
||||||
// thus we manually issue the deadlock detection
|
// thus we manually issue the deadlock detection
|
||||||
session "deadlock-checker"
|
session "deadlock-checker"
|
||||||
|
|
||||||
|
|
||||||
// we issue the checker not only when there are deadlocks to ensure that we never cancel
|
// we issue the checker not only when there are deadlocks to ensure that we never cancel
|
||||||
// backend inappropriately
|
// backend inappropriately
|
||||||
step "deadlock-checker-call"
|
step "deadlock-checker-call"
|
||||||
|
|
Loading…
Reference in New Issue