diff options
-rw-r--r-- | ctdb/include/ctdb_protocol.h | 4 | ||||
-rw-r--r-- | ctdb/server/ctdb_ltdb_server.c | 8 | ||||
-rw-r--r-- | ctdb/server/ctdb_recoverd.c | 46 |
3 files changed, 58 insertions, 0 deletions
diff --git a/ctdb/include/ctdb_protocol.h b/ctdb/include/ctdb_protocol.h index f2d68f4c3a..629c91c0cd 100644 --- a/ctdb/include/ctdb_protocol.h +++ b/ctdb/include/ctdb_protocol.h @@ -114,6 +114,10 @@ struct ctdb_call_info { #define CTDB_SRVID_VACUUM_FETCH 0xF700000000000000LL /* + * a message to tell recovery daemon to detach a database + */ +#define CTDB_SRVID_DETACH_DATABASE 0xF701000000000000LL +/* a message to tell the recovery daemon to write a talloc memdump to the log */ diff --git a/ctdb/server/ctdb_ltdb_server.c b/ctdb/server/ctdb_ltdb_server.c index 19c6a82b9c..6ff92c54e3 100644 --- a/ctdb/server/ctdb_ltdb_server.c +++ b/ctdb/server/ctdb_ltdb_server.c @@ -1220,6 +1220,14 @@ int32_t ctdb_control_db_detach(struct ctdb_context *ctdb, TDB_DATA indata, return -1; } + /* Detach database from recoverd */ + if (ctdb_daemon_send_message(ctdb, ctdb->pnn, + CTDB_SRVID_DETACH_DATABASE, + indata) != 0) { + DEBUG(DEBUG_ERR, ("Unable to detach DB from recoverd\n")); + return -1; + } + /* Disable vacuuming and drop all vacuuming data */ talloc_free(ctdb_db->vacuum_handle); talloc_free(ctdb_db->delete_queue); diff --git a/ctdb/server/ctdb_recoverd.c b/ctdb/server/ctdb_recoverd.c index ac692ec541..77586353c7 100644 --- a/ctdb/server/ctdb_recoverd.c +++ b/ctdb/server/ctdb_recoverd.c @@ -1095,6 +1095,47 @@ static void vacuum_fetch_handler(struct ctdb_context *ctdb, uint64_t srvid, /* + * handler for database detach + */ +static void detach_database_handler(struct ctdb_context *ctdb, uint64_t srvid, + TDB_DATA data, void *private_data) +{ + struct ctdb_recoverd *rec = talloc_get_type(private_data, + struct ctdb_recoverd); + uint32_t db_id; + struct vacuum_info *v, *vnext; + struct ctdb_db_context *ctdb_db; + + if (data.dsize != sizeof(db_id)) { + return; + } + db_id = *(uint32_t *)data.dptr; + + ctdb_db = find_ctdb_db(ctdb, db_id); + if (ctdb_db == NULL) { + /* database is not attached */ + return; + } + + /* Stop any active vacuum fetch */ + v = rec->vacuum_info; + while (v != NULL) { + vnext = v->next; + + if (v->ctdb_db->db_id == db_id) { + talloc_free(v); + } + v = vnext; + } + + DLIST_REMOVE(ctdb->db_list, ctdb_db); + + DEBUG(DEBUG_NOTICE, ("Detached from database '%s'\n", + ctdb_db->db_name)); + talloc_free(ctdb_db); +} + +/* called when ctdb_wait_timeout should finish */ static void ctdb_wait_handler(struct event_context *ev, struct timed_event *te, @@ -4145,6 +4186,11 @@ static void monitor_cluster(struct ctdb_context *ctdb) CTDB_SRVID_DISABLE_TAKEOVER_RUNS, disable_takeover_runs_handler, rec); + /* register a message port for detaching database */ + ctdb_client_set_message_handler(ctdb, + CTDB_SRVID_DETACH_DATABASE, + detach_database_handler, rec); + for (;;) { TALLOC_CTX *mem_ctx = talloc_new(ctdb); struct timeval start; |