From 10cd79a957fac7b8dc310e4cc81d6e3a56a6c5ec Mon Sep 17 00:00:00 2001 From: SaitTalhaNisanci Date: Wed, 15 Apr 2020 14:28:27 +0300 Subject: [PATCH] add invalidate_inactive_shared_connections test function We introduce invalidate_inactive_shared_connections udf to be used in testing. It is possible that a connection count for an inactive node will be greater than 0 and in that case it will not be removed at the time of invalidation. However, later we don't have a mechanism to remove it, which means that it will stay in the hash. For this not to cause a problem, we use this udf in testing. --- .../distributed/connection/shared_connection_stats.c | 1 - .../regress/expected/ensure_no_shared_connection_leak.out | 7 +++++++ src/test/regress/sql/ensure_no_shared_connection_leak.sql | 3 +++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/backend/distributed/connection/shared_connection_stats.c b/src/backend/distributed/connection/shared_connection_stats.c index ffcd3ca30..92505caeb 100644 --- a/src/backend/distributed/connection/shared_connection_stats.c +++ b/src/backend/distributed/connection/shared_connection_stats.c @@ -110,7 +110,6 @@ static uint32 SharedConnectionHashHash(const void *key, Size keysize); PG_FUNCTION_INFO_V1(citus_remote_connection_stats); - /* * citus_remote_connection_stats returns all the avaliable information about all * the remote connections (a.k.a., connections to remote nodes). diff --git a/src/test/regress/expected/ensure_no_shared_connection_leak.out b/src/test/regress/expected/ensure_no_shared_connection_leak.out index 060313c60..753415982 100644 --- a/src/test/regress/expected/ensure_no_shared_connection_leak.out +++ b/src/test/regress/expected/ensure_no_shared_connection_leak.out @@ -117,6 +117,13 @@ SELECT pg_reload_conf(); \c - - - :master_port SET search_path TO ensure_no_shared_connection_leak; +-- invalidate inactive shared connections +SELECT invalidate_inactive_shared_connections(); + invalidate_inactive_shared_connections +--------------------------------------------------------------------- + +(1 row) + -- ensure that we only have at most citus.max_cached_conns_per_worker -- connections per node select diff --git a/src/test/regress/sql/ensure_no_shared_connection_leak.sql b/src/test/regress/sql/ensure_no_shared_connection_leak.sql index df4847cfb..2d95adb5a 100644 --- a/src/test/regress/sql/ensure_no_shared_connection_leak.sql +++ b/src/test/regress/sql/ensure_no_shared_connection_leak.sql @@ -54,6 +54,9 @@ SELECT pg_reload_conf(); \c - - - :master_port SET search_path TO ensure_no_shared_connection_leak; +-- invalidate inactive shared connections +SELECT invalidate_inactive_shared_connections(); + -- ensure that we only have at most citus.max_cached_conns_per_worker -- connections per node select