From eef45194bdb1542b07d2c219c8b6be2a0b308902 Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Mon, 19 Aug 2019 21:47:03 +1000 Subject: [PATCH 1/4] ctdb-daemon: Factor out new function ctdb_node_become_inactive() This is a superset of ctdb_local_node_got_banned() so will replace that function, and will also be used in the NODE_STOP control. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14087 Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs (cherry picked from commit a42bcaabb63722411bee52b80cbfc795593defbc) --- ctdb/include/ctdb_private.h | 2 ++ ctdb/server/ctdb_recover.c | 43 +++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/ctdb/include/ctdb_private.h b/ctdb/include/ctdb_private.h index 1e9619faddf..d9d13fad358 100644 --- a/ctdb/include/ctdb_private.h +++ b/ctdb/include/ctdb_private.h @@ -819,6 +819,8 @@ int32_t ctdb_control_recd_ping(struct ctdb_context *ctdb); int32_t ctdb_control_set_recmaster(struct ctdb_context *ctdb, uint32_t opcode, TDB_DATA indata); +void ctdb_node_become_inactive(struct ctdb_context *ctdb); + int32_t ctdb_control_stop_node(struct ctdb_context *ctdb); int32_t ctdb_control_continue_node(struct ctdb_context *ctdb); diff --git a/ctdb/server/ctdb_recover.c b/ctdb/server/ctdb_recover.c index 343728839c1..df60a4cb9c0 100644 --- a/ctdb/server/ctdb_recover.c +++ b/ctdb/server/ctdb_recover.c @@ -1420,6 +1420,49 @@ int32_t ctdb_control_set_recmaster(struct ctdb_context *ctdb, uint32_t opcode, T return 0; } +void ctdb_node_become_inactive(struct ctdb_context *ctdb) +{ + struct ctdb_db_context *ctdb_db; + + D_WARNING("Making node INACTIVE\n"); + + /* + * Do not service database calls - reset generation to invalid + * so this node ignores any REQ/REPLY CALL/DMASTER + */ + ctdb->vnn_map->generation = INVALID_GENERATION; + for (ctdb_db = ctdb->db_list; ctdb_db != NULL; ctdb_db = ctdb_db->next) { + ctdb_db->generation = INVALID_GENERATION; + } + + /* + * Although this bypasses the control, the only thing missing + * is the deferred drop of all public IPs, which isn't + * necessary because they are dropped below + */ + if (ctdb->recovery_mode != CTDB_RECOVERY_ACTIVE) { + D_NOTICE("Recovery mode set to ACTIVE\n"); + ctdb->recovery_mode = CTDB_RECOVERY_ACTIVE; + } + + /* + * Initiate database freeze - this will be scheduled for + * immediate execution and will be in progress long before the + * calling control returns + */ + ctdb_daemon_send_control(ctdb, + ctdb->pnn, + 0, + CTDB_CONTROL_FREEZE, + 0, + CTDB_CTRL_FLAG_NOREPLY, + tdb_null, + NULL, + NULL); + + D_NOTICE("Dropping all public IP addresses\n"); + ctdb_release_all_ips(ctdb); +} int32_t ctdb_control_stop_node(struct ctdb_context *ctdb) { -- 2.23.0.rc1 From 0c0390d8d142ffb2d032297a313e8fc0f6c945f0 Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Mon, 19 Aug 2019 21:52:57 +1000 Subject: [PATCH 2/4] ctdb-daemon: Switch banning code to use ctdb_node_become_inactive() There's no reason to avoid immediately setting recovery mode to active and initiating freeze of databases. This effectively reverts the following commits: d8f3b490bbb691c9916eed0df5b980c1aef23c85 b4357a79d916b1f8ade8fa78563fbef0ce670aa9 The latter is now implemented using a control, resulting in looser coupling. See also the following commit: f8141e91a693912ea1107a49320e83702a80757a BUG: https://bugzilla.samba.org/show_bug.cgi?id=14087 Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs (cherry picked from commit 0f5f7b7cf4e970f3f36c5e0b3d09e710fe90801a) --- ctdb/server/ctdb_banning.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ctdb/server/ctdb_banning.c b/ctdb/server/ctdb_banning.c index 9cd163645a1..11794dc5b0b 100644 --- a/ctdb/server/ctdb_banning.c +++ b/ctdb/server/ctdb_banning.c @@ -129,7 +129,7 @@ int32_t ctdb_control_set_ban_state(struct ctdb_context *ctdb, TDB_DATA indata) ctdb_ban_node_event, ctdb); if (!already_banned) { - ctdb_local_node_got_banned(ctdb); + ctdb_node_become_inactive(ctdb); } return 0; } -- 2.23.0.rc1 From 2e35cfbead9a0498b60d5552566b2d888a015931 Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Tue, 20 Aug 2019 11:29:42 +1000 Subject: [PATCH 3/4] ctdb-daemon: Drop unused function ctdb_local_node_got_banned() BUG: https://bugzilla.samba.org/show_bug.cgi?id=14087 Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs (cherry picked from commit 91ac4c13d8472955d1f04bd775ec4b3ff8bf1b61) --- ctdb/include/ctdb_private.h | 1 - ctdb/server/ctdb_banning.c | 24 ------------------------ 2 files changed, 25 deletions(-) diff --git a/ctdb/include/ctdb_private.h b/ctdb/include/ctdb_private.h index d9d13fad358..1f168dae2b8 100644 --- a/ctdb/include/ctdb_private.h +++ b/ctdb/include/ctdb_private.h @@ -481,7 +481,6 @@ int ctdb_ibw_init(struct ctdb_context *ctdb); /* from ctdb_banning.c */ -void ctdb_local_node_got_banned(struct ctdb_context *ctdb); int32_t ctdb_control_set_ban_state(struct ctdb_context *ctdb, TDB_DATA indata); int32_t ctdb_control_get_ban_state(struct ctdb_context *ctdb, TDB_DATA *outdata); void ctdb_ban_self(struct ctdb_context *ctdb); diff --git a/ctdb/server/ctdb_banning.c b/ctdb/server/ctdb_banning.c index 11794dc5b0b..3c711575e8c 100644 --- a/ctdb/server/ctdb_banning.c +++ b/ctdb/server/ctdb_banning.c @@ -57,30 +57,6 @@ static void ctdb_ban_node_event(struct tevent_context *ev, } } -void ctdb_local_node_got_banned(struct ctdb_context *ctdb) -{ - struct ctdb_db_context *ctdb_db; - - DEBUG(DEBUG_NOTICE, ("This node has been banned - releasing all public " - "IPs and setting the generation to INVALID.\n")); - - /* Reset the generation id to 1 to make us ignore any - REQ/REPLY CALL/DMASTER someone sends to us. - We are now banned so we shouldnt service database calls - anymore. - */ - ctdb->vnn_map->generation = INVALID_GENERATION; - for (ctdb_db = ctdb->db_list; ctdb_db != NULL; ctdb_db = ctdb_db->next) { - ctdb_db->generation = INVALID_GENERATION; - } - - /* Recovery daemon will set the recovery mode ACTIVE and freeze - * databases. - */ - - ctdb_release_all_ips(ctdb); -} - int32_t ctdb_control_set_ban_state(struct ctdb_context *ctdb, TDB_DATA indata) { struct ctdb_ban_state *bantime = (struct ctdb_ban_state *)indata.dptr; -- 2.23.0.rc1 From 950449761dad4eb4f5ab30129098b4b4987a3c93 Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Mon, 19 Aug 2019 21:48:04 +1000 Subject: [PATCH 4/4] ctdb-daemon: Make node inactive in the NODE_STOP control Currently some of this is supported by a periodic check in the recovery daemon's main_loop(), which notices the flag change, sets recovery mode active and freezes databases. If STOP_NODE returns immediately then the associated recovery can complete and the node can be continued before databases are actually frozen. Instead, immediately do all of the things that make a node inactive. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14087 RN: Stop "ctdb stop" from completing before freezing databases Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs Autobuild-User(master): Amitay Isaacs Autobuild-Date(master): Tue Aug 20 08:32:27 UTC 2019 on sn-devel-184 (cherry picked from commit e9f2e205ee89f4f3d6302cc11b4d0eb2efaf0f53) --- ctdb/server/ctdb_recover.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ctdb/server/ctdb_recover.c b/ctdb/server/ctdb_recover.c index df60a4cb9c0..1654c6d3978 100644 --- a/ctdb/server/ctdb_recover.c +++ b/ctdb/server/ctdb_recover.c @@ -1469,6 +1469,8 @@ int32_t ctdb_control_stop_node(struct ctdb_context *ctdb) DEBUG(DEBUG_ERR, ("Stopping node\n")); ctdb->nodes[ctdb->pnn]->flags |= NODE_FLAGS_STOPPED; + ctdb_node_become_inactive(ctdb); + return 0; } -- 2.23.0.rc1