summaryrefslogtreecommitdiffstats
path: root/ctdb
diff options
context:
space:
mode:
authorAmitay Isaacs <amitay@gmail.com>2014-04-22 15:24:49 +1000
committerMichael Adam <obnox@samba.org>2014-04-23 17:05:45 +0200
commit463ea9e52541aaadcdcf97808d05ca6dacbbea6e (patch)
tree13e69b7cbdd43a4fea2979b9149c1de0cdfe5c0a /ctdb
parentb31240acafb20100cf249c6346fb41f90a06158b (diff)
downloadsamba-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')
-rw-r--r--ctdb/include/ctdb_protocol.h4
-rw-r--r--ctdb/server/ctdb_ltdb_server.c8
-rw-r--r--ctdb/server/ctdb_recoverd.c46
3 files changed, 58 insertions, 0 deletions
diff --git a/ctdb/include/ctdb_protocol.h b/ctdb/include/ctdb_protocol.h
index f2d68f4c3a3..629c91c0cd3 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 19c6a82b9c8..6ff92c54e31 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 ac692ec5419..77586353c7e 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;