ctdb-daemon: Add implementation for CTDB_CONTROL_DB_ATTACH_REPLICATED control
authorAmitay Isaacs <amitay@gmail.com>
Thu, 2 Mar 2017 05:38:58 +0000 (16:38 +1100)
committerMartin Schwenke <martins@samba.org>
Thu, 29 Jun 2017 08:34:27 +0000 (10:34 +0200)
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
ctdb/server/ctdb_control.c
ctdb/server/ctdb_ltdb_server.c
ctdb/server/ctdb_recovery_helper.c

index 8deb7c8..4048443 100644 (file)
@@ -275,6 +275,11 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb,
                                        CTDB_DB_FLAGS_PERSISTENT, client_id,
                                        c, async_reply);
 
+       case CTDB_CONTROL_DB_ATTACH_REPLICATED:
+         return ctdb_control_db_attach(ctdb, indata, outdata,
+                                       CTDB_DB_FLAGS_REPLICATED, client_id,
+                                       c, async_reply);
+
        case CTDB_CONTROL_SET_CALL:
                return control_not_implemented("SET_CALL", NULL);
 
index ffa5269..d837838 100644 (file)
@@ -1115,6 +1115,7 @@ int32_t ctdb_control_db_attach(struct ctdb_context *ctdb, TDB_DATA indata,
        struct ctdb_db_context *db;
        struct ctdb_node *node = ctdb->nodes[ctdb->pnn];
        struct ctdb_client *client = NULL;
+       uint32_t opcode;
 
        if (ctdb->tunable.allow_client_db_attach == 0) {
                DEBUG(DEBUG_ERR, ("DB Attach to database %s denied by tunable "
@@ -1196,11 +1197,16 @@ int32_t ctdb_control_db_attach(struct ctdb_context *ctdb, TDB_DATA indata,
        /* Try to ensure it's locked in mem */
        lockdown_memory(ctdb->valgrinding);
 
+       if (ctdb_db_persistent(db)) {
+               opcode = CTDB_CONTROL_DB_ATTACH_PERSISTENT;
+       } else if (ctdb_db_replicated(db)) {
+               opcode = CTDB_CONTROL_DB_ATTACH_REPLICATED;
+       } else {
+               opcode = CTDB_CONTROL_DB_ATTACH;
+       }
+
        /* tell all the other nodes about this database */
-       ctdb_daemon_send_control(ctdb, CTDB_BROADCAST_ALL, 0,
-                                ctdb_db_persistent(db) ?
-                                       CTDB_CONTROL_DB_ATTACH_PERSISTENT :
-                                       CTDB_CONTROL_DB_ATTACH,
+       ctdb_daemon_send_control(ctdb, CTDB_BROADCAST_ALL, 0, opcode,
                                 0, CTDB_CTRL_FLAG_NOREPLY,
                                 indata, NULL, NULL);
 
index 943222a..9f7fc07 100644 (file)
@@ -1664,7 +1664,8 @@ static void recover_db_transaction_started(struct tevent_req *subreq)
                return;
        }
 
-       if (state->db_flags & CTDB_DB_FLAGS_PERSISTENT) {
+       if ((state->db_flags & CTDB_DB_FLAGS_PERSISTENT) ||
+           (state->db_flags & CTDB_DB_FLAGS_REPLICATED)) {
                subreq = collect_highseqnum_db_send(
                                state, state->ev, state->client,
                                state->pnn_list, state->count, state->caps,
@@ -1693,7 +1694,8 @@ static void recover_db_collect_done(struct tevent_req *subreq)
        int ret;
        bool status;
 
-       if (state->db_flags & CTDB_DB_FLAGS_PERSISTENT) {
+       if ((state->db_flags & CTDB_DB_FLAGS_PERSISTENT) ||
+           (state->db_flags & CTDB_DB_FLAGS_REPLICATED)) {
                status = collect_highseqnum_db_recv(subreq, &ret);
        } else {
                status = collect_all_db_recv(subreq, &ret);