mirror of https://github.com/citusdata/citus.git
- Synced with main
- Removed maintenance_management_database GUC and logicpull/7286/head
parent
b3bfca9ac6
commit
f447b39b84
|
@ -360,9 +360,7 @@ StartNodeUserDatabaseConnection(uint32 flags, const char *hostname, int32 port,
|
||||||
MultiConnection *connection = FindAvailableConnection(entry->connections, flags);
|
MultiConnection *connection = FindAvailableConnection(entry->connections, flags);
|
||||||
if (connection)
|
if (connection)
|
||||||
{
|
{
|
||||||
if ((flags & REQUIRE_MAINTENANCE_CONNECTION) &&
|
if (flags & REQUIRE_MAINTENANCE_CONNECTION)
|
||||||
IsMaintenanceDaemon &&
|
|
||||||
!IsMaintenanceManagementDatabase(MyDatabaseId))
|
|
||||||
{
|
{
|
||||||
// Maintenance database may have changed, so cached connection should be closed
|
// Maintenance database may have changed, so cached connection should be closed
|
||||||
connection->forceCloseAtTransactionEnd = true;
|
connection->forceCloseAtTransactionEnd = true;
|
||||||
|
@ -446,10 +444,7 @@ StartNodeUserDatabaseConnection(uint32 flags, const char *hostname, int32 port,
|
||||||
else if (flags & REQUIRE_MAINTENANCE_CONNECTION)
|
else if (flags & REQUIRE_MAINTENANCE_CONNECTION)
|
||||||
{
|
{
|
||||||
connection->useForMaintenanceOperations = true;
|
connection->useForMaintenanceOperations = true;
|
||||||
if (IsMaintenanceDaemon && !IsMaintenanceManagementDatabase(MyDatabaseId))
|
connection->forceCloseAtTransactionEnd = true;
|
||||||
{
|
|
||||||
connection->forceCloseAtTransactionEnd = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* fully initialized the connection, record it */
|
/* fully initialized the connection, record it */
|
||||||
|
|
|
@ -2705,17 +2705,6 @@ RegisterCitusConfigVariables(void)
|
||||||
GUC_STANDARD,
|
GUC_STANDARD,
|
||||||
NULL, NULL, NULL);
|
NULL, NULL, NULL);
|
||||||
|
|
||||||
DefineCustomStringVariable(
|
|
||||||
"citus.maintenance_management_database",
|
|
||||||
gettext_noop("Database for cluster-wide maintenance operations across all databases"),
|
|
||||||
gettext_noop("It should be enabled when there are more than "
|
|
||||||
"one database with Citus in a cluster."),
|
|
||||||
&MaintenanceManagementDatabase,
|
|
||||||
"",
|
|
||||||
PGC_SIGHUP,
|
|
||||||
GUC_STANDARD,
|
|
||||||
NULL, NULL, NULL);
|
|
||||||
|
|
||||||
/* warn about config items in the citus namespace that are not registered above */
|
/* warn about config items in the citus namespace that are not registered above */
|
||||||
EmitWarningsOnPlaceholders("citus");
|
EmitWarningsOnPlaceholders("citus");
|
||||||
|
|
||||||
|
|
|
@ -718,27 +718,24 @@ CitusMaintenanceDaemonMain(Datum main_arg)
|
||||||
InvalidateMetadataSystemCache();
|
InvalidateMetadataSystemCache();
|
||||||
StartTransactionCommand();
|
StartTransactionCommand();
|
||||||
|
|
||||||
|
/*
|
||||||
if ((strcmp(GetMaintenanceManagementDatabase(), "") == 0 || IsMaintenanceManagementDatabase(databaseOid)))
|
* We skip the deadlock detection if citus extension
|
||||||
|
* is not accessible.
|
||||||
|
*
|
||||||
|
* Similarly, we skip to run the deadlock checks if
|
||||||
|
* there exists any version mismatch or the extension
|
||||||
|
* is not fully created yet.
|
||||||
|
*/
|
||||||
|
if (!LockCitusExtension())
|
||||||
{
|
{
|
||||||
/*
|
ereport(DEBUG1, (errmsg("could not lock the citus extension, "
|
||||||
* We skip the deadlock detection if citus extension
|
"skipping deadlock detection")));
|
||||||
* is not accessible.
|
|
||||||
*
|
|
||||||
* Similarly, we skip to run the deadlock checks if
|
|
||||||
* there exists any version mismatch or the extension
|
|
||||||
* is not fully created yet.
|
|
||||||
*/
|
|
||||||
if (!LockCitusExtension())
|
|
||||||
{
|
|
||||||
ereport(DEBUG1, (errmsg("could not lock the citus extension, "
|
|
||||||
"skipping deadlock detection")));
|
|
||||||
}
|
|
||||||
else if (CheckCitusVersion(DEBUG1) && CitusHasBeenLoaded())
|
|
||||||
{
|
|
||||||
foundDeadlock = CheckForDistributedDeadlocks();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else if (CheckCitusVersion(DEBUG1) && CitusHasBeenLoaded())
|
||||||
|
{
|
||||||
|
foundDeadlock = CheckForDistributedDeadlocks();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
CommitTransactionCommand();
|
CommitTransactionCommand();
|
||||||
|
|
||||||
|
@ -1237,35 +1234,3 @@ MetadataSyncTriggeredCheckAndReset(MaintenanceDaemonDBData *dbData)
|
||||||
return metadataSyncTriggered;
|
return metadataSyncTriggered;
|
||||||
}
|
}
|
||||||
|
|
||||||
char
|
|
||||||
*GetMaintenanceManagementDatabase(void)
|
|
||||||
{
|
|
||||||
char *result = MaintenanceManagementDatabase;
|
|
||||||
/* If MaintenanceManagementDatabase is not set, all maintenance daemons are considered independent */
|
|
||||||
if (strcmp(MaintenanceManagementDatabase, "") != 0)
|
|
||||||
{
|
|
||||||
Oid maintenanceDatabaseOid = get_database_oid(MaintenanceManagementDatabase, true);
|
|
||||||
if (!maintenanceDatabaseOid)
|
|
||||||
{
|
|
||||||
ereport(WARNING, (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
|
||||||
errmsg("Database \"%s\" doesn't exists, please check the citus.maintenance_management_database parameter. "
|
|
||||||
"Applying a default value instead.",
|
|
||||||
MaintenanceManagementDatabase)));
|
|
||||||
result = "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
|
||||||
IsMaintenanceManagementDatabase(Oid databaseOid)
|
|
||||||
{
|
|
||||||
if (strcmp(GetMaintenanceManagementDatabase(), "") == 0)
|
|
||||||
{
|
|
||||||
/* If MaintenanceManagementDatabase is not set, all maintenance daemons are considered independent */
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
Oid maintenanceDatabaseOid = get_database_oid(MaintenanceManagementDatabase, true);
|
|
||||||
return maintenanceDatabaseOid == databaseOid;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,5 @@
|
||||||
-- This test verfies a behavioir of maintenance daemon in multi-database environment
|
-- This test verfies a behavioir of maintenance daemon in multi-database environment
|
||||||
-- It checks two things:
|
-- It checks that distributed deadlock detection and 2PC transaction recovery should respect the citus.shared_pool_size_maintenance_quota.
|
||||||
-- 1. Maintenance daemons should not cache connections, except the one for the citus.maintenance_management_database
|
|
||||||
-- 2. 2PC transaction recovery should respect the citus.shared_pool_size_maintenance_quota
|
|
||||||
-- 2. Distributed deadlock detection should run only on citus.maintenance_management_database.
|
|
||||||
--
|
|
||||||
-- To do that, it created 100 databases and syntactically generates distributed transactions in various states there.
|
-- To do that, it created 100 databases and syntactically generates distributed transactions in various states there.
|
||||||
SELECT $definition$
|
SELECT $definition$
|
||||||
ALTER SYSTEM SET citus.recover_2pc_interval TO '-1';
|
ALTER SYSTEM SET citus.recover_2pc_interval TO '-1';
|
||||||
|
@ -14,7 +10,6 @@ SELECT $definition$
|
||||||
SELECT $deinition$
|
SELECT $deinition$
|
||||||
ALTER SYSTEM SET citus.recover_2pc_interval TO '5s';
|
ALTER SYSTEM SET citus.recover_2pc_interval TO '5s';
|
||||||
ALTER SYSTEM RESET citus.distributed_deadlock_detection_factor;
|
ALTER SYSTEM RESET citus.distributed_deadlock_detection_factor;
|
||||||
ALTER SYSTEM SET citus.maintenance_management_database = 'regression';
|
|
||||||
SELECT pg_reload_conf();
|
SELECT pg_reload_conf();
|
||||||
$deinition$ AS turn_on_maintenance
|
$deinition$ AS turn_on_maintenance
|
||||||
\gset
|
\gset
|
||||||
|
@ -284,7 +279,7 @@ WHERE datname LIKE 'db%';
|
||||||
t
|
t
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT count(*) BETWEEN 1 AND 3 AS cached_connections_after_recovery_coordinator_test
|
SELECT count(*) = 0 AS cached_connections_after_recovery_coordinator_test
|
||||||
FROM pg_stat_activity
|
FROM pg_stat_activity
|
||||||
WHERE state = 'idle'
|
WHERE state = 'idle'
|
||||||
AND now() - backend_start > '5 seconds'::interval;
|
AND now() - backend_start > '5 seconds'::interval;
|
||||||
|
@ -303,7 +298,7 @@ WHERE gid LIKE 'citus_0_1234_4_0_%'
|
||||||
t
|
t
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT count(*) BETWEEN 1 AND 3 AS cached_connections_after_recovery_worker_1_test
|
SELECT count(*) = 0 AS cached_connections_after_recovery_worker_1_test
|
||||||
FROM pg_stat_activity
|
FROM pg_stat_activity
|
||||||
WHERE state = 'idle'
|
WHERE state = 'idle'
|
||||||
AND now() - backend_start > '5 seconds'::interval;
|
AND now() - backend_start > '5 seconds'::interval;
|
||||||
|
@ -322,7 +317,7 @@ WHERE gid LIKE 'citus_0_1234_4_0_%'
|
||||||
t
|
t
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT count(*) BETWEEN 1 AND 3 AS cached_connections_after_recovery_worker_2_test
|
SELECT count(*) = 0 AS cached_connections_after_recovery_worker_2_test
|
||||||
FROM pg_stat_activity
|
FROM pg_stat_activity
|
||||||
WHERE state = 'idle'
|
WHERE state = 'idle'
|
||||||
AND now() - backend_start > '5 seconds'::interval;
|
AND now() - backend_start > '5 seconds'::interval;
|
||||||
|
@ -336,7 +331,6 @@ WHERE state = 'idle'
|
||||||
SELECT $definition$
|
SELECT $definition$
|
||||||
ALTER SYSTEM RESET citus.recover_2pc_interval;
|
ALTER SYSTEM RESET citus.recover_2pc_interval;
|
||||||
ALTER SYSTEM RESET citus.distributed_deadlock_detection_factor;
|
ALTER SYSTEM RESET citus.distributed_deadlock_detection_factor;
|
||||||
ALTER SYSTEM RESET citus.maintenance_management_database;
|
|
||||||
SELECT pg_reload_conf();
|
SELECT pg_reload_conf();
|
||||||
|
|
||||||
DO
|
DO
|
||||||
|
@ -500,3 +494,5 @@ SELECT $definition$
|
||||||
0
|
0
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
\c - - - :master_port
|
||||||
|
DROP EXTENSION IF EXISTS dblink;
|
||||||
|
|
|
@ -1,9 +1,5 @@
|
||||||
-- This test verfies a behavioir of maintenance daemon in multi-database environment
|
-- This test verfies a behavioir of maintenance daemon in multi-database environment
|
||||||
-- It checks two things:
|
-- It checks that distributed deadlock detection and 2PC transaction recovery should respect the citus.shared_pool_size_maintenance_quota.
|
||||||
-- 1. Maintenance daemons should not cache connections, except the one for the citus.maintenance_management_database
|
|
||||||
-- 2. 2PC transaction recovery should respect the citus.shared_pool_size_maintenance_quota
|
|
||||||
-- 2. Distributed deadlock detection should run only on citus.maintenance_management_database.
|
|
||||||
--
|
|
||||||
-- To do that, it created 100 databases and syntactically generates distributed transactions in various states there.
|
-- To do that, it created 100 databases and syntactically generates distributed transactions in various states there.
|
||||||
|
|
||||||
SELECT $definition$
|
SELECT $definition$
|
||||||
|
@ -16,7 +12,6 @@ SELECT $definition$
|
||||||
SELECT $deinition$
|
SELECT $deinition$
|
||||||
ALTER SYSTEM SET citus.recover_2pc_interval TO '5s';
|
ALTER SYSTEM SET citus.recover_2pc_interval TO '5s';
|
||||||
ALTER SYSTEM RESET citus.distributed_deadlock_detection_factor;
|
ALTER SYSTEM RESET citus.distributed_deadlock_detection_factor;
|
||||||
ALTER SYSTEM SET citus.maintenance_management_database = 'regression';
|
|
||||||
SELECT pg_reload_conf();
|
SELECT pg_reload_conf();
|
||||||
$deinition$ AS turn_on_maintenance
|
$deinition$ AS turn_on_maintenance
|
||||||
\gset
|
\gset
|
||||||
|
@ -245,7 +240,7 @@ FROM pg_database,
|
||||||
$statement$) AS t(groupid integer, gid text)
|
$statement$) AS t(groupid integer, gid text)
|
||||||
WHERE datname LIKE 'db%';
|
WHERE datname LIKE 'db%';
|
||||||
|
|
||||||
SELECT count(*) BETWEEN 1 AND 3 AS cached_connections_after_recovery_coordinator_test
|
SELECT count(*) = 0 AS cached_connections_after_recovery_coordinator_test
|
||||||
FROM pg_stat_activity
|
FROM pg_stat_activity
|
||||||
WHERE state = 'idle'
|
WHERE state = 'idle'
|
||||||
AND now() - backend_start > '5 seconds'::interval;
|
AND now() - backend_start > '5 seconds'::interval;
|
||||||
|
@ -257,7 +252,7 @@ FROM pg_prepared_xacts
|
||||||
WHERE gid LIKE 'citus_0_1234_4_0_%'
|
WHERE gid LIKE 'citus_0_1234_4_0_%'
|
||||||
OR gid LIKE 'citus_0_should_be_forgotten_%';
|
OR gid LIKE 'citus_0_should_be_forgotten_%';
|
||||||
|
|
||||||
SELECT count(*) BETWEEN 1 AND 3 AS cached_connections_after_recovery_worker_1_test
|
SELECT count(*) = 0 AS cached_connections_after_recovery_worker_1_test
|
||||||
FROM pg_stat_activity
|
FROM pg_stat_activity
|
||||||
WHERE state = 'idle'
|
WHERE state = 'idle'
|
||||||
AND now() - backend_start > '5 seconds'::interval;
|
AND now() - backend_start > '5 seconds'::interval;
|
||||||
|
@ -269,7 +264,7 @@ FROM pg_prepared_xacts
|
||||||
WHERE gid LIKE 'citus_0_1234_4_0_%'
|
WHERE gid LIKE 'citus_0_1234_4_0_%'
|
||||||
OR gid LIKE 'citus_0_should_be_forgotten_%';
|
OR gid LIKE 'citus_0_should_be_forgotten_%';
|
||||||
|
|
||||||
SELECT count(*) BETWEEN 1 AND 3 AS cached_connections_after_recovery_worker_2_test
|
SELECT count(*) = 0 AS cached_connections_after_recovery_worker_2_test
|
||||||
FROM pg_stat_activity
|
FROM pg_stat_activity
|
||||||
WHERE state = 'idle'
|
WHERE state = 'idle'
|
||||||
AND now() - backend_start > '5 seconds'::interval;
|
AND now() - backend_start > '5 seconds'::interval;
|
||||||
|
@ -282,7 +277,6 @@ WHERE state = 'idle'
|
||||||
SELECT $definition$
|
SELECT $definition$
|
||||||
ALTER SYSTEM RESET citus.recover_2pc_interval;
|
ALTER SYSTEM RESET citus.recover_2pc_interval;
|
||||||
ALTER SYSTEM RESET citus.distributed_deadlock_detection_factor;
|
ALTER SYSTEM RESET citus.distributed_deadlock_detection_factor;
|
||||||
ALTER SYSTEM RESET citus.maintenance_management_database;
|
|
||||||
SELECT pg_reload_conf();
|
SELECT pg_reload_conf();
|
||||||
|
|
||||||
DO
|
DO
|
||||||
|
@ -421,3 +415,7 @@ SELECT $definition$
|
||||||
\c - - - :worker_2_port
|
\c - - - :worker_2_port
|
||||||
|
|
||||||
:cleanup
|
:cleanup
|
||||||
|
|
||||||
|
\c - - - :master_port
|
||||||
|
|
||||||
|
DROP EXTENSION IF EXISTS dblink;
|
||||||
|
|
Loading…
Reference in New Issue