[SCM] CTDB repository - branch master updated - ctdb-1.0.114-259-g3afa5d9

Ronnie Sahlberg sahlberg at samba.org
Wed Aug 18 22:55:18 MDT 2010


The branch, master has been updated
       via  3afa5d945a56952a7f211af068d671945de960e5 (commit)
       via  13e58d92f5f1723e850a82ae030d0ca57e89b1ee (commit)
       via  dc301b324d2c14a2425a965c076113c4fe97903e (commit)
       via  68b3761a0874429b90731741f0531f76dcfbb081 (commit)
       via  08f7f85477610a4916c1ec866aa467b28f1bbec3 (commit)
       via  aeb70c7e7822854eb87873a5c7783e27e6e72318 (commit)
       via  d8df6835a931082af232c4b94f1dede6f16169f9 (commit)
       via  8e518950ba281502318d6300f7a5ec6cdf6b5674 (commit)
       via  f5d7dc679501e607c2c83a248a89d3cada9df146 (commit)
      from  25c4ce7e919f13226219f036bcffd2be76b2f06c (commit)

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


- Log -----------------------------------------------------------------
commit 3afa5d945a56952a7f211af068d671945de960e5
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Thu Aug 19 14:48:19 2010 +1000

    We need the deprecated talloc_append_string() for now
    so set the TALLOC_DEPRECATED sympol to allow use of this call
    from ctdb_client.c

commit 13e58d92f5f1723e850a82ae030d0ca57e89b1ee
Merge: dc301b324d2c14a2425a965c076113c4fe97903e 68b3761a0874429b90731741f0531f76dcfbb081
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Thu Aug 19 13:17:56 2010 +1000

    Merge commit 'rusty/ports-from-1.0.112' into foo

commit dc301b324d2c14a2425a965c076113c4fe97903e
Merge: 25c4ce7e919f13226219f036bcffd2be76b2f06c d8df6835a931082af232c4b94f1dede6f16169f9
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Thu Aug 19 13:16:35 2010 +1000

    Merge commit 'rusty/vacuum-fix-master'

commit 68b3761a0874429b90731741f0531f76dcfbb081
Author: Rusty Russell <rusty at rustcorp.com.au>
Date:   Mon Jul 19 19:29:09 2010 +0930

    logging: give a unique logging name to each forked child.
    
    This means we can distinguish which child is logging, esp. via syslog where we have no pid.
    
    Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>

commit 08f7f85477610a4916c1ec866aa467b28f1bbec3
Author: Rusty Russell <rusty at rustcorp.com.au>
Date:   Mon Jul 26 13:58:48 2010 +0930

    takeover: prevent crash by avoiding free in traverse on RST timeout
    
    After 5 attempts to send a RST to a client without any response, we free
    "con"; this is done during a traverse.  This frees the node we are walking
    through (the node is made a child of "con" down in rb_tree.c's
    trbt_create_node() (Valgrind would catch this, as Martin confirmed).
    
    So, we create a temporary parent and reparent onto that; then we free
    that parent after the traverse, thus deleting the unwanted nodes.
    
    CQ:S1019041
    Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>

commit aeb70c7e7822854eb87873a5c7783e27e6e72318
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Jul 6 17:54:43 2010 +1000

    Move NAT gateway firewall rules to recovered|updatenatgw events.
    
    The existing code wasn't working as designed in the start event.  It
    should work here.
    
    BZ: 62613
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit d8df6835a931082af232c4b94f1dede6f16169f9
Author: Rusty Russell <rusty at rustcorp.com.au>
Date:   Wed Jul 21 12:28:04 2010 +0930

    vacuum: disabling vacuuming during a freeze
    
    We shouldn't even think about vacuuming when we've frozen the database
    (which is earlier than when we set CTDB_RECOVERY_ACTIVE)
    
    CQ:S1018154 & S1018349
    Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>

commit 8e518950ba281502318d6300f7a5ec6cdf6b5674
Author: Rusty Russell <rusty at rustcorp.com.au>
Date:   Mon Jul 26 16:08:07 2010 +0930

    vacuum: fix crash on vacuum abort
    
    Martin Schwenke discovered that 517f05e42f17766b1e8db8f1f4789cbad968e304
    ("freeze: abort vacuuming when we're going to freeze.") used ctdb_db for
    a logging message which is in fact uninitialized, causing a crash (even
    if it wasn't actually logged).
    
    Initialize it properly.  Also fix incorrect format in another logging
    message introduced in that same change.
    
    CQ:S1019093
    Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>

commit f5d7dc679501e607c2c83a248a89d3cada9df146
Author: Rusty Russell <rusty at rustcorp.com.au>
Date:   Wed Jul 21 12:29:55 2010 +0930

    freeze: abort vacuuming when we're going to freeze.
    
    There are some reports of freeze timeouts, and it looks like vacuuming might
    be the culprit.  So we add code to tell them to abort when a freeze is
    going on.
    
    (This is based on the 1.0.112 branch version 517f05e42f, but far
     simpler since tdb is now robust against processes being killed during
     transaction commit)
    
    CQ:S1018154 & S1018349
    Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>

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

Summary of changes:
 client/ctdb_client.c     |   11 ++++++++++-
 common/ctdb_logging.c    |    2 +-
 config/events.d/11.natgw |    6 ++++++
 include/ctdb_client.h    |    3 ++-
 include/ctdb_private.h   |    3 +++
 lib/util/debug.c         |    4 +++-
 lib/util/debug.h         |    1 +
 server/ctdb_freeze.c     |    4 ++++
 server/ctdb_lockwait.c   |    1 +
 server/ctdb_logging.c    |   13 ++++++++-----
 server/ctdb_monitor.c    |    1 +
 server/ctdb_persistent.c |    1 +
 server/ctdb_recover.c    |    1 +
 server/ctdb_recoverd.c   |    3 ++-
 server/ctdb_takeover.c   |    9 ++++++---
 server/ctdb_traverse.c   |    2 ++
 server/ctdb_vacuum.c     |   29 ++++++++++++++++++++++++++---
 server/eventscript.c     |    3 +++
 18 files changed, 81 insertions(+), 16 deletions(-)
 mode change 100644 => 100755 config/events.d/11.natgw


Changeset truncated at 500 lines:

diff --git a/client/ctdb_client.c b/client/ctdb_client.c
index 51830ab..cf7779d 100644
--- a/client/ctdb_client.c
+++ b/client/ctdb_client.c
@@ -18,6 +18,9 @@
    along with this program; if not, see <http://www.gnu.org/licenses/>.
 */
 
+/* for talloc_append_string() */
+#define TALLOC_DEPRECATED 1
+
 #include "includes.h"
 #include "db_wrap.h"
 #include "lib/tdb/include/tdb.h"
@@ -3827,9 +3830,15 @@ int ctdb_ctrl_recd_ping(struct ctdb_context *ctdb)
  * to the daemon as a client process, this function can be used to change
  * the ctdb context from daemon into client mode
  */
-int switch_from_server_to_client(struct ctdb_context *ctdb)
+int switch_from_server_to_client(struct ctdb_context *ctdb, const char *fmt, ...)
 {
 	int ret;
+	va_list ap;
+
+	/* Add extra information so we can identify this in the logs */
+	va_start(ap, fmt);
+	debug_extra = talloc_append_string(NULL, talloc_vasprintf(NULL, fmt, ap), ":");
+	va_end(ap);
 
 	/* shutdown the transport */
 	if (ctdb->methods) {
diff --git a/common/ctdb_logging.c b/common/ctdb_logging.c
index 4691208..de6e039 100644
--- a/common/ctdb_logging.c
+++ b/common/ctdb_logging.c
@@ -164,7 +164,7 @@ int32_t ctdb_control_get_log(struct ctdb_context *ctdb, TDB_DATA addr)
 	}
 
 	if (child == 0) {
-		if (switch_from_server_to_client(ctdb) != 0) {
+		if (switch_from_server_to_client(ctdb, "log-collector") != 0) {
 			DEBUG(DEBUG_CRIT, (__location__ "ERROR: failed to switch log collector child into client mode.\n"));
 			_exit(1);
 		}
diff --git a/config/events.d/11.natgw b/config/events.d/11.natgw
old mode 100644
new mode 100755
index a01984c..46de7fa
--- a/config/events.d/11.natgw
+++ b/config/events.d/11.natgw
@@ -69,6 +69,12 @@ case "$1" in
 		# This is the first node, set it up as the NAT GW
 		echo 1 >/proc/sys/net/ipv4/ip_forward
 		iptables -A POSTROUTING -t nat -s $CTDB_NATGW_PRIVATE_NETWORK -d ! $CTDB_NATGW_PRIVATE_NETWORK -j MASQUERADE
+
+		# block all incoming connections to the natgw address
+		CTDB_NATGW_PUBLIC_IP_HOST=`echo $CTDB_NATGW_PUBLIC_IP | sed -e "s/\/.*/\/32/"`
+		iptables -D INPUT -p tcp --syn -d $CTDB_NATGW_PUBLIC_IP_HOST -j REJECT 2>/dev/null
+		iptables -I INPUT -p tcp --syn -d $CTDB_NATGW_PUBLIC_IP_HOST -j REJECT 2>/dev/null
+
 		ip addr add $CTDB_NATGW_PUBLIC_IP dev $CTDB_NATGW_PUBLIC_IFACE
 		ip route add 0.0.0.0/0 via $CTDB_NATGW_DEFAULT_GATEWAY >/dev/null 2>/dev/null
 	else
diff --git a/include/ctdb_client.h b/include/ctdb_client.h
index 3029d0f..8fedfde 100644
--- a/include/ctdb_client.h
+++ b/include/ctdb_client.h
@@ -551,7 +551,8 @@ int ctdb_transaction_commit(struct ctdb_transaction_handle *h);
 
 int ctdb_ctrl_recd_ping(struct ctdb_context *ctdb);
 
-int switch_from_server_to_client(struct ctdb_context *ctdb);
+int switch_from_server_to_client(struct ctdb_context *ctdb, const char *fmt,
+				 ...);
 
 int ctdb_ctrl_getscriptstatus(struct ctdb_context *ctdb,
 		    struct timeval timeout, uint32_t destnode,
diff --git a/include/ctdb_private.h b/include/ctdb_private.h
index 8166e15..66558d4 100644
--- a/include/ctdb_private.h
+++ b/include/ctdb_private.h
@@ -457,6 +457,8 @@ struct ctdb_context {
 
 	TALLOC_CTX *banning_ctx;
 
+	struct ctdb_vacuum_child_context *vacuumers;
+
 	/* mapping from pid to ctdb_client * */
 	struct ctdb_client_pid_list *client_pids;
 
@@ -1305,6 +1307,7 @@ int ctdb_ctrl_report_recd_lock_latency(struct ctdb_context *ctdb, struct timeval
 int32_t ctdb_control_stop_node(struct ctdb_context *ctdb, struct ctdb_req_control *c, bool *async_reply);
 int32_t ctdb_control_continue_node(struct ctdb_context *ctdb);
 
+void ctdb_stop_vacuuming(struct ctdb_context *ctdb);
 int ctdb_vacuum_init(struct ctdb_db_context *ctdb_db);
 
 int32_t ctdb_control_enable_script(struct ctdb_context *ctdb, TDB_DATA indata);
diff --git a/lib/util/debug.c b/lib/util/debug.c
index 1cbaa23..e9365d8 100644
--- a/lib/util/debug.c
+++ b/lib/util/debug.c
@@ -42,13 +42,15 @@ static void _do_debug_v(const char *format, va_list ap)
 
 	strftime(tbuf,sizeof(tbuf)-1,"%Y/%m/%d %H:%M:%S", tm);
 
-	fprintf(stderr, "%s.%06u [%5u]: %s", tbuf, (unsigned)t.tv_usec, (unsigned)getpid(), s);
+	fprintf(stderr, "%s.%06u [%s%5u]: %s", tbuf, (unsigned)t.tv_usec,
+		debug_extra, (unsigned)getpid(), s);
 	fflush(stderr);
 	free(s);
 }
 
 /* default logging function */
 void (*do_debug_v)(const char *, va_list ap) = _do_debug_v;
+const char *debug_extra = "";
 
 void do_debug(const char *format, ...)
 {
diff --git a/lib/util/debug.h b/lib/util/debug.h
index 11ecb19..27490a3 100644
--- a/lib/util/debug.h
+++ b/lib/util/debug.h
@@ -18,6 +18,7 @@
 */
 
 void (*do_debug_v)(const char *, va_list ap);
+const char *debug_extra;
 void (*do_debug_add_v)(const char *, va_list ap);
 void log_ringbuffer(const char *format, ...);
 void do_debug(const char *format, ...) PRINTF_ATTRIBUTE(1, 2);
diff --git a/server/ctdb_freeze.c b/server/ctdb_freeze.c
index 924a713..86cb5ed 100644
--- a/server/ctdb_freeze.c
+++ b/server/ctdb_freeze.c
@@ -202,6 +202,7 @@ static struct ctdb_freeze_handle *ctdb_freeze_lock(struct ctdb_context *ctdb, ui
 		/* in the child */
 		close(fd[0]);
 
+		debug_extra = talloc_asprintf(NULL, "freeze_lock-%u:", priority);
 		ret = ctdb_lock_all_databases(ctdb, priority);
 		if (ret != 0) {
 			_exit(0);
@@ -273,6 +274,9 @@ int ctdb_start_freeze(struct ctdb_context *ctdb, uint32_t priority)
 		return 0;
 	}
 
+	/* Stop any vacuuming going on: we don't want to wait. */
+	ctdb_stop_vacuuming(ctdb);
+
 	/* if there isn't a freeze lock child then create one */
 	if (ctdb->freeze_handles[priority] == NULL) {
 		ctdb->freeze_handles[priority] = ctdb_freeze_lock(ctdb, priority);
diff --git a/server/ctdb_lockwait.c b/server/ctdb_lockwait.c
index de80218..9c96bfb 100644
--- a/server/ctdb_lockwait.c
+++ b/server/ctdb_lockwait.c
@@ -136,6 +136,7 @@ struct lockwait_handle *ctdb_lockwait(struct ctdb_db_context *ctdb_db,
 	if (result->child == 0) {
 		char c = 0;
 		close(result->fd[0]);
+		debug_extra = talloc_asprintf(NULL, "chainlock-%s:", ctdb_db->db_name);
 		tdb_chainlock(ctdb_db->ltdb->tdb, key);
 		write(result->fd[1], &c, 1);
 		/* make sure we die when our parent dies */
diff --git a/server/ctdb_logging.c b/server/ctdb_logging.c
index ee4499c..2cc0559 100644
--- a/server/ctdb_logging.c
+++ b/server/ctdb_logging.c
@@ -116,6 +116,7 @@ int start_syslog_daemon(struct ctdb_context *ctdb)
 		return 0;
 	}
 
+	debug_extra = talloc_asprintf(NULL, "syslogd:");
 	talloc_free(ctdb->ev);
 	ctdb->ev = event_context_init(NULL);
 	tevent_loop_allow_nesting(ctdb->ev);
@@ -217,15 +218,16 @@ static void ctdb_syslog_log(const char *format, va_list ap)
 		break;		
 	}
 
-	len = offsetof(struct syslog_message, message) + strlen(s) + 1;
+	len = offsetof(struct syslog_message, message) + strlen(debug_extra) + strlen(s) + 1;
 	msg = malloc(len);
 	if (msg == NULL) {
 		free(s);
 		return;
 	}
 	msg->level = level;
-	msg->len   = strlen(s);
-	strcpy(msg->message, s);
+	msg->len   = strlen(debug_extra) + strlen(s);
+	strcpy(msg->message, debug_extra);
+	strcat(msg->message, s);
 
 	if (syslogd_is_started == 0) {
 		syslog(msg->level, "%s", msg->message);
@@ -279,8 +281,9 @@ static void ctdb_logfile_log(const char *format, va_list ap)
 
 	strftime(tbuf,sizeof(tbuf)-1,"%Y/%m/%d %H:%M:%S", tm);
 
-	ret = asprintf(&s2, "%s.%06u [%5u]: %s",
-		 tbuf, (unsigned)t.tv_usec, (unsigned)getpid(), s);
+	ret = asprintf(&s2, "%s.%06u [%s%5u]: %s",
+		       tbuf, (unsigned)t.tv_usec,
+		       debug_extra, (unsigned)getpid(), s);
 	free(s);
 	if (ret == -1) {
 		const char *errstr = "asprintf failed\n";
diff --git a/server/ctdb_monitor.c b/server/ctdb_monitor.c
index d025706..5cc4608 100644
--- a/server/ctdb_monitor.c
+++ b/server/ctdb_monitor.c
@@ -91,6 +91,7 @@ void ctdb_run_notification_script(struct ctdb_context *ctdb, const char *event)
 	if (child == 0) {
 		int ret;
 
+		debug_extra = talloc_asprintf(NULL, "notification-%s:", event);
 		ret = ctdb_run_notification_script_child(ctdb, event);
 		if (ret != 0) {
 			DEBUG(DEBUG_ERR,(__location__ " Notification script failed\n"));
diff --git a/server/ctdb_persistent.c b/server/ctdb_persistent.c
index 1d5ab35..dc05cbf 100644
--- a/server/ctdb_persistent.c
+++ b/server/ctdb_persistent.c
@@ -543,6 +543,7 @@ struct childwrite_handle *ctdb_childwrite(struct ctdb_db_context *ctdb_db,
 		char c = 0;
 
 		close(result->fd[0]);
+		debug_extra = talloc_asprintf(NULL, "childwrite-%s:", ctdb_db->db_name);
 		ret = ctdb_persistent_store(state);
 		if (ret != 0) {
 			DEBUG(DEBUG_ERR, (__location__ " Failed to write persistent data\n"));
diff --git a/server/ctdb_recover.c b/server/ctdb_recover.c
index 33a543e..e1c7b16 100644
--- a/server/ctdb_recover.c
+++ b/server/ctdb_recover.c
@@ -725,6 +725,7 @@ int32_t ctdb_control_set_recmode(struct ctdb_context *ctdb,
 		char cc = 0;
 		close(state->fd[0]);
 
+		debug_extra = talloc_asprintf(NULL, "set_recmode:");
 		/* we should not be able to get the lock on the reclock file, 
 		  as it should  be held by the recovery master 
 		*/
diff --git a/server/ctdb_recoverd.c b/server/ctdb_recoverd.c
index dc1a59d..437e4cb 100644
--- a/server/ctdb_recoverd.c
+++ b/server/ctdb_recoverd.c
@@ -2774,6 +2774,7 @@ static int check_recovery_lock(struct ctdb_context *ctdb)
 		close(state->fd[0]);
 		state->fd[0] = -1;
 
+		debug_extra = talloc_asprintf(NULL, "recovery-lock:");
 		if (pread(ctdb->recovery_lock_fd, &cc, 1, 0) == -1) {
 			DEBUG(DEBUG_CRIT,("failed read from recovery_lock_fd - %s\n", strerror(errno)));
 			cc = RECLOCK_FAILED;
@@ -3584,7 +3585,7 @@ int ctdb_start_recoverd(struct ctdb_context *ctdb)
 
 	srandom(getpid() ^ time(NULL));
 
-	if (switch_from_server_to_client(ctdb) != 0) {
+	if (switch_from_server_to_client(ctdb, "recoverd") != 0) {
 		DEBUG(DEBUG_CRIT, (__location__ "ERROR: failed to switch recovery daemon into client mode. shutting down.\n"));
 		exit(1);
 	}
diff --git a/server/ctdb_takeover.c b/server/ctdb_takeover.c
index cc801b1..44a68ee 100644
--- a/server/ctdb_takeover.c
+++ b/server/ctdb_takeover.c
@@ -2283,7 +2283,8 @@ static void tickle_connection_traverse(void *param, void *data)
 
 	/* have tried too many times, just give up */
 	if (con->count >= 5) {
-		talloc_free(con);
+		/* can't delete in traverse: reparent to delete_cons */
+		talloc_steal(param, con);
 		return;
 	}
 
@@ -2303,11 +2304,13 @@ static void ctdb_tickle_sentenced_connections(struct event_context *ev, struct t
 					      struct timeval t, void *private_data)
 {
 	struct ctdb_kill_tcp *killtcp = talloc_get_type(private_data, struct ctdb_kill_tcp);
-
+	void *delete_cons = talloc_new(NULL);
 
 	/* loop over all connections sending tickle ACKs */
-	trbt_traversearray32(killtcp->connections, KILLTCP_KEYLEN, tickle_connection_traverse, NULL);
+	trbt_traversearray32(killtcp->connections, KILLTCP_KEYLEN, tickle_connection_traverse, delete_cons);
 
+	/* now we've finished traverse, it's safe to do deletion. */
+	talloc_free(delete_cons);
 
 	/* If there are no more connections to kill we can remove the
 	   entire killtcp structure
diff --git a/server/ctdb_traverse.c b/server/ctdb_traverse.c
index e4e1050..b30af7e 100644
--- a/server/ctdb_traverse.c
+++ b/server/ctdb_traverse.c
@@ -171,6 +171,8 @@ static struct ctdb_traverse_local_handle *ctdb_traverse_local(struct ctdb_db_con
 	if (h->child == 0) {
 		/* start the traverse in the child */
 		close(h->fd[0]);
+		debug_extra = talloc_asprintf(NULL, "traverse_local-%s:",
+					      ctdb_db->db_name);
 		tdb_traverse_read(ctdb_db->ltdb->tdb, ctdb_traverse_local_fn, h);
 		_exit(0);
 	}
diff --git a/server/ctdb_vacuum.c b/server/ctdb_vacuum.c
index 9ec8b31..dc26d08 100644
--- a/server/ctdb_vacuum.c
+++ b/server/ctdb_vacuum.c
@@ -36,7 +36,9 @@
 enum vacuum_child_status { VACUUM_RUNNING, VACUUM_OK, VACUUM_ERROR, VACUUM_TIMEOUT};
 
 struct ctdb_vacuum_child_context {
+	struct ctdb_vacuum_child_context *next, *prev;
 	struct ctdb_vacuum_handle *vacuum_handle;
+	/* fd child writes status to */
 	int fd[2];
 	pid_t child_pid;
 	enum vacuum_child_status status;
@@ -634,6 +636,7 @@ static int ctdb_repack_db(struct ctdb_db_context *ctdb_db, TALLOC_CTX *mem_ctx)
 	vdata->vacuum_limit = vacuum_limit;
 	vdata->repack_limit = repack_limit;
 	vdata->delete_tree = trbt_create(vdata, 0);
+	vdata->ctdb_db = ctdb_db;
 	if (vdata->delete_tree == NULL) {
 		DEBUG(DEBUG_ERR,(__location__ " Out of memory\n"));
 		talloc_free(vdata);
@@ -743,6 +746,8 @@ static int vacuum_child_destructor(struct ctdb_vacuum_child_context *child_ctx)
 		kill(child_ctx->child_pid, SIGKILL);
 	}
 
+	DLIST_REMOVE(ctdb->vacuumers, child_ctx);
+
 	event_add_timed(ctdb->ev, child_ctx->vacuum_handle,
 			timeval_current_ofs(get_vacuum_interval(ctdb_db), 0), 
 			ctdb_vacuum_event, child_ctx->vacuum_handle);
@@ -804,8 +809,14 @@ ctdb_vacuum_event(struct event_context *ev, struct timed_event *te,
 	struct tevent_fd *fde;
 	int ret;
 
-	/* we dont vacuum if we are in recovery mode */
-	if (ctdb->recovery_mode == CTDB_RECOVERY_ACTIVE) {
+	/* we dont vacuum if we are in recovery mode, or db frozen */
+	if (ctdb->recovery_mode == CTDB_RECOVERY_ACTIVE ||
+	    ctdb->freeze_mode[ctdb_db->priority] != CTDB_FREEZE_NONE) {
+		DEBUG(DEBUG_INFO, ("Not vacuuming %s (%s)\n", ctdb_db->db_name,
+				   ctdb->recovery_mode == CTDB_RECOVERY_ACTIVE ? "in recovery"
+				   : ctdb->freeze_mode[ctdb_db->priority] == CTDB_FREEZE_PENDING
+				   ? "freeze pending"
+				   : "frozen"));
 		event_add_timed(ctdb->ev, vacuum_handle, timeval_current_ofs(ctdb->tunable.vacuum_default_interval, 0), ctdb_vacuum_event, vacuum_handle);
 		return;
 	}
@@ -842,7 +853,7 @@ ctdb_vacuum_event(struct event_context *ev, struct timed_event *te,
 
 		DEBUG(DEBUG_INFO,("Vacuuming child process %d for db %s started\n", getpid(), ctdb_db->db_name));
 	
-		if (switch_from_server_to_client(ctdb) != 0) {
+		if (switch_from_server_to_client(ctdb, "vacuum-%s", ctdb_db->db_name) != 0) {
 			DEBUG(DEBUG_CRIT, (__location__ "ERROR: failed to switch vacuum daemon into client mode. Shutting down.\n"));
 			_exit(1);
 		}
@@ -862,6 +873,7 @@ ctdb_vacuum_event(struct event_context *ev, struct timed_event *te,
 	child_ctx->status = VACUUM_RUNNING;
 	child_ctx->start_time = timeval_current();
 
+	DLIST_ADD(ctdb->vacuumers, child_ctx);
 	talloc_set_destructor(child_ctx, vacuum_child_destructor);
 
 	event_add_timed(ctdb->ev, child_ctx,
@@ -878,6 +890,17 @@ ctdb_vacuum_event(struct event_context *ev, struct timed_event *te,
 	child_ctx->vacuum_handle = vacuum_handle;
 }
 
+void ctdb_stop_vacuuming(struct ctdb_context *ctdb)
+{
+	/* Simply free them all. */
+	while (ctdb->vacuumers) {
+		DEBUG(DEBUG_INFO, ("Aborting vacuuming for %s (%i)\n",
+			   ctdb->vacuumers->vacuum_handle->ctdb_db->db_name,
+			   (int)ctdb->vacuumers->child_pid));
+		/* vacuum_child_destructor kills it, removes from list */
+		talloc_free(ctdb->vacuumers);
+	}
+}
 
 /* this function initializes the vacuuming context for a database
  * starts the vacuuming events
diff --git a/server/eventscript.c b/server/eventscript.c
index aa8556d..139f59f 100644
--- a/server/eventscript.c
+++ b/server/eventscript.c
@@ -386,6 +386,9 @@ static int fork_child_for_script(struct ctdb_context *ctdb,
 	if (state->child == 0) {
 		int rt;
 
+		debug_extra = talloc_asprintf(NULL, "eventscript-%s-%s:",
+					      current->name,
+					      ctdb_eventscript_call_names[state->call]);
 		close(state->fd[0]);
 		set_close_on_exec(state->fd[1]);
 


-- 
CTDB repository


More information about the samba-cvs mailing list