[SCM] CTDB repository - branch master updated - ctdb-2.1-20-ga0ef73e

Amitay Isaacs amitay at samba.org
Mon Feb 4 22:20:12 MST 2013


The branch, master has been updated
       via  a0ef73e197dc9147f7718e0813fe803ff0b3d54d (commit)
       via  9b0d56b16775aa16f33bdfdf831256e085fa3339 (commit)
       via  3400b2ed34b6eb9496eb55f1aab6f89d2952060d (commit)
       via  0581f9a84e58764d194f4e04064c2c5b393c348b (commit)
       via  501461cc3e132d4adee9e91b5d4513a26bae2846 (commit)
      from  f1ffe1112b7e342d7f1228ca816a8e5918f893cf (commit)

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


- Log -----------------------------------------------------------------
commit a0ef73e197dc9147f7718e0813fe803ff0b3d54d
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Feb 5 13:16:46 2013 +1100

    initscript: export CTDB_EXTERNAL_TRACE
    
    This means it can be set like any other configuration option in the
    configuration file, without needing to export it there.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit 9b0d56b16775aa16f33bdfdf831256e085fa3339
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Feb 5 14:36:29 2013 +1100

    ctdbd: Don't use a fixed length buffer for the hung script command
    
    The amount of data to write into the buffer wasn't constrained
    anywhere...
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit 3400b2ed34b6eb9496eb55f1aab6f89d2952060d
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Feb 5 14:25:01 2013 +1100

    ctdbd: Complain loudly if CTDB_DEBUG_HUNG_SCRIPT script isn't executable
    
    This is quite easy to misconfigure by failing to set the execute bit
    on the script.  Better to complain loudly.
    
    This is a debugging facilty rather than core CTDB functionality, so it
    doesn't need a subtle mechanism to disable it at run-time.  To disable
    the designated script at run-time either edit it to put an "exit 0" at
    the top or move it aside and symlink to /bin/true.
    
    This is implemented by actually removing the code that checks that the
    file exists and is executable.  The output from the shell when the
    system() function fails is just as useful.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit 0581f9a84e58764d194f4e04064c2c5b393c348b
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Feb 5 15:49:52 2013 +1100

    ctdbd: Remove command-line option --debug-hung-script
    
    Use an environment variable instead.  This just means that the
    initscript exports CTDB_DEBUG_HUNG_SCRIPT and the code checks for the
    environment variable.
    
    The justification for this simplification is that more debug options
    will be arriving soon and we want to handle them consistently without
    needing to add a command-line option for each.  So, the convention
    will be to use an environment variable for each debug option.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit 501461cc3e132d4adee9e91b5d4513a26bae2846
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Feb 5 13:08:55 2013 +1100

    ctdbd: Remove debug_hung_script_ctx
    
    The only allocation against this context is by
    ctdb_fork_with_logging().  This memory is freed by ctdb_log_handler()
    anyway.  There should be no memory leak.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

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

Summary of changes:
 config/ctdb.init       |    8 +++++++-
 include/ctdb_private.h |    3 ---
 server/ctdbd.c         |   11 -----------
 server/eventscript.c   |   35 +++++++++--------------------------
 4 files changed, 16 insertions(+), 41 deletions(-)


Changeset truncated at 500 lines:

diff --git a/config/ctdb.init b/config/ctdb.init
index 9f9b686..dafe8f7 100755
--- a/config/ctdb.init
+++ b/config/ctdb.init
@@ -95,7 +95,6 @@ build_ctdb_options () {
     maybe_set "--event-script-dir"       "$CTDB_EVENT_SCRIPT_DIR"
     maybe_set "--transport"              "$CTDB_TRANSPORT"
     maybe_set "-d"                       "$CTDB_DEBUGLEVEL"
-    maybe_set "--debug-hung-script"      "$CTDB_DEBUG_HUNG_SCRIPT"
     maybe_set "--notification-script"    "$CTDB_NOTIFY_SCRIPT"
     maybe_set "--start-as-disabled"      "$CTDB_START_AS_DISABLED"    "yes"
     maybe_set "--start-as-stopped "      "$CTDB_START_AS_STOPPED"     "yes"
@@ -108,6 +107,11 @@ build_ctdb_options () {
     maybe_set "--max-persistent-check-errors" "$CTDB_MAX_PERSISTENT_CHECK_ERRORS"
 }
 
+export_debug_variables ()
+{
+    export CTDB_DEBUG_HUNG_SCRIPT CTDB_EXTERNAL_TRACE
+}
+
 # Log given message or stdin to either syslog or a CTDB log file
 do_log ()
 {
@@ -235,6 +239,8 @@ start() {
 
     build_ctdb_options
 
+    export_debug_variables
+
     # make sure we drop any ips that might still be held if previous
     # instance of ctdb got killed with -9 or similar
     drop_all_public_ips
diff --git a/include/ctdb_private.h b/include/ctdb_private.h
index cd0feaa..cf850aa 100644
--- a/include/ctdb_private.h
+++ b/include/ctdb_private.h
@@ -494,7 +494,6 @@ struct ctdb_context {
 	bool do_setsched;
 	void *saved_scheduler_param;
 	const char *event_script_dir;
-	const char *debug_hung_script;
 	const char *notification_script;
 	const char *default_public_interface;
 	pid_t ctdbd_pid;
@@ -539,7 +538,6 @@ struct ctdb_context {
 
 	const char *public_addresses_file;
 	struct trbt_tree *child_processes; 
-	TALLOC_CTX *debug_hung_script_ctx;
 
 	/* Used for locking record/db/alldb */
 	int lock_num_current;
@@ -1204,7 +1202,6 @@ int ctdb_set_single_public_ip(struct ctdb_context *ctdb,
 			      const char *ip);
 int ctdb_set_event_script(struct ctdb_context *ctdb, const char *script);
 int ctdb_set_event_script_dir(struct ctdb_context *ctdb, const char *script_dir);
-int ctdb_set_debug_hung_script(struct ctdb_context *ctdb, const char *script);
 int ctdb_set_notification_script(struct ctdb_context *ctdb, const char *script);
 void lcp2_forcerebalance(struct ctdb_context *ctdb, uint32_t pnn);
 int ctdb_takeover_run(struct ctdb_context *ctdb, struct ctdb_node_map *nodemap, client_async_callback fail_callback, void *callback_data);
diff --git a/server/ctdbd.c b/server/ctdbd.c
index ad1baac..512a4b7 100644
--- a/server/ctdbd.c
+++ b/server/ctdbd.c
@@ -33,7 +33,6 @@ static struct {
 	const char *public_address_list;
 	const char *event_script_dir;
 	const char *notification_script;
-	const char *debug_hung_script;
 	const char *logfile;
 	const char *recovery_lock_file;
 	const char *db_dir;
@@ -61,7 +60,6 @@ static struct {
 	.db_dir_persistent = VARDIR "/ctdb/persistent",
 	.db_dir_state = VARDIR "/ctdb/state",
 	.script_log_level = DEBUG_ERR,
-	.debug_hung_script = ETCDIR "/ctdb/debug-hung-script.sh",
 };
 
 int script_log_level;
@@ -126,7 +124,6 @@ int main(int argc, const char *argv[])
 		{ "logfile", 0, POPT_ARG_STRING, &options.logfile, 0, "log file location", "filename" },
 		{ "nlist", 0, POPT_ARG_STRING, &options.nlist, 0, "node list file", "filename" },
 		{ "notification-script", 0, POPT_ARG_STRING, &options.notification_script, 0, "notification script", "filename" },
-		{ "debug-hung-script", 0, POPT_ARG_STRING, &options.debug_hung_script, 0, "debug script for hung eventscripts", "filename" },
 		{ "listen", 0, POPT_ARG_STRING, &options.myaddress, 0, "address to listen on", "address" },
 		{ "transport", 0, POPT_ARG_STRING, &options.transport, 0, "protocol transport", NULL },
 		{ "dbdir", 0, POPT_ARG_STRING, &options.db_dir, 0, "directory for the tdb files", NULL },
@@ -310,14 +307,6 @@ int main(int argc, const char *argv[])
 		}
 	}
 
-	if (options.debug_hung_script != NULL) {
-		ret = ctdb_set_debug_hung_script(ctdb, options.debug_hung_script);
-	}
-	if (ret == -1) {
-		DEBUG(DEBUG_ALERT,("Unable to setup script to debug hung eventscripts\n"));
-		exit(1);
-	}
-
 	ctdb->valgrinding = options.valgrinding;
 	if (options.valgrinding || options.nosetsched) {
 		ctdb->do_setsched = 0;
diff --git a/server/eventscript.c b/server/eventscript.c
index 762f950..817cb0c 100644
--- a/server/eventscript.c
+++ b/server/eventscript.c
@@ -503,21 +503,12 @@ static void ctdb_event_script_handler(struct event_context *ev, struct fd_event
 	}
 }
 
-/*
-  setup the script to debug hung eventscripts
-*/
-int ctdb_set_debug_hung_script(struct ctdb_context *ctdb, const char *script)
-{
-	ctdb->debug_hung_script = talloc_strdup(ctdb, script);
-	CTDB_NO_MEMORY(ctdb, ctdb->debug_hung_script);
-	return 0;
-}
-
 static void ctdb_run_debug_hung_script(struct ctdb_context *ctdb, struct ctdb_event_script_state *state)
 {
 	struct ctdb_script_wire *current = get_current_script(state);
 	char *cmd;
 	pid_t pid;
+	const char * debug_hung_script = ETCDIR "/ctdb/debug-hung-script.sh";
 
 	cmd = child_command_string(ctdb, state,
 				   state->from_user, current->name,
@@ -528,9 +519,7 @@ static void ctdb_run_debug_hung_script(struct ctdb_context *ctdb, struct ctdb_ev
 			 cmd, timeval_elapsed(&current->start), state->child));
 	talloc_free(cmd);
 
-	talloc_free(ctdb->debug_hung_script_ctx);
-	ctdb->debug_hung_script_ctx = talloc_new(ctdb);
- 	if (!ctdb_fork_with_logging(ctdb->debug_hung_script_ctx, ctdb, "Hung script", NULL, NULL, &pid)) {
+	if (!ctdb_fork_with_logging(ctdb, ctdb, "Hung script", NULL, NULL, &pid)) {
 		DEBUG(DEBUG_ERR,("Failed to fork a child process with logging to track hung event script\n"));
 		ctdb_kill(state->ctdb, state->child, SIGTERM);
 		return;
@@ -542,22 +531,16 @@ static void ctdb_run_debug_hung_script(struct ctdb_context *ctdb, struct ctdb_ev
 		return;
 	}
 	if (pid == 0) {
-		struct stat st;
-		char buf[200];
-
-		if (stat(ctdb->debug_hung_script, &st) != 0) {
-			DEBUG(DEBUG_ERR,("Failed to stat the script to debug hung eventscript. Is it not installed correctly? (script:%s)\n", ctdb->debug_hung_script));
-			ctdb_kill(state->ctdb, state->child, SIGTERM);
-			_exit(0);
-		}		
-		if (!(st.st_mode & S_IXUSR)) {
-			DEBUG(DEBUG_DEBUG,("Debug script %s is not executable.\n", ctdb->debug_hung_script));
-			ctdb_kill(state->ctdb, state->child, SIGTERM);
-			_exit(0);
+		char *buf;
+
+		if (getenv("CTDB_DEBUG_HUNG_SCRIPT") != NULL) {
+			debug_hung_script = getenv("CTDB_DEBUG_HUNG_SCRIPT");
 		}
 
-		sprintf(buf, "%s %d", ctdb->debug_hung_script, state->child);
+		buf = talloc_asprintf(NULL, "%s %d",
+				      debug_hung_script, state->child);
 		system(buf);
+		talloc_free(buf);
 
 		/* Now we can kill the child */
 		ctdb_kill(state->ctdb, state->child, SIGTERM);


-- 
CTDB repository


More information about the samba-cvs mailing list