mirror of https://github.com/citusdata/citus.git
Stop background daemon before dropping the database (#6688)
DESCRIPTION: Stop maintenance daemon when dropping a database even without Citus extension Fixes #6670pull/6688/merge
parent
c7f8c5de99
commit
b6a4652849
|
@ -219,6 +219,23 @@ multi_ProcessUtility(PlannedStmt *pstmt,
|
||||||
PreprocessCreateExtensionStmtForCitusColumnar(parsetree);
|
PreprocessCreateExtensionStmtForCitusColumnar(parsetree);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Make sure that on DROP DATABASE we terminate the background daemon
|
||||||
|
* associated with it.
|
||||||
|
*/
|
||||||
|
if (IsA(parsetree, DropdbStmt))
|
||||||
|
{
|
||||||
|
const bool missingOK = true;
|
||||||
|
DropdbStmt *dropDbStatement = (DropdbStmt *) parsetree;
|
||||||
|
char *dbname = dropDbStatement->dbname;
|
||||||
|
Oid databaseOid = get_database_oid(dbname, missingOK);
|
||||||
|
|
||||||
|
if (OidIsValid(databaseOid))
|
||||||
|
{
|
||||||
|
StopMaintenanceDaemon(databaseOid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!CitusHasBeenLoaded())
|
if (!CitusHasBeenLoaded())
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
|
@ -678,22 +695,9 @@ ProcessUtilityInternal(PlannedStmt *pstmt,
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Make sure that on DROP DATABASE we terminate the background daemon
|
* Make sure that on DROP EXTENSION we terminate the background daemon
|
||||||
* associated with it.
|
* associated with it.
|
||||||
*/
|
*/
|
||||||
if (IsA(parsetree, DropdbStmt))
|
|
||||||
{
|
|
||||||
const bool missingOK = true;
|
|
||||||
DropdbStmt *dropDbStatement = (DropdbStmt *) parsetree;
|
|
||||||
char *dbname = dropDbStatement->dbname;
|
|
||||||
Oid databaseOid = get_database_oid(dbname, missingOK);
|
|
||||||
|
|
||||||
if (OidIsValid(databaseOid))
|
|
||||||
{
|
|
||||||
StopMaintenanceDaemon(databaseOid);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (IsDropCitusExtensionStmt(parsetree))
|
if (IsDropCitusExtensionStmt(parsetree))
|
||||||
{
|
{
|
||||||
StopMaintenanceDaemon(MyDatabaseId);
|
StopMaintenanceDaemon(MyDatabaseId);
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
-- coordinator
|
||||||
|
CREATE SCHEMA drop_database;
|
||||||
|
SET search_path TO drop_database;
|
||||||
|
SET citus.shard_count TO 4;
|
||||||
|
SET citus.shard_replication_factor TO 1;
|
||||||
|
SET citus.next_shard_id TO 35137400;
|
||||||
|
CREATE DATABASE citus_created;
|
||||||
|
NOTICE: Citus partially supports CREATE DATABASE for distributed databases
|
||||||
|
DETAIL: Citus does not propagate CREATE DATABASE command to workers
|
||||||
|
HINT: You can manually create a database and its extensions on workers.
|
||||||
|
\c citus_created
|
||||||
|
CREATE EXTENSION citus;
|
||||||
|
CREATE DATABASE citus_not_created;
|
||||||
|
NOTICE: Citus partially supports CREATE DATABASE for distributed databases
|
||||||
|
DETAIL: Citus does not propagate CREATE DATABASE command to workers
|
||||||
|
HINT: You can manually create a database and its extensions on workers.
|
||||||
|
\c citus_not_created
|
||||||
|
DROP DATABASE citus_created;
|
||||||
|
\c regression
|
||||||
|
DROP DATABASE citus_not_created;
|
||||||
|
-- worker1
|
||||||
|
\c - - - :worker_1_port
|
||||||
|
SET search_path TO drop_database;
|
||||||
|
SET citus.shard_count TO 4;
|
||||||
|
SET citus.shard_replication_factor TO 1;
|
||||||
|
SET citus.next_shard_id TO 35137400;
|
||||||
|
CREATE DATABASE citus_created;
|
||||||
|
NOTICE: Citus partially supports CREATE DATABASE for distributed databases
|
||||||
|
DETAIL: Citus does not propagate CREATE DATABASE command to workers
|
||||||
|
HINT: You can manually create a database and its extensions on workers.
|
||||||
|
\c citus_created
|
||||||
|
CREATE EXTENSION citus;
|
||||||
|
CREATE DATABASE citus_not_created;
|
||||||
|
NOTICE: Citus partially supports CREATE DATABASE for distributed databases
|
||||||
|
DETAIL: Citus does not propagate CREATE DATABASE command to workers
|
||||||
|
HINT: You can manually create a database and its extensions on workers.
|
||||||
|
\c citus_not_created
|
||||||
|
DROP DATABASE citus_created;
|
||||||
|
\c regression
|
||||||
|
DROP DATABASE citus_not_created;
|
||||||
|
\c - - - :master_port
|
||||||
|
SET client_min_messages TO WARNING;
|
||||||
|
DROP SCHEMA drop_database CASCADE;
|
|
@ -121,3 +121,4 @@ test: ensure_no_shared_connection_leak
|
||||||
test: check_mx
|
test: check_mx
|
||||||
|
|
||||||
test: generated_identity
|
test: generated_identity
|
||||||
|
test: drop_database
|
||||||
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
-- coordinator
|
||||||
|
CREATE SCHEMA drop_database;
|
||||||
|
SET search_path TO drop_database;
|
||||||
|
SET citus.shard_count TO 4;
|
||||||
|
SET citus.shard_replication_factor TO 1;
|
||||||
|
SET citus.next_shard_id TO 35137400;
|
||||||
|
|
||||||
|
CREATE DATABASE citus_created;
|
||||||
|
|
||||||
|
\c citus_created
|
||||||
|
CREATE EXTENSION citus;
|
||||||
|
|
||||||
|
CREATE DATABASE citus_not_created;
|
||||||
|
|
||||||
|
\c citus_not_created
|
||||||
|
DROP DATABASE citus_created;
|
||||||
|
|
||||||
|
\c regression
|
||||||
|
DROP DATABASE citus_not_created;
|
||||||
|
|
||||||
|
-- worker1
|
||||||
|
\c - - - :worker_1_port
|
||||||
|
|
||||||
|
SET search_path TO drop_database;
|
||||||
|
SET citus.shard_count TO 4;
|
||||||
|
SET citus.shard_replication_factor TO 1;
|
||||||
|
SET citus.next_shard_id TO 35137400;
|
||||||
|
|
||||||
|
CREATE DATABASE citus_created;
|
||||||
|
|
||||||
|
\c citus_created
|
||||||
|
CREATE EXTENSION citus;
|
||||||
|
|
||||||
|
CREATE DATABASE citus_not_created;
|
||||||
|
|
||||||
|
\c citus_not_created
|
||||||
|
DROP DATABASE citus_created;
|
||||||
|
|
||||||
|
\c regression
|
||||||
|
DROP DATABASE citus_not_created;
|
||||||
|
|
||||||
|
\c - - - :master_port
|
||||||
|
|
||||||
|
SET client_min_messages TO WARNING;
|
||||||
|
DROP SCHEMA drop_database CASCADE;
|
Loading…
Reference in New Issue