diff --git a/ctdb/common/ctdb.c b/ctdb/common/ctdb.c index 5242e75b797..8fafc45369b 100644 --- a/ctdb/common/ctdb.c +++ b/ctdb/common/ctdb.c @@ -86,14 +86,6 @@ void ctdb_clear_flags(struct ctdb_context *ctdb, unsigned flags) ctdb->flags &= ~flags; } -/* - set max acess count before a dmaster migration -*/ -void ctdb_set_max_lacount(struct ctdb_context *ctdb, unsigned count) -{ - ctdb->max_lacount = count; -} - /* set the directory for the local databases */ @@ -528,11 +520,18 @@ struct ctdb_context *ctdb_init(struct event_context *ev) ctdb->recovery_master = (uint32_t)-1; ctdb->upcalls = &ctdb_upcalls; ctdb->idr = idr_init(ctdb); - ctdb->max_lacount = CTDB_DEFAULT_MAX_LACOUNT; - ctdb->seqnum_frequency = CTDB_DEFAULT_SEQNUM_FREQUENCY; ctdb->recovery_lock_fd = -1; ctdb->monitoring_mode = CTDB_MONITORING_ACTIVE; + /* set default values for tunables */ + ctdb->tunable.max_redirect_count = 3; + ctdb->tunable.seqnum_frequency = 1; + ctdb->tunable.control_timeout = 60; + ctdb->tunable.traverse_timeout = 20; + ctdb->tunable.monitoring_timeout = 2; + ctdb->tunable.monitoring_limit = 3; + ctdb->tunable.max_lacount = 7; + return ctdb; } diff --git a/ctdb/common/ctdb_call.c b/ctdb/common/ctdb_call.c index 9b71514991c..1604b0a91c7 100644 --- a/ctdb/common/ctdb_call.c +++ b/ctdb/common/ctdb_call.c @@ -180,7 +180,7 @@ static void ctdb_call_send_redirect(struct ctdb_context *ctdb, uint32_t lmaster = ctdb_lmaster(ctdb, &key); if (ctdb->vnn == lmaster) { c->hdr.destnode = header->dmaster; - } else if ((c->hopcount % CTDB_MAX_REDIRECT_COUNT) == 0) { + } else if ((c->hopcount % ctdb->tunable.max_redirect_count) == 0) { c->hdr.destnode = lmaster; } else { c->hdr.destnode = header->dmaster; @@ -476,8 +476,8 @@ void ctdb_request_call(struct ctdb_context *ctdb, struct ctdb_req_header *hdr) */ if ( c->hdr.srcnode != ctdb->vnn && ((header.laccessor == c->hdr.srcnode - && header.lacount >= ctdb->max_lacount) - || (c->flags&CTDB_IMMEDIATE_MIGRATION)) ) { + && header.lacount >= ctdb->tunable.max_lacount) + || (c->flags & CTDB_IMMEDIATE_MIGRATION)) ) { DEBUG(2,("vnn %u starting migration of %08x to %u\n", ctdb->vnn, ctdb_hash(&call.key), c->hdr.srcnode)); ctdb_call_send_dmaster(ctdb_db, c, &header, &call.key, &data); diff --git a/ctdb/common/ctdb_control.c b/ctdb/common/ctdb_control.c index f73672796e6..7d2af014b12 100644 --- a/ctdb/common/ctdb_control.c +++ b/ctdb/common/ctdb_control.c @@ -142,14 +142,6 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb, case CTDB_CONTROL_GET_VNN: return ctdb->vnn; - case CTDB_CONTROL_CONFIG: { - CHECK_CONTROL_DATA_SIZE(0); - ctdb->statistics.controls.get_config++; - outdata->dptr = (uint8_t *)ctdb; - outdata->dsize = sizeof(*ctdb); - return 0; - } - case CTDB_CONTROL_PING: CHECK_CONTROL_DATA_SIZE(0); ctdb->statistics.controls.ping++; @@ -224,11 +216,6 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb, CHECK_CONTROL_DATA_SIZE(sizeof(uint32_t)); return ctdb_ltdb_update_seqnum(ctdb, *(uint32_t *)indata.dptr, srcnode); - case CTDB_CONTROL_SET_SEQNUM_FREQUENCY: - ctdb->statistics.controls.set_seqnum_frequency++; - CHECK_CONTROL_DATA_SIZE(sizeof(uint32_t)); - return ctdb_ltdb_set_seqnum_frequency(ctdb, *(uint32_t *)indata.dptr); - case CTDB_CONTROL_FREEZE: CHECK_CONTROL_DATA_SIZE(0); return ctdb_control_freeze(ctdb, c, async_reply); @@ -489,10 +476,11 @@ int ctdb_daemon_send_control(struct ctdb_context *ctdb, uint32_t destnode, return 0; } -#if CTDB_CONTROL_TIMEOUT - event_add_timed(ctdb->ev, state, timeval_current_ofs(CTDB_CONTROL_TIMEOUT, 0), - ctdb_control_timeout, state); -#endif + if (ctdb->tunable.control_timeout) { + event_add_timed(ctdb->ev, state, + timeval_current_ofs(ctdb->tunable.control_timeout, 0), + ctdb_control_timeout, state); + } talloc_free(c); return 0; diff --git a/ctdb/common/ctdb_ltdb.c b/ctdb/common/ctdb_ltdb.c index a6f0879c6f0..0898cfca24a 100644 --- a/ctdb/common/ctdb_ltdb.c +++ b/ctdb/common/ctdb_ltdb.c @@ -484,9 +484,10 @@ static void ctdb_ltdb_seqnum_check(struct event_context *ev, struct timed_event ctdb_db->seqnum = new_seqnum; /* setup a new timer */ - ctdb_db->te = event_add_timed(ctdb->ev, ctdb_db, - timeval_current_ofs(ctdb->seqnum_frequency, 0), - ctdb_ltdb_seqnum_check, ctdb_db); + ctdb_db->te = + event_add_timed(ctdb->ev, ctdb_db, + timeval_current_ofs(ctdb->tunable.seqnum_frequency, 0), + ctdb_ltdb_seqnum_check, ctdb_db); } /* @@ -502,9 +503,10 @@ int32_t ctdb_ltdb_enable_seqnum(struct ctdb_context *ctdb, uint32_t db_id) } if (ctdb_db->te == NULL) { - ctdb_db->te = event_add_timed(ctdb->ev, ctdb_db, - timeval_current_ofs(ctdb->seqnum_frequency, 0), - ctdb_ltdb_seqnum_check, ctdb_db); + ctdb_db->te = + event_add_timed(ctdb->ev, ctdb_db, + timeval_current_ofs(ctdb->tunable.seqnum_frequency, 0), + ctdb_ltdb_seqnum_check, ctdb_db); } tdb_enable_seqnum(ctdb_db->ltdb->tdb); @@ -512,11 +514,3 @@ int32_t ctdb_ltdb_enable_seqnum(struct ctdb_context *ctdb, uint32_t db_id) return 0; } -/* - enable seqnum handling on this db - */ -int32_t ctdb_ltdb_set_seqnum_frequency(struct ctdb_context *ctdb, uint32_t frequency) -{ - ctdb->seqnum_frequency = frequency; - return 0; -} diff --git a/ctdb/common/ctdb_monitor.c b/ctdb/common/ctdb_monitor.c index 750a1f5bd63..7a1bee35293 100644 --- a/ctdb/common/ctdb_monitor.c +++ b/ctdb/common/ctdb_monitor.c @@ -36,7 +36,7 @@ static void ctdb_check_for_dead_nodes(struct event_context *ev, struct timed_eve if (ctdb->monitoring_mode==CTDB_MONITORING_DISABLED) { event_add_timed(ctdb->ev, ctdb, - timeval_current_ofs(CTDB_MONITORING_TIMEOUT, 0), + timeval_current_ofs(ctdb->tunable.monitoring_timeout, 0), ctdb_check_for_dead_nodes, ctdb); return; } @@ -65,7 +65,7 @@ static void ctdb_check_for_dead_nodes(struct event_context *ev, struct timed_eve node->rx_cnt = 0; - if (node->dead_count >= CTDB_MONITORING_DEAD_COUNT) { + if (node->dead_count >= ctdb->tunable.monitoring_limit) { DEBUG(0,("dead count reached for node %u\n", node->vnn)); ctdb_node_dead(node); ctdb_send_keepalive(ctdb, node->vnn); @@ -84,7 +84,7 @@ static void ctdb_check_for_dead_nodes(struct event_context *ev, struct timed_eve } event_add_timed(ctdb->ev, ctdb, - timeval_current_ofs(CTDB_MONITORING_TIMEOUT, 0), + timeval_current_ofs(ctdb->tunable.monitoring_timeout, 0), ctdb_check_for_dead_nodes, ctdb); } @@ -94,7 +94,7 @@ static void ctdb_check_for_dead_nodes(struct event_context *ev, struct timed_eve int ctdb_start_monitoring(struct ctdb_context *ctdb) { event_add_timed(ctdb->ev, ctdb, - timeval_current_ofs(CTDB_MONITORING_TIMEOUT, 0), + timeval_current_ofs(ctdb->tunable.monitoring_timeout, 0), ctdb_check_for_dead_nodes, ctdb); return 0; } diff --git a/ctdb/common/ctdb_traverse.c b/ctdb/common/ctdb_traverse.c index e3777489d22..bceff7f0243 100644 --- a/ctdb/common/ctdb_traverse.c +++ b/ctdb/common/ctdb_traverse.c @@ -256,7 +256,8 @@ struct ctdb_traverse_all_handle *ctdb_daemon_traverse_all(struct ctdb_db_context } /* timeout the traverse */ - event_add_timed(ctdb->ev, state, timeval_current_ofs(CTDB_TRAVERSE_TIMEOUT, 0), + event_add_timed(ctdb->ev, state, + timeval_current_ofs(ctdb->tunable.traverse_timeout, 0), ctdb_traverse_all_timeout, state); return state; diff --git a/ctdb/include/ctdb_private.h b/ctdb/include/ctdb_private.h index c6d2259e838..d7f2b32cea5 100644 --- a/ctdb/include/ctdb_private.h +++ b/ctdb/include/ctdb_private.h @@ -38,15 +38,6 @@ #define CTDB_NULL_FUNC 0xFF000001 #define CTDB_FETCH_FUNC 0xFF000002 -#define CTDB_MAX_REDIRECT_COUNT 3 -#define CTDB_DEFAULT_SEQNUM_FREQUENCY 1 -#define CTDB_CONTROL_TIMEOUT 60 -#define CTDB_TRAVERSE_TIMEOUT 20 -#define CTDB_MONITORING_TIMEOUT 2 -#define CTDB_MONITORING_DEAD_COUNT 3 -#define CTDB_DEFAULT_MAX_LACOUNT 7 - - /* all tunable variables go in here */ struct ctdb_tunable { uint32_t max_redirect_count; @@ -284,6 +275,7 @@ struct ctdb_context { struct event_context *ev; uint32_t recovery_mode; uint32_t monitoring_mode; + struct ctdb_tunable tunable; enum ctdb_freeze_mode freeze_mode; struct ctdb_freeze_handle *freeze_handle; struct ctdb_address address; @@ -305,14 +297,12 @@ struct ctdb_context { const struct ctdb_methods *methods; /* transport methods */ const struct ctdb_upcalls *upcalls; /* transport upcalls */ void *private_data; /* private to transport */ - unsigned max_lacount; struct ctdb_db_context *db_list; struct ctdb_message_list *message_list; struct ctdb_daemon_data daemon; struct ctdb_statistics statistics; struct ctdb_vnn_map *vnn_map; uint32_t num_clients; - uint32_t seqnum_frequency; uint32_t recovery_master; struct ctdb_call_state *pending_calls; struct ctdb_takeover takeover; @@ -362,54 +352,54 @@ struct ctdb_ltdb_header { uint32_t lacount; }; -enum ctdb_controls {CTDB_CONTROL_PROCESS_EXISTS, - CTDB_CONTROL_STATISTICS, - CTDB_CONTROL_CONFIG, - CTDB_CONTROL_PING, - CTDB_CONTROL_GETDBPATH, - CTDB_CONTROL_GETVNNMAP, - CTDB_CONTROL_SETVNNMAP, - CTDB_CONTROL_GET_DEBUG, - CTDB_CONTROL_SET_DEBUG, - CTDB_CONTROL_GET_DBMAP, - CTDB_CONTROL_GET_NODEMAP, - CTDB_CONTROL_SET_DMASTER, - CTDB_CONTROL_CLEAR_DB, - CTDB_CONTROL_PULL_DB, - CTDB_CONTROL_PUSH_DB, - CTDB_CONTROL_GET_RECMODE, - CTDB_CONTROL_SET_RECMODE, - CTDB_CONTROL_STATISTICS_RESET, - CTDB_CONTROL_DB_ATTACH, - CTDB_CONTROL_SET_CALL, - CTDB_CONTROL_TRAVERSE_START, - CTDB_CONTROL_TRAVERSE_ALL, - CTDB_CONTROL_TRAVERSE_DATA, - CTDB_CONTROL_REGISTER_SRVID, - CTDB_CONTROL_DEREGISTER_SRVID, - CTDB_CONTROL_GET_DBNAME, - CTDB_CONTROL_ENABLE_SEQNUM, - CTDB_CONTROL_UPDATE_SEQNUM, - CTDB_CONTROL_SET_SEQNUM_FREQUENCY, - CTDB_CONTROL_DUMP_MEMORY, - CTDB_CONTROL_GET_PID, - CTDB_CONTROL_GET_RECMASTER, - CTDB_CONTROL_SET_RECMASTER, - CTDB_CONTROL_FREEZE, - CTDB_CONTROL_THAW, - CTDB_CONTROL_GET_VNN, - CTDB_CONTROL_SHUTDOWN, - CTDB_CONTROL_GET_MONMODE, - CTDB_CONTROL_SET_MONMODE, - CTDB_CONTROL_MAX_RSN, - CTDB_CONTROL_SET_RSN_NONEMPTY, - CTDB_CONTROL_DELETE_LOW_RSN, - CTDB_CONTROL_TAKEOVER_IP, - CTDB_CONTROL_RELEASE_IP, - CTDB_CONTROL_TCP_CLIENT, - CTDB_CONTROL_TCP_ADD, - CTDB_CONTROL_TCP_REMOVE, - CTDB_CONTROL_STARTUP, +enum ctdb_controls {CTDB_CONTROL_PROCESS_EXISTS = 0, + CTDB_CONTROL_STATISTICS = 1, + /* #2 removed */ + CTDB_CONTROL_PING = 3, + CTDB_CONTROL_GETDBPATH = 4, + CTDB_CONTROL_GETVNNMAP = 5, + CTDB_CONTROL_SETVNNMAP = 6, + CTDB_CONTROL_GET_DEBUG = 7, + CTDB_CONTROL_SET_DEBUG = 8, + CTDB_CONTROL_GET_DBMAP = 9, + CTDB_CONTROL_GET_NODEMAP = 10, + CTDB_CONTROL_SET_DMASTER = 11, + CTDB_CONTROL_CLEAR_DB = 12, + CTDB_CONTROL_PULL_DB = 13, + CTDB_CONTROL_PUSH_DB = 14, + CTDB_CONTROL_GET_RECMODE = 15, + CTDB_CONTROL_SET_RECMODE = 16, + CTDB_CONTROL_STATISTICS_RESET = 17, + CTDB_CONTROL_DB_ATTACH = 18, + CTDB_CONTROL_SET_CALL = 19, + CTDB_CONTROL_TRAVERSE_START = 20, + CTDB_CONTROL_TRAVERSE_ALL = 21, + CTDB_CONTROL_TRAVERSE_DATA = 22, + CTDB_CONTROL_REGISTER_SRVID = 23, + CTDB_CONTROL_DEREGISTER_SRVID = 24, + CTDB_CONTROL_GET_DBNAME = 25, + CTDB_CONTROL_ENABLE_SEQNUM = 26, + CTDB_CONTROL_UPDATE_SEQNUM = 27, + /* #28 removed */ + CTDB_CONTROL_DUMP_MEMORY = 29, + CTDB_CONTROL_GET_PID = 30, + CTDB_CONTROL_GET_RECMASTER = 31, + CTDB_CONTROL_SET_RECMASTER = 32, + CTDB_CONTROL_FREEZE = 33, + CTDB_CONTROL_THAW = 34, + CTDB_CONTROL_GET_VNN = 35, + CTDB_CONTROL_SHUTDOWN = 36, + CTDB_CONTROL_GET_MONMODE = 37, + CTDB_CONTROL_SET_MONMODE = 38, + CTDB_CONTROL_MAX_RSN = 39, + CTDB_CONTROL_SET_RSN_NONEMPTY = 40, + CTDB_CONTROL_DELETE_LOW_RSN = 41, + CTDB_CONTROL_TAKEOVER_IP = 42, + CTDB_CONTROL_RELEASE_IP = 43, + CTDB_CONTROL_TCP_CLIENT = 44, + CTDB_CONTROL_TCP_ADD = 45, + CTDB_CONTROL_TCP_REMOVE = 46, + CTDB_CONTROL_STARTUP = 47, }; /* @@ -490,15 +480,15 @@ struct ctdb_fetch_handle { */ enum ctdb_operation { CTDB_REQ_CALL = 0, - CTDB_REPLY_CALL, - CTDB_REQ_DMASTER, - CTDB_REPLY_DMASTER, - CTDB_REPLY_ERROR, - CTDB_REQ_MESSAGE, - CTDB_REQ_FINISHED, - CTDB_REQ_CONTROL, - CTDB_REPLY_CONTROL, - CTDB_REQ_KEEPALIVE, + CTDB_REPLY_CALL = 1, + CTDB_REQ_DMASTER = 2, + CTDB_REPLY_DMASTER = 3, + CTDB_REPLY_ERROR = 4, + CTDB_REQ_MESSAGE = 5, + /* #6 removed */ + CTDB_REQ_CONTROL = 7, + CTDB_REPLY_CONTROL = 8, + CTDB_REQ_KEEPALIVE = 9, }; #define CTDB_MAGIC 0x43544442 /* CTDB */ diff --git a/ctdb/tests/bench.sh b/ctdb/tests/bench.sh index 495abbffe8a..48a4277591d 100755 --- a/ctdb/tests/bench.sh +++ b/ctdb/tests/bench.sh @@ -12,10 +12,7 @@ for i in `seq 1 $NUMNODES`; do echo 127.0.0.$i >> nodes.txt done -echo "Trying $NUMNODES nodes" -for i in `seq 1 $NUMNODES`; do - $VALGRIND bin/ctdbd --reclock=rec.lock --nlist nodes.txt --event-script=tests/events --logfile=- --socket=sock.$i -done +tests/start_daemons.sh $NUMNODES nodes.txt || exit 1 killall -9 ctdb_bench echo "Trying $NUMNODES nodes" diff --git a/ctdb/tests/ctdbd.sh b/ctdb/tests/ctdbd.sh index 70c452a9d05..29777516bdf 100755 --- a/ctdb/tests/ctdbd.sh +++ b/ctdb/tests/ctdbd.sh @@ -2,14 +2,7 @@ killall -q ctdbd -echo "Starting 2 ctdb daemons" -$VALGRIND bin/ctdbd --reclock=rec.lock --nlist tests/nodes.txt --event-script=tests/events --logfile=- -$VALGRIND bin/ctdbd --reclock=rec.lock --nlist tests/nodes.txt --event-script=tests/events --logfile=- --socket=sock.2 - -while bin/ctdb status | grep RECOVERY > /dev/null; do - echo "`date` Waiting for recovery" - sleep 1; -done +tests/start_daemons.sh 2 tests/nodes.txt || exit 1 echo "Testing ping" $VALGRIND bin/ctdb ping || exit 1 diff --git a/ctdb/tests/fetch.sh b/ctdb/tests/fetch.sh index a2123a6b34f..325957e63f7 100755 --- a/ctdb/tests/fetch.sh +++ b/ctdb/tests/fetch.sh @@ -10,11 +10,8 @@ for i in `seq 1 $NUMNODES`; do echo 127.0.0.$i >> nodes.txt done -killall -q ctdbd -echo "Trying $NUMNODES nodes" -for i in `seq 1 $NUMNODES`; do - $VALGRIND bin/ctdbd --reclock=rec.lock --nlist nodes.txt --event-script=tests/events --logfile=- --socket=sock.$i -done +tests/start_daemons.sh $NUMNODES nodes.txt || exit 1 + killall -9 -q ctdb_fetch for i in `seq 1 $NUMNODES`; do diff --git a/ctdb/tests/start_daemons.sh b/ctdb/tests/start_daemons.sh new file mode 100755 index 00000000000..e902ae45f48 --- /dev/null +++ b/ctdb/tests/start_daemons.sh @@ -0,0 +1,19 @@ +#!/bin/sh + +NUMNODES="$1" +NODES=$2 + +pkill -f ctdbd + +echo "Starting $NUMNODES ctdb daemons" +for i in `seq 1 $NUMNODES`; do + $VALGRIND bin/ctdbd --reclock=rec.lock --nlist $NODES --event-script=tests/events --logfile=- --socket=sock.$i --dbdir=test.db || exit 1 +done +ln -sf sock.1 /tmp/ctdb.socket || exit 1 + +while bin/ctdb status | grep RECOVERY > /dev/null; do + echo "`date` Waiting for recovery" + sleep 1; +done + +exit 0 diff --git a/ctdb/tools/ctdb_control.c b/ctdb/tools/ctdb_control.c index 40852b063ec..34080bc50b5 100644 --- a/ctdb/tools/ctdb_control.c +++ b/ctdb/tools/ctdb_control.c @@ -107,7 +107,6 @@ static void show_statistics(struct ctdb_statistics *s) STATISTICS_FIELD(controls.traverse_data), STATISTICS_FIELD(controls.update_seqnum), STATISTICS_FIELD(controls.enable_seqnum), - STATISTICS_FIELD(controls.set_seqnum_frequency), STATISTICS_FIELD(controls.register_srvid), STATISTICS_FIELD(controls.deregister_srvid), STATISTICS_FIELD(timeouts.call),