diff options
author | Amitay Isaacs <amitay@gmail.com> | 2014-04-22 15:24:49 +1000 |
---|---|---|
committer | Michael Adam <obnox@samba.org> | 2014-04-23 17:05:45 +0200 |
commit | 463ea9e52541aaadcdcf97808d05ca6dacbbea6e (patch) | |
tree | 13e69b7cbdd43a4fea2979b9149c1de0cdfe5c0a /ctdb/server | |
parent | b31240acafb20100cf249c6346fb41f90a06158b (diff) | |
download | samba-463ea9e52541aaadcdcf97808d05ca6dacbbea6e.tar.gz samba-463ea9e52541aaadcdcf97808d05ca6dacbbea6e.tar.xz samba-463ea9e52541aaadcdcf97808d05ca6dacbbea6e.zip |
ctdb-recoverd: Detach database from recovery daemon
As part of vacuuming, recoverd attaches to databases to migrate records.
When detaching a database from main daemon, it should be removed from
recovery daemon also.
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Michael Adam <obnox@samba.org>
Autobuild-User(master): Michael Adam <obnox@samba.org>
Autobuild-Date(master): Wed Apr 23 17:05:45 CEST 2014 on sn-devel-104
Diffstat (limited to 'ctdb/server')
-rw-r--r-- | ctdb/server/ctdb_ltdb_server.c | 8 | ||||
-rw-r--r-- | ctdb/server/ctdb_recoverd.c | 46 |
2 files changed, 54 insertions, 0 deletions
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; |