[SCM] CTDB repository - branch master updated - ctdb-1.0.108-64-g6ed34d5

Ronnie Sahlberg sahlberg at samba.org
Tue Dec 15 02:55:08 MST 2009


The branch, master has been updated
       via  6ed34d5320c39d8a55f2a36ad4c1ab574e0b0796 (commit)
       via  bcf494b81f4277dc75f05faccf0c446bd15f6e2b (commit)
       via  24767be2eb9aed29704c2a4097bab5466cb6728f (commit)
       via  340be0179f55acfff77f8c3c8be958679227bde1 (commit)
      from  ea9e39369379939abf6a4076fa2014c10c1a9ad0 (commit)

http://gitweb.samba.org/?p=sahlberg/ctdb.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 6ed34d5320c39d8a55f2a36ad4c1ab574e0b0796
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Tue Dec 15 20:56:16 2009 +1100

    Author: Rusty Russell <rusty at rustcorp.com.au>
    Date:   Tue Dec 15 15:53:30 2009 +1030
    
        eventscript: hack to avoid overloading valgrind
    
        Now we fork one child per script, when running under valgrind the
    load
        gets quite high.  This is because valgrind does a lot of work after
    exit,
        and we don't wait for the children to finish; we start the next one
    when
        the child reports status via the pipe.
    
        This fix is ugly, but simple.
    
        Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>

commit bcf494b81f4277dc75f05faccf0c446bd15f6e2b
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Tue Dec 15 19:04:52 2009 +1100

    This is a dodgy patch.
    
    I saw once where the master ctdbd logging structure was talloc freed
    which caused issues.
    So only free the structure if it is NOT the master structure.
    
    This needs to be looked into in more detail.

commit 24767be2eb9aed29704c2a4097bab5466cb6728f
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Tue Dec 15 12:14:49 2009 +1100

    add a new test tool that just locks and releases the same record over and over

commit 340be0179f55acfff77f8c3c8be958679227bde1
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Tue Dec 15 11:29:16 2009 +1100

    ctdb_fetch requires the number of nodes being specified.
    Have it log an error and terminate if thie parameter was omitted

-----------------------------------------------------------------------

Summary of changes:
 Makefile.in                                     |    7 ++-
 server/ctdb_logging.c                           |    4 +-
 server/eventscript.c                            |    3 +
 tests/src/ctdb_fetch.c                          |    5 ++
 tests/src/{ctdb_traverse.c => ctdb_fetch_one.c} |   72 +++++++++++++++-------
 5 files changed, 66 insertions(+), 25 deletions(-)
 copy tests/src/{ctdb_traverse.c => ctdb_fetch_one.c} (62%)


Changeset truncated at 500 lines:

diff --git a/Makefile.in b/Makefile.in
index df80e7f..0684df3 100755
--- a/Makefile.in
+++ b/Makefile.in
@@ -58,7 +58,8 @@ CTDB_SERVER_OBJ = server/ctdbd.o server/ctdb_daemon.o server/ctdb_lockwait.o \
 	server/ctdb_vacuum.o server/ctdb_banning.o \
 	$(CTDB_CLIENT_OBJ) $(CTDB_TCP_OBJ) @INFINIBAND_WRAPPER_OBJ@
 
-TEST_BINS=tests/bin/ctdb_bench tests/bin/ctdb_fetch tests/bin/ctdb_store \
+TEST_BINS=tests/bin/ctdb_bench tests/bin/ctdb_fetch tests/bin/ctdb_fetch_one \
+	tests/bin/ctdb_store \
 	tests/bin/ctdb_randrec tests/bin/ctdb_persistent \
 	tests/bin/ctdb_traverse tests/bin/rb_test tests/bin/ctdb_transaction \
 	@INFINIBAND_BINS@
@@ -143,6 +144,10 @@ tests/bin/ctdb_fetch: $(CTDB_CLIENT_OBJ) tests/src/ctdb_fetch.o
 	@echo Linking $@
 	@$(CC) $(CFLAGS) -o $@ tests/src/ctdb_fetch.o $(CTDB_CLIENT_OBJ) $(LIB_FLAGS)
 
+tests/bin/ctdb_fetch_one: $(CTDB_CLIENT_OBJ) tests/src/ctdb_fetch_one.o 
+	@echo Linking $@
+	@$(CC) $(CFLAGS) -o $@ tests/src/ctdb_fetch_one.o $(CTDB_CLIENT_OBJ) $(LIB_FLAGS)
+
 tests/bin/ctdb_store: $(CTDB_CLIENT_OBJ) tests/src/ctdb_store.o 
 	@echo Linking $@
 	@$(CC) $(CFLAGS) -o $@ tests/src/ctdb_store.o $(CTDB_CLIENT_OBJ) $(LIB_FLAGS)
diff --git a/server/ctdb_logging.c b/server/ctdb_logging.c
index 770deb6..de25865 100644
--- a/server/ctdb_logging.c
+++ b/server/ctdb_logging.c
@@ -382,7 +382,9 @@ static void ctdb_log_handler(struct event_context *ev, struct fd_event *fde,
 	if (n > 0) {
 		log->buf_used += n;
 	} else if (n == 0) {
-		talloc_free(log);
+		if (log != log_state) {
+			talloc_free(log);
+		}
 		return;
 	}
 
diff --git a/server/eventscript.c b/server/eventscript.c
index 5bec0e0..59cb6a3 100644
--- a/server/eventscript.c
+++ b/server/eventscript.c
@@ -450,6 +450,9 @@ static void ctdb_event_script_handler(struct event_context *ev, struct fd_event
 		state->cb_status = 0;
 	}
 
+	/* valgrind gets overloaded if we run next script as it's still doing
+	 * post-execution analysis, so kill finished child here. */
+	kill(state->child, SIGKILL);
 	state->child = 0;
 
 	/* Aborted or finished all scripts?  We're done. */
diff --git a/tests/src/ctdb_fetch.c b/tests/src/ctdb_fetch.c
index eecbb84..ec53ac9 100644
--- a/tests/src/ctdb_fetch.c
+++ b/tests/src/ctdb_fetch.c
@@ -200,6 +200,11 @@ int main(int argc, const char *argv[])
 		while (extra_argv[extra_argc]) extra_argc++;
 	}
 
+	if (num_nodes == 0) {
+		printf("You must specify the number of nodes\n");
+		exit(1);
+	}
+
 	ev = event_context_init(NULL);
 
 	ctdb = ctdb_cmdline_client(ev);
diff --git a/tests/src/ctdb_traverse.c b/tests/src/ctdb_fetch_one.c
similarity index 62%
copy from tests/src/ctdb_traverse.c
copy to tests/src/ctdb_fetch_one.c
index 1726b23..648aa18 100644
--- a/tests/src/ctdb_traverse.c
+++ b/tests/src/ctdb_fetch_one.c
@@ -1,8 +1,8 @@
 /* 
-   simple tool to traverse a ctdb database over and over and over
+   simple ctdb benchmark
+   This test just fetch_locks a record and releases it in a loop.
 
-   Copyright (C) Andrew Tridgell  2006
-	Ronnie sahlberg 2007
+   Copyright (C) Ronnie Sahlberg 2009
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -27,24 +27,52 @@
 #include <sys/time.h>
 #include <time.h>
 
-static const char *dbname = "test.tdb";
+static int timelimit = 10;
+static int lock_count = 0;
 
-static int traverse_callback(struct ctdb_context *ctdb, TDB_DATA key, TDB_DATA data, void *private_data)
+static struct ctdb_db_context *ctdb_db;
+
+#define TESTKEY "testkey"
+
+
+static void alarm_handler(int sig)
 {
-	uint32_t *count = private_data;
-	
-	(*count)++;
-	return 0;
+	printf("Locks:%d\n", lock_count);
+	lock_count=0;
+
+	timelimit--;
+	if (timelimit <= 0) {
+		exit(0);
+	}
+	alarm(1);
 }
 
-static void traverse_loop(struct ctdb_context *ctdb, struct ctdb_db_context *ctdb_db, struct event_context *ev)
+/*
+	Just try locking/unlocking the same record over and over
+*/
+static void bench_fetch_one_loop(struct ctdb_context *ctdb, struct event_context *ev)
 {
-	uint32_t count;
+	TDB_DATA key, data;
+
+	key.dptr = discard_const(TESTKEY);
+	key.dsize = strlen(TESTKEY);
 
-	printf("traversing database\n");
-	count = 0;
-	ctdb_traverse(ctdb_db, traverse_callback, &count);
-	printf("traversed %d records\n", count);
+
+	while (1) {
+		TALLOC_CTX *tmp_ctx = talloc_new(ctdb);
+		struct ctdb_record_handle *h;
+
+		h = ctdb_fetch_lock(ctdb_db, tmp_ctx, key, &data);
+		if (h == NULL) {
+			printf("Failed to fetch record '%s' on node %d\n", 
+		       		(const char *)key.dptr, ctdb_get_pnn(ctdb));
+			talloc_free(tmp_ctx);
+			continue;
+		}
+
+		talloc_free(tmp_ctx);
+		lock_count++;
+	}
 }
 
 /*
@@ -53,12 +81,11 @@ static void traverse_loop(struct ctdb_context *ctdb, struct ctdb_db_context *ctd
 int main(int argc, const char *argv[])
 {
 	struct ctdb_context *ctdb;
-	struct ctdb_db_context *ctdb_db;
 
 	struct poptOption popt_options[] = {
 		POPT_AUTOHELP
 		POPT_CTDB_CMDLINE
-		{ "database", 0, POPT_ARG_STRING, &dbname, 0, "database to traverse", "name" },
+		{ "timelimit", 't', POPT_ARG_INT, &timelimit, 0, "timelimit", "integer" },
 		POPT_TABLEEND
 	};
 	int opt;
@@ -78,8 +105,6 @@ int main(int argc, const char *argv[])
 		}
 	}
 
-	/* talloc_enable_leak_report_full(); */
-
 	/* setup the remaining options for the main program to use */
 	extra_argv = poptGetArgs(pc);
 	if (extra_argv) {
@@ -92,7 +117,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, 0);
+	ctdb_db = ctdb_attach(ctdb, "test.tdb", false, 0);
 	if (!ctdb_db) {
 		printf("ctdb_attach failed - %s\n", ctdb_errstr(ctdb));
 		exit(1);
@@ -106,9 +131,10 @@ int main(int argc, const char *argv[])
 		event_loop_once(ev);
 	}
 
-	while (1) {
-		traverse_loop(ctdb, ctdb_db, ev);
-	}
+	signal(SIGALRM, alarm_handler);
+	alarm(1);
+
+	bench_fetch_one_loop(ctdb, ev);
 
 	return 0;
 }


-- 
CTDB repository


More information about the samba-cvs mailing list