The branch, 2.5 has been updated via a89f6a073d0d780ac8336c202b7b8f7179aa8d35 (commit) via 1c3abfc5502cc99a2325152de28a1592a58675af (commit) via 5dc5faaff37973e1cec1eaa92ff7ac8de1530ade (commit) via 7a8cfaa3409495cd01ed7e91d92fd6c90d0fe5aa (commit) from ae3deb87ab5fefdc33437fa4eca2f7468c581957 (commit)
http://gitweb.samba.org/?p=ctdb.git;a=shortlog;h=2.5 - Log ----------------------------------------------------------------- commit a89f6a073d0d780ac8336c202b7b8f7179aa8d35 Author: Martin Schwenke <mar...@meltin.net> Date: Fri May 23 21:58:55 2014 +1000 tools-ctdb: Make natgwlist and lvsmaster more resilient Recent changes have caused these commands to attempt to get capabilities from all nodes before doing further filtering. This means that capabilities are unnecessarily fetched from nodes that are unlikely to be the master. If such a node does not answer the control then many nodes can fail to calculate the master node. In the case of natgwlist this will cause "monitor" events to fail resulting in unhealthy nodes. Restore the behaviour where capabilities are only fetched for a node that will be the master if it has the desired flags. Although this masks a problem where a connected node is not replying, it can help to avoid an outage in some cases. Add supporting tests and infrastructure. Infrastructure just lets a timeout be faked - just for ctdb_ctrl_getcapabilities_stub() so far. First test checks that this infrastructure works if the first node times out in natgwlist. Second test checks the case worked around by the above fix - that is, no failure when a node with PNN beyond the NATGW master can time out. Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> Autobuild-User(master): Amitay Isaacs <ami...@samba.org> Autobuild-Date(master): Thu May 29 05:59:37 CEST 2014 on sn-devel-104 (Imported from commit 4dd382296d3e78000713ab0ac1f8e531e25857cc) commit 1c3abfc5502cc99a2325152de28a1592a58675af Author: Amitay Isaacs <ami...@gmail.com> Date: Wed May 28 10:40:29 2014 +1000 ib: Make infiniband transport compile again Update included header files and fix compilation warnings. ib/ibwrapper.c: In function âibw_stopâ: ib/ibwrapper.c:1015:17: warning: comparison between âenum ibw_state_ctxâ and âenum ibw_state_connâ [-Wenum-compare] if (ctx->state==IBWC_ERROR || ctx->state==IBWC_CONNECTED) { ^ ib/ibwrapper.c:1015:43: warning: comparison between âenum ibw_state_ctxâ and âenum ibw_state_connâ [-Wenum-compare] if (ctx->state==IBWC_ERROR || ctx->state==IBWC_CONNECTED) { The current logic just seems wrong. The context of this line and the error checking in ibw_disconnect() suggest that these comparisons should use p->state rather than ctx->state, so do that. Signed-off-by: Amitay Isaacs <ami...@gmail.com> Reviewed-by: Martin Schwenke <mar...@meltin.net> (Imported from commit f2ef23cd5f227d2da2f032a2a56fbdd4d105b137) commit 5dc5faaff37973e1cec1eaa92ff7ac8de1530ade Author: Amitay Isaacs <ami...@gmail.com> Date: Wed May 28 08:09:02 2014 +1000 pmda: Do not hardcode include paths Signed-off-by: Amitay Isaacs <ami...@gmail.com> Reviewed-by: Martin Schwenke <mar...@meltin.net> (Imported from commit a27e59e8ecb622de826323c048107ab75acd0928) commit 7a8cfaa3409495cd01ed7e91d92fd6c90d0fe5aa Author: Martin Schwenke <mar...@meltin.net> Date: Tue May 6 11:08:57 2014 +1000 tools-ctdb: scriptstatus should not count disabled scripts script_status->num_scripts is used as the count in this message: "%d scripts were executed last %s cycle\n" However, script_status->num_scripts includes disabled scripts, which are never actually executed. Instead, count the number of scripts that aren't disabled and make the message print that. Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> Autobuild-User(master): Amitay Isaacs <ami...@samba.org> Autobuild-Date(master): Wed May 28 02:27:48 CEST 2014 on sn-devel-104 (Imported from commit c1deb87fb78b84a551ad8dc1004247d8a836f9bc) ----------------------------------------------------------------------- Summary of changes: Makefile.in | 12 ++- ib/config.m4 | 2 +- ib/ibw_ctdb_init.c | 3 +- ib/ibwrapper.c | 3 +- ib/ibwrapper_test.c | 2 +- tests/src/ctdb_test_stubs.c | 23 +++++ tests/tool/stubby.natgwlist.009.sh | 36 ++++++++ ...by.natgwlist.001.sh => stubby.natgwlist.010.sh} | 14 ++-- tools/ctdb.c | 88 ++++++++++++-------- utils/pmda/pmda_ctdb.c | 8 +- 10 files changed, 136 insertions(+), 55 deletions(-) create mode 100755 tests/tool/stubby.natgwlist.009.sh copy tests/tool/{stubby.natgwlist.001.sh => stubby.natgwlist.010.sh} (81%) Changeset truncated at 500 lines: diff --git a/Makefile.in b/Makefile.in index ba90ae6..84c6940 100755 --- a/Makefile.in +++ b/Makefile.in @@ -91,6 +91,8 @@ CTDB_COMMON_OBJ = common/ctdb_io.o common/ctdb_util.o \ CTDB_TCP_OBJ = tcp/tcp_connect.o tcp/tcp_io.o tcp/tcp_init.o +CTDB_IB_OBJ = @INFINIBAND_WRAPPER_OBJ@ + CTDB_EXTERNAL_OBJ = $(POPT_OBJ) $(TALLOC_OBJ) $(TDB_OBJ) \ $(REPLACE_OBJ) $(EXTRA_OBJ) $(TEVENT_OBJ) $(SOCKET_WRAPPER_OBJ) @@ -106,7 +108,7 @@ CTDB_SERVER_OBJ = server/ctdbd.o server/ctdb_daemon.o \ server/ctdb_keepalive.o server/ctdb_logging.o server/ctdb_uptime.o \ server/ctdb_vacuum.o server/ctdb_banning.o server/ctdb_statistics.o \ server/ctdb_update_record.o server/ctdb_lock.o \ - $(CTDB_CLIENT_OBJ) $(CTDB_TCP_OBJ) @INFINIBAND_WRAPPER_OBJ@ + $(CTDB_CLIENT_OBJ) $(CTDB_TCP_OBJ) $(CTDB_IB_OBJ) TEST_BINS=tests/bin/ctdb_bench tests/bin/ctdb_fetch tests/bin/ctdb_fetch_one \ tests/bin/ctdb_fetch_readonly_once tests/bin/ctdb_fetch_readonly_loop \ @@ -278,9 +280,9 @@ CTDB_TEST_OBJ = $(TALLOC_OBJ) $(TDB_OBJ) \ tests/src/ctdb_takeover_tests.o: tests/src/ctdb_takeover_tests.c $(CTDBD_TEST_C) -tests/bin/ctdb_takeover_tests: $(CTDB_TEST_OBJ) tests/src/ctdb_takeover_tests.o +tests/bin/ctdb_takeover_tests: $(CTDB_TEST_OBJ) tests/src/ctdb_takeover_tests.o $(CTDB_IB_OBJ) @echo Linking $@ - $(WRAPPER) $(CC) $(CFLAGS) -o $@ tests/src/ctdb_takeover_tests.o $(CTDB_TEST_OBJ) $(LIB_FLAGS) + $(WRAPPER) $(CC) $(CFLAGS) -o $@ tests/src/ctdb_takeover_tests.o $(CTDB_IB_OBJ) $(CTDB_TEST_OBJ) $(LIB_FLAGS) tests/src/ctdb_functest.o: tests/src/ctdb_functest.c tests/src/ctdb_test.c $(CTDB_TEST_C) @@ -298,9 +300,9 @@ tests/bin/ctdb_lock_tdb: tests/src/ctdb_lock_tdb.o $(CTDB_CLIENT_OBJ) @echo Linking $@ $(WRAPPER) $(CC) $(CFLAGS) -o $@ $^ $(LIB_FLAGS) -tests/bin/ibwrapper_test: $(CTDB_CLIENT_OBJ) ib/ibwrapper_test.o +tests/bin/ibwrapper_test: $(CTDB_CLIENT_OBJ) ib/ibwrapper_test.o $(CTDB_IB_OBJ) @echo Linking $@ - $(WRAPPER) $(CC) $(CFLAGS) -o $@ ib/ibwrapper_test.o $(CTDB_CLIENT_OBJ) $(LIB_FLAGS) + $(WRAPPER) $(CC) $(CFLAGS) -o $@ ib/ibwrapper_test.o $(CTDB_CLIENT_OBJ) $(CTDB_IB_OBJ) $(LIB_FLAGS) manpages: $(MAKE) -C doc diff --git a/ib/config.m4 b/ib/config.m4 index 47d6fac..6c626bd 100644 --- a/ib/config.m4 +++ b/ib/config.m4 @@ -1,4 +1,4 @@ -AC_ARG_ENABLE(--enable-infiniband, +AC_ARG_ENABLE(infiniband, [ --enable-infiniband Turn on infiniband support (default=no)]) HAVE_INFINIBAND=no diff --git a/ib/ibw_ctdb_init.c b/ib/ibw_ctdb_init.c index 066814d..63deff2 100644 --- a/ib/ibw_ctdb_init.c +++ b/ib/ibw_ctdb_init.c @@ -26,6 +26,7 @@ #include "ctdb_private.h" #include "ibwrapper.h" #include "ibw_ctdb.h" +#include "lib/util/dlinklist.h" static int ctdb_ibw_listen(struct ctdb_context *ctdb, int backlog) { @@ -99,7 +100,7 @@ static int ctdb_ibw_initialise(struct ctdb_context *ctdb) */ static int ctdb_ibw_start(struct ctdb_context *ctdb) { - int i, ret; + int i; /* everything async here */ for (i=0;i<ctdb->num_nodes;i++) { diff --git a/ib/ibwrapper.c b/ib/ibwrapper.c index f6e7168..3daab3e 100644 --- a/ib/ibwrapper.c +++ b/ib/ibwrapper.c @@ -34,7 +34,6 @@ #include <unistd.h> #include "includes.h" -#include "lib/events/events.h" #include "ibwrapper.h" #include <infiniband/kern-abi.h> @@ -1013,7 +1012,7 @@ int ibw_stop(struct ibw_ctx *ctx) DEBUG(DEBUG_DEBUG, ("ibw_stop\n")); for(p=ctx->conn_list; p!=NULL; p=p->next) { - if (ctx->state==IBWC_ERROR || ctx->state==IBWC_CONNECTED) { + if (p->state==IBWC_ERROR || p->state==IBWC_CONNECTED) { if (ibw_disconnect(p)) return -1; } diff --git a/ib/ibwrapper_test.c b/ib/ibwrapper_test.c index ba54286..48162c3 100644 --- a/ib/ibwrapper_test.c +++ b/ib/ibwrapper_test.c @@ -325,7 +325,7 @@ int ibwtest_receive_handler(struct ibw_conn *conn, void *buf, int n) n - sizeof(uint32_t) - 2); DEBUG(DEBUG_DEBUG, ("[%d]msg varsize %u/sum %u from %s\n", op, - n - sizeof(uint32_t) - 2, + (uint32_t)(n - sizeof(uint32_t) - 2), (uint32_t)sum, tconn->id ? tconn->id : "NULL")); if (sum!=((unsigned char *)buf)[n-1]) { diff --git a/tests/src/ctdb_test_stubs.c b/tests/src/ctdb_test_stubs.c index 6149b3d..d36fe81 100644 --- a/tests/src/ctdb_test_stubs.c +++ b/tests/src/ctdb_test_stubs.c @@ -30,6 +30,10 @@ static struct ctdb_context *ctdb_global; * -CTDB_CAP_RECMASTER. LVS can be faked on by adding * CTDB_CAP_LVS. */ + +/* A fake flag that is only supported by some functions */ +#define NODE_FLAGS_FAKE_TIMEOUT 0x80000000 + void ctdb_test_stubs_read_nodemap(struct ctdb_context *ctdb) { char line[1024]; @@ -95,6 +99,12 @@ void ctdb_test_stubs_read_nodemap(struct ctdb_context *ctdb) capabilities &= ~CTDB_CAP_NATGW; } else if (strcmp(tok, "CTDB_CAP_LVS") == 0) { capabilities |= CTDB_CAP_LVS; + } else if (strcmp(tok, "TIMEOUT") == 0) { + /* This can be done with just a flag + * value but it is probably clearer + * and less error-prone to fake this + * with an explicit token */ + flags |= NODE_FLAGS_FAKE_TIMEOUT; } tok = strtok(NULL, " \t"); } @@ -550,6 +560,19 @@ int ctdb_ctrl_getcapabilities_stub(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t *capabilities) { + + if (ctdb->nodes[destnode]->flags & NODE_FLAGS_FAKE_TIMEOUT) { + /* Placeholder for line#, instead of __location__ */ + DEBUG(DEBUG_ERR, + ("__LOCATION__ control timed out." + " reqid:1234567890 opcode:80 dstnode:%d\n", destnode)); + DEBUG(DEBUG_ERR, + ("__LOCATION__ ctdb_control_recv failed\n")); + DEBUG(DEBUG_ERR, + ("__LOCATION__ ctdb_ctrl_getcapabilities_recv failed\n")); + return -1; + } + if (ctdb->nodes[destnode]->flags & NODE_FLAGS_DISCONNECTED) { DEBUG(DEBUG_ERR, ("ctdb_control error: 'ctdb_control to disconnected node\n")); diff --git a/tests/tool/stubby.natgwlist.009.sh b/tests/tool/stubby.natgwlist.009.sh new file mode 100755 index 0000000..7534fd2 --- /dev/null +++ b/tests/tool/stubby.natgwlist.009.sh @@ -0,0 +1,36 @@ +#!/bin/sh + +. "${TEST_SCRIPTS_DIR}/unit.sh" + +define_test "3 nodes, all in natgw group, 1 actual time-out" + +setup_natgw <<EOF +192.168.20.41 +192.168.20.42 +192.168.20.43 +EOF + +required_result 255 <<EOF +DATE TIME [PID]: __LOCATION__ control timed out. reqid:1234567890 opcode:80 dstnode:0 +DATE TIME [PID]: __LOCATION__ ctdb_control_recv failed +DATE TIME [PID]: __LOCATION__ ctdb_ctrl_getcapabilities_recv failed +DATE TIME [PID]: Unable to get capabilities from node 0 +EOF + +simple_test <<EOF +NODEMAP +0 192.168.20.41 0x0 TIMEOUT +1 192.168.20.42 0x0 CURRENT RECMASTER +2 192.168.20.43 0x0 + +VNNMAP +654321 +0 +1 +2 + +IFACES +:Name:LinkStatus:References: +:eth2:1:2: +:eth1:1:4: +EOF diff --git a/tests/tool/stubby.natgwlist.001.sh b/tests/tool/stubby.natgwlist.010.sh similarity index 81% copy from tests/tool/stubby.natgwlist.001.sh copy to tests/tool/stubby.natgwlist.010.sh index f1d2d37..aaa3161 100755 --- a/tests/tool/stubby.natgwlist.001.sh +++ b/tests/tool/stubby.natgwlist.010.sh @@ -2,7 +2,7 @@ . "${TEST_SCRIPTS_DIR}/unit.sh" -define_test "3 nodes, all in natgw group, all ok" +define_test "3 nodes, all in natgw group, 1 potential time-out" setup_natgw <<EOF 192.168.20.41 @@ -22,16 +22,16 @@ simple_test <<EOF NODEMAP 0 192.168.20.41 0x0 CURRENT RECMASTER 1 192.168.20.42 0x0 -2 192.168.20.43 0x0 - -IFACES -:Name:LinkStatus:References: -:eth2:1:2: -:eth1:1:4: +2 192.168.20.43 0x0 TIMEOUT VNNMAP 654321 0 1 2 + +IFACES +:Name:LinkStatus:References: +:eth2:1:2: +:eth1:1:4: EOF diff --git a/tools/ctdb.c b/tools/ctdb.c index d8265d7..dc505c9 100644 --- a/tools/ctdb.c +++ b/tools/ctdb.c @@ -1179,7 +1179,8 @@ filter_nodemap_by_addrs(struct ctdb_context *ctdb, static struct ctdb_node_map * filter_nodemap_by_capabilities(struct ctdb_context *ctdb, struct ctdb_node_map *nodemap, - uint32_t required_capabilities) + uint32_t required_capabilities, + bool first_only) { int i; uint32_t capabilities; @@ -1213,6 +1214,9 @@ filter_nodemap_by_capabilities(struct ctdb_context *ctdb, ret->nodes[ret->num] = nodemap->nodes[i]; ret->num++; + if (first_only) { + break; + } } return ret; @@ -1252,7 +1256,7 @@ static int control_natgwlist(struct ctdb_context *ctdb, int argc, const char **a int i, ret; struct pnn_node *natgw_nodes = NULL; struct ctdb_node_map *orig_nodemap=NULL; - struct ctdb_node_map *cnodemap, *nodemap; + struct ctdb_node_map *nodemap; uint32_t mypnn, pnn; const char *ip; @@ -1293,21 +1297,15 @@ static int control_natgwlist(struct ctdb_context *ctdb, int argc, const char **a goto done; } - /* Get a nodemap that includes only the nodes with the NATGW - * capability */ - cnodemap = filter_nodemap_by_capabilities(ctdb, nodemap, - CTDB_CAP_NATGW); - if (cnodemap == NULL) { - ret = -1; - goto done; - } - ret = 2; /* matches ENOENT */ pnn = -1; ip = "0.0.0.0"; + /* For each flag mask... */ for (i = 0; exclude_flags[i] != 0; i++) { + /* ... get a nodemap that excludes nodes with with + * masked flags... */ struct ctdb_node_map *t = - filter_nodemap_by_flags(ctdb, cnodemap, + filter_nodemap_by_flags(ctdb, nodemap, exclude_flags[i]); if (t == NULL) { /* No memory */ @@ -1315,10 +1313,23 @@ static int control_natgwlist(struct ctdb_context *ctdb, int argc, const char **a goto done; } if (t->num > 0) { - ret = 0; - pnn = t->nodes[0].pnn; - ip = ctdb_addr_to_str(&t->nodes[0].addr); - break; + /* ... and find the first node with the NATGW + * capability */ + struct ctdb_node_map *n; + n = filter_nodemap_by_capabilities(ctdb, t, + CTDB_CAP_NATGW, + true); + if (n == NULL) { + /* No memory */ + ret = -1; + goto done; + } + if (n->num > 0) { + ret = 0; + pnn = n->nodes[0].pnn; + ip = ctdb_addr_to_str(&n->nodes[0].addr); + break; + } } talloc_free(t); } @@ -1377,8 +1388,14 @@ static int control_one_scriptstatus(struct ctdb_context *ctdb, } if (!options.machinereadable) { + int num_run = 0; + for (i=0; i<script_status->num_scripts; i++) { + if (script_status->scripts[i].status != -ENOEXEC) { + num_run++; + } + } printf("%d scripts were executed last %s cycle\n", - script_status->num_scripts, + num_run, ctdb_eventscript_call_names[type]); } for (i=0; i<script_status->num_scripts; i++) { @@ -3563,7 +3580,7 @@ static int control_lvs(struct ctdb_context *ctdb, int argc, const char **argv) } nodemap = filter_nodemap_by_capabilities(ctdb, orig_nodemap, - CTDB_CAP_LVS); + CTDB_CAP_LVS, false); if (nodemap == NULL) { /* No memory */ ret = -1; @@ -3603,26 +3620,17 @@ done: static int control_lvsmaster(struct ctdb_context *ctdb, int argc, const char **argv) { TALLOC_CTX *tmp_ctx = talloc_new(ctdb); - struct ctdb_node_map *orig_nodemap=NULL; - struct ctdb_node_map *nodemap; + struct ctdb_node_map *nodemap=NULL; int i, ret; ret = ctdb_ctrl_getnodemap(ctdb, TIMELIMIT(), options.pnn, - tmp_ctx, &orig_nodemap); + tmp_ctx, &nodemap); if (ret != 0) { DEBUG(DEBUG_ERR, ("Unable to get nodemap from node %u\n", options.pnn)); talloc_free(tmp_ctx); return -1; } - nodemap = filter_nodemap_by_capabilities(ctdb, orig_nodemap, - CTDB_CAP_LVS); - if (nodemap == NULL) { - /* No memory */ - ret = -1; - goto done; - } - for (i = 0; lvs_exclude_flags[i] != 0; i++) { struct ctdb_node_map *t = filter_nodemap_by_flags(ctdb, nodemap, @@ -3633,11 +3641,23 @@ static int control_lvsmaster(struct ctdb_context *ctdb, int argc, const char **a goto done; } if (t->num > 0) { - ret = 0; - printf(options.machinereadable ? - "%d\n" : "Node %d is LVS master\n", - t->nodes[0].pnn); - goto done; + struct ctdb_node_map *n; + n = filter_nodemap_by_capabilities(ctdb, + t, + CTDB_CAP_LVS, + true); + if (n == NULL) { + /* No memory */ + ret = -1; + goto done; + } + if (n->num > 0) { + ret = 0; + printf(options.machinereadable ? + "%d\n" : "Node %d is LVS master\n", + n->nodes[0].pnn); + goto done; + } } talloc_free(t); } diff --git a/utils/pmda/pmda_ctdb.c b/utils/pmda/pmda_ctdb.c index 6e034ba..a686389 100644 --- a/utils/pmda/pmda_ctdb.c +++ b/utils/pmda/pmda_ctdb.c @@ -22,10 +22,10 @@ #include <pcp/pmapi.h> #include <pcp/impl.h> #include <pcp/pmda.h> -#include "../../include/includes.h" -#include "../../include/ctdb.h" -#include "../../include/ctdb_private.h" -#include "../../include/ctdb_protocol.h" +#include "includes.h" +#include "ctdb.h" +#include "ctdb_private.h" +#include "ctdb_protocol.h" #include "domain.h" /* -- CTDB repository