The branch, master has been updated via 4948574f5a290434f3edd0c052cf13f3645deec4 (commit) from 181318fea6886c40d0aff02d0de777f28ffeddce (commit)
http://gitweb.samba.org/?p=sahlberg/ctdb.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit 4948574f5a290434f3edd0c052cf13f3645deec4 Author: Ronnie Sahlberg <[EMAIL PROTECTED]> Date: Wed Jun 4 10:46:20 2008 +1000 add a parameter for the tdb-flags to the client function ctdb_attach() so that we can pass TDB_NOSYNC when we attach to a persistent database and want fast unsafe writes instead of slow but safe tdb_transaction writes. enhance the ctdb_persistent test suite to test both safe and unsafe writes ----------------------------------------------------------------------- Summary of changes: client/ctdb_client.c | 4 ++-- include/ctdb.h | 2 +- server/ctdb_recoverd.c | 2 +- tests/ctdb_bench.c | 2 +- tests/ctdb_fetch.c | 2 +- tests/ctdb_persistent.c | 14 ++++++++++++-- tests/ctdb_randrec.c | 2 +- tests/ctdb_store.c | 2 +- tests/ctdb_traverse.c | 2 +- tests/persistent.sh | 22 +++++++++++++++++++++- tools/ctdb.c | 4 ++-- tools/ctdb_vacuum.c | 4 ++-- 12 files changed, 46 insertions(+), 16 deletions(-) Changeset truncated at 500 lines: diff --git a/client/ctdb_client.c b/client/ctdb_client.c index 921392c..04befd0 100644 --- a/client/ctdb_client.c +++ b/client/ctdb_client.c @@ -1640,7 +1640,7 @@ static int ctdb_fetch_func(struct ctdb_call_info *call) /* attach to a specific database - client call */ -struct ctdb_db_context *ctdb_attach(struct ctdb_context *ctdb, const char *name, bool persistent) +struct ctdb_db_context *ctdb_attach(struct ctdb_context *ctdb, const char *name, bool persistent, uint32_t tdb_flags) { struct ctdb_db_context *ctdb_db; TDB_DATA data; @@ -1663,7 +1663,7 @@ struct ctdb_db_context *ctdb_attach(struct ctdb_context *ctdb, const char *name, data.dsize = strlen(name)+1; /* tell ctdb daemon to attach */ - ret = ctdb_control(ctdb, CTDB_CURRENT_NODE, 0, + ret = ctdb_control(ctdb, CTDB_CURRENT_NODE, tdb_flags, persistent?CTDB_CONTROL_DB_ATTACH_PERSISTENT:CTDB_CONTROL_DB_ATTACH, 0, data, ctdb_db, &data, &res, NULL, NULL); if (ret != 0 || res != 0 || data.dsize != sizeof(uint32_t)) { diff --git a/include/ctdb.h b/include/ctdb.h index 95d3f2f..ecbe957 100644 --- a/include/ctdb.h +++ b/include/ctdb.h @@ -185,7 +185,7 @@ int ctdb_start_daemon(struct ctdb_context *ctdb, bool do_fork); /* attach to a ctdb database */ -struct ctdb_db_context *ctdb_attach(struct ctdb_context *ctdb, const char *name, bool persistent); +struct ctdb_db_context *ctdb_attach(struct ctdb_context *ctdb, const char *name, bool persistent, uint32_t tdb_flags); /* find an attached ctdb_db handle given a name diff --git a/server/ctdb_recoverd.c b/server/ctdb_recoverd.c index 9a33819..30b121c 100644 --- a/server/ctdb_recoverd.c +++ b/server/ctdb_recoverd.c @@ -866,7 +866,7 @@ static void vacuum_fetch_handler(struct ctdb_context *ctdb, uint64_t srvid, } /* attach to it */ - ctdb_db = ctdb_attach(ctdb, name, persistent); + ctdb_db = ctdb_attach(ctdb, name, persistent, 0); if (ctdb_db == NULL) { DEBUG(DEBUG_ERR,(__location__ " Failed to attach to database '%s'\n", name)); talloc_free(tmp_ctx); diff --git a/tests/ctdb_bench.c b/tests/ctdb_bench.c index c14ef2b..2d6b3ab 100644 --- a/tests/ctdb_bench.c +++ b/tests/ctdb_bench.c @@ -201,7 +201,7 @@ int main(int argc, const char *argv[]) &cluster_ready); /* attach to a specific database */ - ctdb_db = ctdb_attach(ctdb, "test.tdb", false); + ctdb_db = ctdb_attach(ctdb, "test.tdb", false, 0); if (!ctdb_db) { printf("ctdb_attach failed - %s\n", ctdb_errstr(ctdb)); exit(1); diff --git a/tests/ctdb_fetch.c b/tests/ctdb_fetch.c index 56eb244..2cc51d5 100644 --- a/tests/ctdb_fetch.c +++ b/tests/ctdb_fetch.c @@ -219,7 +219,7 @@ int main(int argc, const char *argv[]) &cluster_ready); /* attach to a specific database */ - ctdb_db = ctdb_attach(ctdb, "test.tdb", false); + ctdb_db = ctdb_attach(ctdb, "test.tdb", false, 0); if (!ctdb_db) { printf("ctdb_attach failed - %s\n", ctdb_errstr(ctdb)); exit(1); diff --git a/tests/ctdb_persistent.c b/tests/ctdb_persistent.c index b98e662..7bd4ab8 100644 --- a/tests/ctdb_persistent.c +++ b/tests/ctdb_persistent.c @@ -167,11 +167,12 @@ int main(int argc, const char *argv[]) { struct ctdb_context *ctdb; struct ctdb_db_context *ctdb_db; - + int unsafe_writes = 0; struct poptOption popt_options[] = { POPT_AUTOHELP POPT_CTDB_CMDLINE { "timelimit", 't', POPT_ARG_INT, &timelimit, 0, "timelimit", "integer" }, + { "unsafe-writes", 'u', POPT_ARG_NONE, &unsafe_writes, 0, "do not use tdb transactions when writing", NULL }, POPT_TABLEEND }; int opt; @@ -201,9 +202,18 @@ int main(int argc, const char *argv[]) ev = event_context_init(NULL); ctdb = ctdb_cmdline_client(ev); + if (ctdb == NULL) { + printf("Could not attach to daemon\n"); + return 1; + } /* attach to a specific database */ - ctdb_db = ctdb_attach(ctdb, "persistent.tdb", true); + if (unsafe_writes == 1) { + ctdb_db = ctdb_attach(ctdb, "persistent.tdb", true, TDB_NOSYNC); + } else { + ctdb_db = ctdb_attach(ctdb, "persistent.tdb", true, 0); + } + if (!ctdb_db) { printf("ctdb_attach failed - %s\n", ctdb_errstr(ctdb)); exit(1); diff --git a/tests/ctdb_randrec.c b/tests/ctdb_randrec.c index 287b57c..4b9b2bc 100644 --- a/tests/ctdb_randrec.c +++ b/tests/ctdb_randrec.c @@ -143,7 +143,7 @@ int main(int argc, const char *argv[]) ctdb = ctdb_cmdline_client(ev); /* attach to a specific database */ - ctdb_db = ctdb_attach(ctdb, "test.tdb", false); + ctdb_db = ctdb_attach(ctdb, "test.tdb", false, 0); if (!ctdb_db) { printf("ctdb_attach failed - %s\n", ctdb_errstr(ctdb)); exit(1); diff --git a/tests/ctdb_store.c b/tests/ctdb_store.c index 70ce7fb..ce4195c 100644 --- a/tests/ctdb_store.c +++ b/tests/ctdb_store.c @@ -139,7 +139,7 @@ int main(int argc, const char *argv[]) ctdb = ctdb_cmdline_client(ev); /* attach to a specific database */ - ctdb_db = ctdb_attach(ctdb, "test.tdb", false); + ctdb_db = ctdb_attach(ctdb, "test.tdb", false, 0); if (!ctdb_db) { printf("ctdb_attach failed - %s\n", ctdb_errstr(ctdb)); exit(1); diff --git a/tests/ctdb_traverse.c b/tests/ctdb_traverse.c index 136dfbc..f5ca715 100644 --- a/tests/ctdb_traverse.c +++ b/tests/ctdb_traverse.c @@ -92,7 +92,7 @@ int main(int argc, const char *argv[]) ctdb = ctdb_cmdline_client(ev); /* attach to a specific database */ - ctdb_db = ctdb_attach(ctdb, dbname, false); + ctdb_db = ctdb_attach(ctdb, dbname, false, 0); if (!ctdb_db) { printf("ctdb_attach failed - %s\n", ctdb_errstr(ctdb)); exit(1); diff --git a/tests/persistent.sh b/tests/persistent.sh index d952786..327f8bc 100755 --- a/tests/persistent.sh +++ b/tests/persistent.sh @@ -5,7 +5,8 @@ if [ $# -gt 0 ]; then NUMNODES=$1 fi -echo "Starting $NUMNODES daemons" + +echo "Starting $NUMNODES daemons for SAFE persistent writes" tests/start_daemons.sh $NUMNODES || exit 1 killall -9 -q ctdb_persistent @@ -17,5 +18,24 @@ wait echo "Shutting down" bin/ctdb shutdown -n all --socket=sock.1 +killall -9 ctdbd + + + +echo "Starting $NUMNODES daemons for UNSAFE persistent writes" +tests/start_daemons.sh $NUMNODES || exit 1 + +killall -9 -q ctdb_persistent + +for i in `seq 1 $NUMNODES`; do + $VALGRIND bin/ctdb_persistent --unsafe-writes --timelimit 30 --socket sock.$i $* & +done +wait + +echo "Shutting down" +bin/ctdb shutdown -n all --socket=sock.1 +killall -9 ctdbd + + exit 0 diff --git a/tools/ctdb.c b/tools/ctdb.c index c8cfe80..6df7813 100644 --- a/tools/ctdb.c +++ b/tools/ctdb.c @@ -1278,7 +1278,7 @@ static int control_catdb(struct ctdb_context *ctdb, int argc, const char **argv) } db_name = argv[0]; - ctdb_db = ctdb_attach(ctdb, db_name, false); + ctdb_db = ctdb_attach(ctdb, db_name, false, 0); if (ctdb_db == NULL) { DEBUG(DEBUG_ERR,("Unable to attach to database '%s'\n", db_name)); @@ -1633,7 +1633,7 @@ static int control_attach(struct ctdb_context *ctdb, int argc, const char **argv } db_name = argv[0]; - ctdb_db = ctdb_attach(ctdb, db_name, false); + ctdb_db = ctdb_attach(ctdb, db_name, false, 0); if (ctdb_db == NULL) { DEBUG(DEBUG_ERR,("Unable to attach to database '%s'\n", db_name)); return -1; diff --git a/tools/ctdb_vacuum.c b/tools/ctdb_vacuum.c index 1423582..60a0b0a 100644 --- a/tools/ctdb_vacuum.c +++ b/tools/ctdb_vacuum.c @@ -260,7 +260,7 @@ static int ctdb_vacuum_db(struct ctdb_context *ctdb, uint32_t db_id, struct ctdb return -1; } - ctdb_db = ctdb_attach(ctdb, name, persistent); + ctdb_db = ctdb_attach(ctdb, name, persistent, 0); if (ctdb_db == NULL) { DEBUG(DEBUG_ERR,(__location__ " Failed to attach to database '%s'\n", name)); talloc_free(vdata); @@ -579,7 +579,7 @@ static int ctdb_repack_db(struct ctdb_context *ctdb, uint32_t db_id, return -1; } - ctdb_db = ctdb_attach(ctdb, name, persistent); + ctdb_db = ctdb_attach(ctdb, name, persistent, 0); if (ctdb_db == NULL) { DEBUG(DEBUG_ERR,(__location__ " Failed to attach to database '%s'\n", name)); return -1; -- CTDB repository