Merge commit 'origin/master'
authorMartin Schwenke <martin@meltin.net>
Wed, 11 Nov 2009 01:16:30 +0000 (12:16 +1100)
committerMartin Schwenke <martin@meltin.net>
Wed, 11 Nov 2009 01:16:30 +0000 (12:16 +1100)
36 files changed:
Makefile.in
client/ctdb_client.c
common/ctdb_io.c
config/ctdb.init
config/ctdb.sysconfig
config/events.d/10.interface
config/events.d/99.timeout [new file with mode: 0755]
config/functions
doc/ctdb.1
doc/ctdb.1.html
doc/ctdb.1.xml
include/ctdb.h
include/ctdb_private.h
lib/events/events_epoll.c
lib/events/events_select.c
lib/events/events_standard.c
packaging/RPM/ctdb.spec.in [moved from packaging/RPM/ctdb.spec with 90% similarity]
packaging/RPM/makerpms.sh
server/ctdb_call.c
server/ctdb_control.c
server/ctdb_daemon.c
server/ctdb_logging.c
server/ctdb_ltdb_server.c
server/ctdb_monitor.c
server/ctdb_persistent.c
server/ctdb_recover.c
server/ctdb_recoverd.c
server/ctdb_takeover.c
server/ctdb_tunables.c
server/ctdb_vacuum.c
server/ctdbd.c
server/eventscript.c
tcp/tcp_connect.c
tests/src/ctdb_transaction.c
tools/ctdb.c
tools/ctdb_diagnostics

index 88f6eaef937b838342c7e102f1d1f6ad5b63136b..4b2d1007fd4c8c2bb3cd885d97093e1b83cff501 100755 (executable)
@@ -211,7 +211,7 @@ install: all
        ${INSTALLCMD} -m 755 config/events.d/10.interface $(DESTDIR)$(etcdir)/ctdb/events.d
        ${INSTALLCMD} -m 755 config/events.d/11.natgw $(DESTDIR)$(etcdir)/ctdb/events.d
        ${INSTALLCMD} -m 755 config/events.d/11.routing $(DESTDIR)$(etcdir)/ctdb/events.d
-       ${INSTALLCMD} -m 755 config/events.d/20.multipathd $(DESTDIR)$(etcdir)/ctdb/events.d
+       ${INSTALLCMD} -m 644 config/events.d/20.multipathd $(DESTDIR)$(etcdir)/ctdb/events.d
        ${INSTALLCMD} -m 644 config/events.d/31.clamd $(DESTDIR)$(etcdir)/ctdb/events.d
        ${INSTALLCMD} -m 755 config/events.d/40.vsftpd $(DESTDIR)$(etcdir)/ctdb/events.d
        ${INSTALLCMD} -m 755 config/events.d/41.httpd $(DESTDIR)$(etcdir)/ctdb/events.d
index 0948d4118a52d305a72fc017348b98a5346ec781..3e6b833d672ee7322d723a9274b741392a567db1 100644 (file)
@@ -30,6 +30,8 @@
 #include "../include/ctdb_private.h"
 #include "lib/util/dlinklist.h"
 
+pid_t ctdbd_pid;
+
 /*
   allocate a packet for use in client<->daemon communication
  */
@@ -764,7 +766,9 @@ static void control_timeout_func(struct event_context *ev, struct timed_event *t
 {
        struct ctdb_client_control_state *state = talloc_get_type(private_data, struct ctdb_client_control_state);
 
-       DEBUG(DEBUG_ERR,("control timed out. reqid:%d opcode:%d dstnode:%d\n", state->reqid, state->c->opcode, state->c->hdr.destnode));
+       DEBUG(DEBUG_ERR,(__location__ " control timed out. reqid:%u opcode:%u "
+                        "dstnode:%u\n", state->reqid, state->c->opcode,
+                        state->c->hdr.destnode));
 
        state->state = CTDB_CONTROL_TIMEOUT;
 
@@ -2386,7 +2390,7 @@ int ctdb_ctrl_modflags(struct ctdb_context *ctdb, struct timeval timeout, uint32
                                        timeout, false, data,
                                        NULL, NULL,
                                        NULL) != 0) {
-               DEBUG(DEBUG_ERR, (__location__ " ctdb_control to disable node failed\n"));
+               DEBUG(DEBUG_ERR, (__location__ " Unable to update nodeflags on remote nodes\n"));
 
                talloc_free(tmp_ctx);
                return -1;
@@ -3139,12 +3143,42 @@ int ctdb_ctrl_getcapabilities(struct ctdb_context *ctdb, struct timeval timeout,
        return ret;
 }
 
+/**
+ * check whether a transaction is active on a given db on a given node
+ */
+static int32_t ctdb_ctrl_transaction_active(struct ctdb_context *ctdb,
+                                           uint32_t destnode,
+                                           uint32_t db_id)
+{
+       int32_t status;
+       int ret;
+       TDB_DATA indata;
+
+       indata.dptr = (uint8_t *)&db_id;
+       indata.dsize = sizeof(db_id);
+
+       ret = ctdb_control(ctdb, destnode, 0,
+                          CTDB_CONTROL_TRANS2_ACTIVE,
+                          0, indata, NULL, NULL, &status,
+                          NULL, NULL);
+
+       if (ret != 0) {
+               DEBUG(DEBUG_ERR, (__location__ " ctdb control for transaction_active failed\n"));
+               return -1;
+       }
+
+       return status;
+}
+
+
 struct ctdb_transaction_handle {
        struct ctdb_db_context *ctdb_db;
        bool in_replay;
-       /* we store the reads and writes done under a transaction one
-          list stores both reads and writes, the other just writes
-       */
+       /*
+        * we store the reads and writes done under a transaction:
+        * - one list stores both reads and writes (m_all),
+        * - the other just writes (m_write)
+        */
        struct ctdb_marshall_buffer *m_all;
        struct ctdb_marshall_buffer *m_write;
 };
@@ -3168,6 +3202,7 @@ static int ctdb_transaction_fetch_start(struct ctdb_transaction_handle *h)
        int ret;
        struct ctdb_db_context *ctdb_db = h->ctdb_db;
        pid_t pid;
+       int32_t status;
 
        key.dptr = discard_const(keyname);
        key.dsize = strlen(keyname);
@@ -3182,10 +3217,25 @@ again:
 
        rh = ctdb_fetch_lock(ctdb_db, tmp_ctx, key, NULL);
        if (rh == NULL) {
-               DEBUG(DEBUG_ERR,(__location__ " Failed to fetch_lock database\n"));             
+               DEBUG(DEBUG_ERR,(__location__ " Failed to fetch_lock database\n"));
                talloc_free(tmp_ctx);
                return -1;
        }
+
+       status = ctdb_ctrl_transaction_active(ctdb_db->ctdb,
+                                             CTDB_CURRENT_NODE,
+                                             ctdb_db->db_id);
+       if (status == 1) {
+               unsigned long int usec = (1000 + random()) % 100000;
+               DEBUG(DEBUG_NOTICE, (__location__ " transaction is active "
+                                    "on db_id[0x%08x]. waiting for %lu "
+                                    "microseconds\n",
+                                    ctdb_db->db_id, usec));
+               talloc_free(tmp_ctx);
+               usleep(usec);
+               goto again;
+       }
+
        /*
         * store the pid in the database:
         * it is not enough that the node is dmaster...
@@ -3451,6 +3501,9 @@ again:
                           &timeout, NULL);
        if (ret != 0 || status != 0) {
                tdb_transaction_cancel(h->ctdb_db->ltdb->tdb);
+               DEBUG(DEBUG_WARNING, (__location__ " transaction commit%s failed"
+                                     ", retrying after 1 second...\n",
+                                     (retries==0)?"":"retry "));
                sleep(1);
 
                if (ret != 0) {
index ea7c17d01989d980c0524ed72ddcb741ed310dc9..99180ce926fec5b0812249da9e23841950a9e940 100644 (file)
@@ -46,6 +46,7 @@ struct ctdb_queue {
        struct ctdb_context *ctdb;
        struct ctdb_partial partial; /* partial input packet */
        struct ctdb_queue_pkt *out_queue;
+       uint32_t out_queue_length;
        struct fd_event *fde;
        int fd;
        size_t alignment;
@@ -57,12 +58,7 @@ struct ctdb_queue {
 
 int ctdb_queue_length(struct ctdb_queue *queue)
 {
-       int i;
-       struct ctdb_queue_pkt *pkt;
-
-       for(i=0, pkt=queue->out_queue;pkt;i++,pkt=pkt->next);
-
-       return i;
+       return queue->out_queue_length;
 }
 
 /*
@@ -188,6 +184,7 @@ static void queue_io_write(struct ctdb_queue *queue)
                        if (pkt->length != pkt->full_length) {
                                /* partial packet sent - we have to drop it */
                                DLIST_REMOVE(queue->out_queue, pkt);
+                               queue->out_queue_length--;
                                talloc_free(pkt);
                        }
                        talloc_free(queue->fde);
@@ -206,6 +203,7 @@ static void queue_io_write(struct ctdb_queue *queue)
                }
 
                DLIST_REMOVE(queue->out_queue, pkt);
+               queue->out_queue_length--;
                talloc_free(pkt);
        }
 
@@ -286,6 +284,7 @@ int ctdb_queue_send(struct ctdb_queue *queue, uint8_t *data, uint32_t length)
        }
 
        DLIST_ADD_END(queue->out_queue, pkt, struct ctdb_queue_pkt *);
+       queue->out_queue_length++;
 
        if (queue->ctdb->tunable.verbose_memory_names != 0) {
                struct ctdb_req_header *hdr = (struct ctdb_req_header *)pkt->data;
index df333b222a9a5b4a46b0ec2818652e83abb03805..67747fd149da73f95a2d84d146b5fa4d1249cbdf 100755 (executable)
@@ -144,6 +144,12 @@ start() {
 
     check_persistent_databases || return $?
 
+    if [ yes == "$CTDB_SUPPRESS_COREFILE" ]; then
+       ulimit -c 0
+    else
+       ulimit -c unlimited
+    fi
+
     case $init_style in
        valgrind)
            valgrind -q --log-file=/var/log/ctdb_valgrind \
index ca2b63fad157e99fc8c27690cd8a8b86bac0acf9..e6c7b4f2cccf869b8ed683231f4704ff2327ba98 100644 (file)
@@ -187,10 +187,19 @@ CTDB_RECOVERY_LOCK="/some/place/on/shared/storage"
 # the default is ERR
 CTDB_DEBUGLEVEL=ERR
 
+# whether to suppress core files.  Default is no.
+# CTDB_SUPPRESS_COREFILE=yes
+
 # Write debug messages to syslog instead of logfile?
 # The default is not to use syslog.
 # CTDB_SYSLOG=no
 
+# Should the 99.timeout monitor event script be run?
+# This event script just sleeps long enough to trigger the
+# event script timeout. Might be useful for debugging.
+# The default is "no".
+# CTDB_RUN_TIMEOUT_MONITOR=no
+
 # set any default tuning options for ctdb
 # use CTDB_SET_XXXX=value where XXXX is the name of the tuning
 # variable
@@ -198,7 +207,6 @@ CTDB_DEBUGLEVEL=ERR
 #    CTDB_SET_TRAVERSETIMEOUT=60
 # you can get a list of variables using "ctdb listvars"
 
-
 # any other options you might want. Run ctdbd --help for a list
 # CTDB_OPTIONS=
 
index 61f7148236996e87bd9ac715d501f018a73f0467..9a02b15fd938fcb5090faf71b2f091d21b985f58 100755 (executable)
@@ -147,6 +147,10 @@ case $cmd in
            case $IFACE in 
            ethX*|bond*)
                IFACE=`echo $IFACE |sed -e 's/\....$//'`
+               grep -q 'Currently Active Slave: None' /proc/net/bonding/$IFACE && {
+                       echo "ERROR: No active slaves for bond device $IFACE"
+                       exit 1
+               }
                grep -q '^MII Status: up' /proc/net/bonding/$IFACE || {
                        echo "ERROR: public network interface $IFACE is down"
                        exit 1
diff --git a/config/events.d/99.timeout b/config/events.d/99.timeout
new file mode 100755 (executable)
index 0000000..9ef24e6
--- /dev/null
@@ -0,0 +1,24 @@
+#!/bin/sh
+#
+# Event script to just sleep longer than the timeout
+# in the monitor action. The purpose is to trigger
+# the event timeout mechanism.
+
+. $CTDB_BASE/functions
+loadconfig ctdb
+
+[ "x$CTDB_RUN_TIMEOUT_MONITOR" = "xyes" ] || exit 0
+
+cmd="$1"
+shift
+
+case $cmd in
+       monitor)
+               TIMEOUT=$(ctdb listvars | grep EventScriptTimeout | awk '{print $3}')
+               echo "sleeping for $((TIMEOUT * 2)) seconds..."
+               sleep $((TIMEOUT * 2))
+               ;;
+esac
+
+exit 0
+
index 1d1d0548d60f1e08a3c726e1800a9d0efacca060..043051b23ec92768e9638e28933f93091e7b1cbd 100644 (file)
@@ -318,8 +318,8 @@ kill_tcp_connections() {
        echo "Killing TCP connection $srcip:$srcport $destip:$destport"
        ctdb killtcp $srcip:$srcport $destip:$destport >/dev/null 2>&1 || _failed=1
        case $destport in
-         # we only do one-way killtcp for NFS and CIFS
-         139|445|2049) : ;;
+         # we only do one-way killtcp for CIFS
+         139|445) : ;;
          # for all others we do 2-way
          *) 
                ctdb killtcp $destip:$destport $srcip:$srcport >/dev/null 2>&1 || _failed=1
index 0b59cf60a20c17e95496de295e775d9f5dd47b23..fa9482feb6876891c7eac81c7e94abfa455d7df6 100644 (file)
@@ -1,11 +1,11 @@
 .\"     Title: ctdb
 .\"    Author: 
 .\" Generator: DocBook XSL Stylesheets v1.73.2 <http://docbook.sf.net/>
-.\"      Date: 08/13/2009
+.\"      Date: 10/29/2009
 .\"    Manual: 
 .\"    Source: 
 .\"
-.TH "CTDB" "1" "08/13/2009" "" ""
+.TH "CTDB" "1" "10/29/2009" "" ""
 .\" disable hyphenation
 .nh
 .\" disable justification (adjust text to left margin only)
@@ -178,7 +178,7 @@ Recovery master:0
 This command shows the pnn of the node which is currently the recmaster\.
 .SS "uptime"
 .PP
-This command shows the uptime for the ctdb daemon\. When the last recovery completed and how long the last recovery took\. If the "duration" is shown as a negative number, this indicates that there is a recovery in progress and it started that many seconds ago\.
+This command shows the uptime for the ctdb daemon\. When the last recovery or ip\-failover completed and how long it took\. If the "duration" is shown as a negative number, this indicates that there is a recovery/failover in progress and it started that many seconds ago\.
 .PP
 Example: ctdb uptime
 .PP
@@ -186,10 +186,10 @@ Example output:
 .sp
 .RS 4
 .nf
-Current time of node  : Tue Mar 24 18:27:54 2009
-Ctdbd start time      : (000 00:00:05) Tue Mar 24 18:27:49 2009
-Time of last recovery : (000 00:00:05) Tue Mar 24 18:27:49 2009
-Duration of last recovery : 0\.000000 seconds
+Current time of node          :                Thu Oct 29 10:38:54 2009
+Ctdbd start time              : (000 16:54:28) Wed Oct 28 17:44:26 2009
+Time of last recovery/failover: (000 16:53:31) Wed Oct 28 17:45:23 2009
+Duration of last recovery/failover: 2\.248552 seconds
       
 .fi
 .RE
index e4c58dd269cd06669b4b7694bcbaa74bcc7a5915..46de1b6f38af225e5a69c2332500b9f1b25be8ce 100644 (file)
@@ -1,6 +1,6 @@
-<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>ctdb</title><meta name="generator" content="DocBook XSL Stylesheets V1.73.2"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="refentry" lang="en"><a name="ctdb.1"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ctdb &#8212; clustered tdb database management utility</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="cmdsynopsis"><p><code class="command">ctdb [ OPTIONS ] COMMAND ...</code> </p></div><div class="cmdsynopsis"><p><code class="command">ctdb</code>  [-n &lt;node&gt;] [-Y] [-t &lt;timeout&gt;] [-T &lt;timelimit&gt;] [-? --help] [--usage] [-d --debug=&lt;INTEGER&gt;] [--socket=&lt;filename&gt;]</p></div></div><div class="refsect1" lang="en"><a name="id2478257"></a><h2>DESCRIPTION</h2><p>
+<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>ctdb</title><meta name="generator" content="DocBook XSL Stylesheets V1.73.2"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="refentry" lang="en"><a name="ctdb.1"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ctdb &#8212; clustered tdb database management utility</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="cmdsynopsis"><p><code class="command">ctdb [ OPTIONS ] COMMAND ...</code> </p></div><div class="cmdsynopsis"><p><code class="command">ctdb</code>  [-n &lt;node&gt;] [-Y] [-t &lt;timeout&gt;] [-T &lt;timelimit&gt;] [-? --help] [--usage] [-d --debug=&lt;INTEGER&gt;] [--socket=&lt;filename&gt;]</p></div></div><div class="refsect1" lang="en"><a name="id2478395"></a><h2>DESCRIPTION</h2><p>
       ctdb is a utility to view and manage a ctdb cluster.
-    </p></div><div class="refsect1" lang="en"><a name="id2478267"></a><h2>OPTIONS</h2><div class="variablelist"><dl><dt><span class="term">-n &lt;pnn&gt;</span></dt><dd><p>
+    </p></div><div class="refsect1" lang="en"><a name="id2478405"></a><h2>OPTIONS</h2><div class="variablelist"><dl><dt><span class="term">-n &lt;pnn&gt;</span></dt><dd><p>
             This specifies the physical node number on which to execute the 
            command. Default is to run the command on the deamon running on 
            the local host.
             You only need to specify this parameter if you run multiple ctdb 
             daemons on the same physical host and thus can not use the default
             name for the domain socket.
-          </p></dd></dl></div></div><div class="refsect1" lang="en"><a name="id2478404"></a><h2>Administrative Commands</h2><p>
+          </p></dd></dl></div></div><div class="refsect1" lang="en"><a name="id2479674"></a><h2>Administrative Commands</h2><p>
       These are commands used to monitor and administrate a CTDB cluster.
-    </p><div class="refsect2" lang="en"><a name="id2478413"></a><h3>pnn</h3><p>
+    </p><div class="refsect2" lang="en"><a name="id2479683"></a><h3>pnn</h3><p>
         This command displays the pnn of the current node.
-      </p></div><div class="refsect2" lang="en"><a name="id2478423"></a><h3>status</h3><p>
+      </p></div><div class="refsect2" lang="en"><a name="id2479693"></a><h3>status</h3><p>
         This command shows the current status of the ctdb node.
-      </p><div class="refsect3" lang="en"><a name="id2478621"></a><h4>node status</h4><p>
+      </p><div class="refsect3" lang="en"><a name="id2479702"></a><h4>node status</h4><p>
           Node status reflects the current status of the node. There are five possible states:
         </p><p>
           OK - This node is fully functional.
@@ -52,7 +52,7 @@
       RECMASTER or NATGW.
       This node does not perticipate in the CTDB cluster but can still be
       communicated with. I.e. ctdb commands can be sent to it.
-        </p></div><div class="refsect3" lang="en"><a name="id2478682"></a><h4>generation</h4><p>
+        </p></div><div class="refsect3" lang="en"><a name="id2479763"></a><h4>generation</h4><p>
           The generation id is a number that indicates the current generation 
           of a cluster instance. Each time a cluster goes through a 
           reconfiguration or a recovery its generation id will be changed.
          All nodes start with generation "INVALID" and are not assigned a real
          generation id until they have successfully been merged with a cluster
          through a recovery.
-        </p></div><div class="refsect3" lang="en"><a name="id2478717"></a><h4>VNNMAP</h4><p>
+        </p></div><div class="refsect3" lang="en"><a name="id2479798"></a><h4>VNNMAP</h4><p>
           The list of Virtual Node Numbers. This is a list of all nodes that actively participates in the cluster and that share the workload of hosting the Clustered TDB database records.
           Only nodes that are participating in the vnnmap can become lmaster or dmaster for a database record.
-        </p></div><div class="refsect3" lang="en"><a name="id2478731"></a><h4>Recovery mode</h4><p>
+        </p></div><div class="refsect3" lang="en"><a name="id2479812"></a><h4>Recovery mode</h4><p>
           This is the current recovery mode of the cluster. There are two possible modes:
         </p><p>
           NORMAL - The cluster is fully operational.
@@ -96,7 +96,7 @@
        have been recovered, the node mode will change into NORMAL mode
        and the databases will be "thawed", allowing samba to access the
        databases again.
-       </p></div><div class="refsect3" lang="en"><a name="id2478773"></a><h4>Recovery master</h4><p>
+       </p></div><div class="refsect3" lang="en"><a name="id2528501"></a><h4>Recovery master</h4><p>
           This is the cluster node that is currently designated as the recovery master. This node is responsible of monitoring the consistency of the cluster and to perform the actual recovery process when reqired.
         </p><p>
        Only one node at a time can be the designated recovery master. Which
@@ -118,18 +118,18 @@ hash:2 lmaster:2
 hash:3 lmaster:3
 Recovery mode:NORMAL (0)
 Recovery master:0
-      </pre></div><div class="refsect2" lang="en"><a name="id2478810"></a><h3>recmaster</h3><p>
+      </pre></div><div class="refsect2" lang="en"><a name="id2528538"></a><h3>recmaster</h3><p>
         This command shows the pnn of the node which is currently the recmaster.
-      </p></div><div class="refsect2" lang="en"><a name="id2478821"></a><h3>uptime</h3><p>
-        This command shows the uptime for the ctdb daemon. When the last recovery completed and how long the last recovery took. If the "duration" is shown as a negative number, this indicates that there is a recovery in progress and it started that many seconds ago.
+      </p></div><div class="refsect2" lang="en"><a name="id2528549"></a><h3>uptime</h3><p>
+        This command shows the uptime for the ctdb daemon. When the last recovery or ip-failover completed and how long it took. If the "duration" is shown as a negative number, this indicates that there is a recovery/failover in progress and it started that many seconds ago.
       </p><p>
        Example: ctdb uptime
       </p><p>Example output:</p><pre class="screen">
-Current time of node  : Tue Mar 24 18:27:54 2009
-Ctdbd start time      : (000 00:00:05) Tue Mar 24 18:27:49 2009
-Time of last recovery : (000 00:00:05) Tue Mar 24 18:27:49 2009
-Duration of last recovery : 0.000000 seconds
-      </pre></div><div class="refsect2" lang="en"><a name="id2478851"></a><h3>listnodes</h3><p>
+Current time of node          :                Thu Oct 29 10:38:54 2009
+Ctdbd start time              : (000 16:54:28) Wed Oct 28 17:44:26 2009
+Time of last recovery/failover: (000 16:53:31) Wed Oct 28 17:45:23 2009
+Duration of last recovery/failover: 2.248552 seconds
+      </pre></div><div class="refsect2" lang="en"><a name="id2528580"></a><h3>listnodes</h3><p>
         This command shows lists the ip addresses of all the nodes in the cluster.
       </p><p>
        Example: ctdb listnodes
@@ -138,7 +138,7 @@ Duration of last recovery : 0.000000 seconds
 10.0.0.72
 10.0.0.73
 10.0.0.74
-      </pre></div><div class="refsect2" lang="en"><a name="id2478874"></a><h3>ping</h3><p>
+      </pre></div><div class="refsect2" lang="en"><a name="id2528604"></a><h3>ping</h3><p>
         This command will "ping" all CTDB daemons in the cluster to verify that they are processing commands correctly.
       </p><p>
        Example: ctdb ping
@@ -149,7 +149,7 @@ response from 0 time=0.000054 sec  (3 clients)
 response from 1 time=0.000144 sec  (2 clients)
 response from 2 time=0.000105 sec  (2 clients)
 response from 3 time=0.000114 sec  (2 clients)
-      </pre></div><div class="refsect2" lang="en"><a name="id2528491"></a><h3>ip</h3><p>
+      </pre></div><div class="refsect2" lang="en"><a name="id2528630"></a><h3>ip</h3><p>
         This command will display the list of public addresses that are provided by the cluster and which physical node is currently serving this ip. By default this command will ONLY show those public addresses that are known to the node itself. To see the full list of all public ips across the cluster you must use "ctdb ip -n all".
       </p><p>
        Example: ctdb ip
@@ -161,7 +161,7 @@ Number of addresses:4
 12.1.1.2         1
 12.1.1.3         2
 12.1.1.4         3
-      </pre></div><div class="refsect2" lang="en"><a name="id2528519"></a><h3>scriptstatus</h3><p>
+      </pre></div><div class="refsect2" lang="en"><a name="id2528658"></a><h3>scriptstatus</h3><p>
         This command displays which scripts where run in the previous monitoring cycle and the result of each script. If a script failed with an error, causing the node to become unhealthy, the output from that script is also shown.
       </p><p>
        Example: ctdb scriptstatus
@@ -178,15 +178,15 @@ Number of addresses:4
 41.httpd             Status:OK    Duration:0.039 Tue Mar 24 18:56:57 2009
 50.samba             Status:ERROR    Duration:0.082 Tue Mar 24 18:56:57 2009
    OUTPUT:ERROR: Samba tcp port 445 is not responding
-      </pre></div><div class="refsect2" lang="en"><a name="id2528555"></a><h3>disablescript &lt;script&gt;</h3><p>
+      </pre></div><div class="refsect2" lang="en"><a name="id2528694"></a><h3>disablescript &lt;script&gt;</h3><p>
        This command is used to disable an eventscript.
       </p><p>
        This will take effect the next time the eventscripts are being executed so it can take a short while until this is reflected in 'scriptstatus'.
-      </p></div><div class="refsect2" lang="en"><a name="id2528572"></a><h3>enablescript &lt;script&gt;</h3><p>
+      </p></div><div class="refsect2" lang="en"><a name="id2528711"></a><h3>enablescript &lt;script&gt;</h3><p>
        This command is used to enable an eventscript.
       </p><p>
        This will take effect the next time the eventscripts are being executed so it can take a short while until this is reflected in 'scriptstatus'.
-      </p></div><div class="refsect2" lang="en"><a name="id2528588"></a><h3>getvar &lt;name&gt;</h3><p>
+      </p></div><div class="refsect2" lang="en"><a name="id2528727"></a><h3>getvar &lt;name&gt;</h3><p>
         Get the runtime value of a tuneable variable.
       </p><p>
        Example: ctdb getvar MaxRedirectCount
@@ -194,11 +194,11 @@ Number of addresses:4
        Example output:
       </p><pre class="screen">
 MaxRedirectCount    = 3
-      </pre></div><div class="refsect2" lang="en"><a name="id2528611"></a><h3>setvar &lt;name&gt; &lt;value&gt;</h3><p>
+      </pre></div><div class="refsect2" lang="en"><a name="id2528750"></a><h3>setvar &lt;name&gt; &lt;value&gt;</h3><p>
         Set the runtime value of a tuneable variable.
       </p><p>
        Example: ctdb setvar MaxRedirectCount 5
-      </p></div><div class="refsect2" lang="en"><a name="id2528626"></a><h3>listvars</h3><p>
+      </p></div><div class="refsect2" lang="en"><a name="id2528765"></a><h3>listvars</h3><p>
         List all tuneable variables.
       </p><p>
        Example: ctdb listvars
@@ -220,7 +220,7 @@ MonitorInterval     = 15
 EventScriptTimeout  = 20
 RecoveryGracePeriod = 60
 RecoveryBanPeriod   = 300
-      </pre></div><div class="refsect2" lang="en"><a name="id2528654"></a><h3>lvsmaster</h3><p>
+      </pre></div><div class="refsect2" lang="en"><a name="id2528793"></a><h3>lvsmaster</h3><p>
       This command shows which node is currently the LVSMASTER. The
       LVSMASTER is the node in the cluster which drives the LVS system and
       which receives all incoming traffic from clients.
@@ -231,7 +231,7 @@ RecoveryBanPeriod   = 300
       evenly onto the other nodes in the cluster. This is an alternative to using
       public ip addresses. See the manpage for ctdbd for more information
       about LVS.
-      </p></div><div class="refsect2" lang="en"><a name="id2528676"></a><h3>lvs</h3><p>
+      </p></div><div class="refsect2" lang="en"><a name="id2528815"></a><h3>lvs</h3><p>
       This command shows which nodes in the cluster are currently active in the
       LVS configuration. I.e. which nodes we are currently loadbalancing
       the single ip address across.
@@ -246,7 +246,7 @@ RecoveryBanPeriod   = 300
       </p><pre class="screen">
 2:10.0.0.13
 3:10.0.0.14
-      </pre></div><div class="refsect2" lang="en"><a name="id2528706"></a><h3>getcapabilities</h3><p>
+      </pre></div><div class="refsect2" lang="en"><a name="id2528845"></a><h3>getcapabilities</h3><p>
       This command shows the capabilities of the current node.
       Please see manpage for ctdbd for a full list of all capabilities and
       more detailed description.
@@ -265,7 +265,7 @@ RecoveryBanPeriod   = 300
 RECMASTER: YES
 LMASTER: YES
 LVS: NO
-      </pre></div><div class="refsect2" lang="en"><a name="id2528742"></a><h3>statistics</h3><p>
+      </pre></div><div class="refsect2" lang="en"><a name="id2528881"></a><h3>statistics</h3><p>
         Collect statistics from the CTDB daemon about how many calls it has served.
       </p><p>
        Example: ctdb statistics
@@ -307,23 +307,23 @@ CTDB version 1
  max_hop_count                      0
  max_call_latency                   4.948321 sec
  max_lockwait_latency               0.000000 sec
-      </pre></div><div class="refsect2" lang="en"><a name="id2528786"></a><h3>statisticsreset</h3><p>
+      </pre></div><div class="refsect2" lang="en"><a name="id2528925"></a><h3>statisticsreset</h3><p>
         This command is used to clear all statistics counters in a node.
       </p><p>
        Example: ctdb statisticsreset
-      </p></div><div class="refsect2" lang="en"><a name="id2528800"></a><h3>getreclock</h3><p>
+      </p></div><div class="refsect2" lang="en"><a name="id2528939"></a><h3>getreclock</h3><p>
        This command is used to show the filename of the reclock file that is used.
       </p><p>
        Example output:
       </p><pre class="screen">
 Reclock file:/gpfs/.ctdb/shared
-      </pre></div><div class="refsect2" lang="en"><a name="id2528820"></a><h3>setreclock [filename]</h3><p>
+      </pre></div><div class="refsect2" lang="en"><a name="id2528959"></a><h3>setreclock [filename]</h3><p>
        This command is used to modify, or clear, the file that is used as the reclock file at runtime. When this command is used, the reclock file checks are disabled. To re-enable the checks the administrator needs to activate the "VerifyRecoveryLock" tunable using "ctdb setvar".
       </p><p>
        If run with no parameter this will remove the reclock file completely. If run with a parameter the parameter specifies the new filename to use for the recovery lock.
       </p><p>
        This command only affects the runtime settings of a ctdb node and will be lost when ctdb is restarted. For persistent changes to the reclock file setting you must edit /etc/sysconfig/ctdb.
-      </p></div><div class="refsect2" lang="en"><a name="id2528846"></a><h3>getdebug</h3><p>
+      </p></div><div class="refsect2" lang="en"><a name="id2528985"></a><h3>getdebug</h3><p>
         Get the current debug level for the node. the debug level controls what information is written to the log file.
       </p><p>
        The debug levels are mapped to the corresponding syslog levels.
@@ -333,42 +333,42 @@ Reclock file:/gpfs/.ctdb/shared
        The list of debug levels from highest to lowest are :
       </p><p>
        EMERG ALERT CRIT ERR WARNING NOTICE INFO DEBUG
-      </p></div><div class="refsect2" lang="en"><a name="id2528872"></a><h3>setdebug &lt;debuglevel&gt;</h3><p>
+      </p></div><div class="refsect2" lang="en"><a name="id2529011"></a><h3>setdebug &lt;debuglevel&gt;</h3><p>
         Set the debug level of a node. This controls what information will be logged.
       </p><p>
        The debuglevel is one of EMERG ALERT CRIT ERR WARNING NOTICE INFO DEBUG
-      </p></div><div class="refsect2" lang="en"><a name="id2528888"></a><h3>getpid</h3><p>
+      </p></div><div class="refsect2" lang="en"><a name="id2529027"></a><h3>getpid</h3><p>
         This command will return the process id of the ctdb daemon.
-      </p></div><div class="refsect2" lang="en"><a name="id2528898"></a><h3>disable</h3><p>
+      </p></div><div class="refsect2" lang="en"><a name="id2529037"></a><h3>disable</h3><p>
         This command is used to administratively disable a node in the cluster.
         A disabled node will still participate in the cluster and host
         clustered TDB records but its public ip address has been taken over by
         a different node and it no longer hosts any services.
-      </p></div><div class="refsect2" lang="en"><a name="id2528912"></a><h3>enable</h3><p>
+      </p></div><div class="refsect2" lang="en"><a name="id2529051"></a><h3>enable</h3><p>
         Re-enable a node that has been administratively disabled.
-      </p></div><div class="refsect2" lang="en"><a name="id2528922"></a><h3>stop</h3><p>
+      </p></div><div class="refsect2" lang="en"><a name="id2529061"></a><h3>stop</h3><p>
         This command is used to administratively STOP a node in the cluster.
         A STOPPED node is connected to the cluster but will not host any
        public ip addresse, nor does it participate in the VNNMAP.
        The difference between a DISABLED node and a STOPPED node is that
        a STOPPED node does not host any parts of the database which means
        that a recovery is required to stop/continue nodes.
-      </p></div><div class="refsect2" lang="en"><a name="id2528937"></a><h3>continue</h3><p>
+      </p></div><div class="refsect2" lang="en"><a name="id2529076"></a><h3>continue</h3><p>
         Re-start a node that has been administratively stopped.
-      </p></div><div class="refsect2" lang="en"><a name="id2528948"></a><h3>addip &lt;public_ip/mask&gt; &lt;iface&gt;</h3><p>
+      </p></div><div class="refsect2" lang="en"><a name="id2529087"></a><h3>addip &lt;public_ip/mask&gt; &lt;iface&gt;</h3><p>
        This command is used to add a new public ip to a node during runtime.
        This allows public addresses to be added to a cluster without having
        to restart the ctdb daemons.
       </p><p>
        Note that this only updates the runtime instance of ctdb. Any changes will be lost next time ctdb is restarted and the public addresses file is re-read.
  If you want this change to be permanent you must also update the public addresses file manually.
-      </p></div><div class="refsect2" lang="en"><a name="id2528968"></a><h3>delip &lt;public_ip&gt;</h3><p>
+      </p></div><div class="refsect2" lang="en"><a name="id2529107"></a><h3>delip &lt;public_ip&gt;</h3><p>
        This command is used to remove a public ip from a node during runtime.
        If this public ip is currently hosted by the node it being removed from, the ip will first be failed over to another node, if possible, before it is removed.
       </p><p>
        Note that this only updates the runtime instance of ctdb. Any changes will be lost next time ctdb is restarted and the public addresses file is re-read.
  If you want this change to be permanent you must also update the public addresses file manually.
-      </p></div><div class="refsect2" lang="en"><a name="id2528989"></a><h3>moveip &lt;public_ip&gt; &lt;node&gt;</h3><p>
+      </p></div><div class="refsect2" lang="en"><a name="id2529132"></a><h3>moveip &lt;public_ip&gt; &lt;node&gt;</h3><p>
       This command can be used to manually fail a public ip address to a
       specific node.
       </p><p>
@@ -379,14 +379,14 @@ Reclock file:/gpfs/.ctdb/shared
       DeterministicIPs = 0
       </p><p>
       NoIPFailback = 1
-      </p></div><div class="refsect2" lang="en"><a name="id2529014"></a><h3>shutdown</h3><p>
+      </p></div><div class="refsect2" lang="en"><a name="id2529157"></a><h3>shutdown</h3><p>
         This command will shutdown a specific CTDB daemon.
-      </p></div><div class="refsect2" lang="en"><a name="id2529024"></a><h3>recover</h3><p>
+      </p></div><div class="refsect2" lang="en"><a name="id2529167"></a><h3>recover</h3><p>
         This command will trigger the recovery daemon to do a cluster
         recovery.
-      </p></div><div class="refsect2" lang="en"><a name="id2529034"></a><h3>ipreallocate</h3><p>
+      </p></div><div class="refsect2" lang="en"><a name="id2529178"></a><h3>ipreallocate</h3><p>
         This command will force the recovery master to perform a full ip reallocation process and redistribute all ip addresses. This is useful to "reset" the allocations back to its default state if they have been changed using the "moveip" command. While a "recover" will also perform this reallocation, a recovery is much more hevyweight since it will also rebuild all the databases.
-      </p></div><div class="refsect2" lang="en"><a name="id2529050"></a><h3>setlmasterrole &lt;on|off&gt;</h3><p>
+      </p></div><div class="refsect2" lang="en"><a name="id2529193"></a><h3>setlmasterrole &lt;on|off&gt;</h3><p>
        This command is used ot enable/disable the LMASTER capability for a node at runtime. This capability determines whether or not a node can be used as an LMASTER for records in the database. A node that does not have the LMASTER capability will not show up in the vnnmap.
       </p><p>
        Nodes will by default have this capability, but it can be stripped off nodes by the setting in the sysconfig file or by using this command.
@@ -394,21 +394,21 @@ Reclock file:/gpfs/.ctdb/shared
        Once this setting has been enabled/disabled, you need to perform a recovery for it to take effect.
       </p><p>
        See also "ctdb getcapabilities"
-      </p></div><div class="refsect2" lang="en"><a name="id2529079"></a><h3>setrecmasterrole &lt;on|off&gt;</h3><p>
+      </p></div><div class="refsect2" lang="en"><a name="id2529222"></a><h3>setrecmasterrole &lt;on|off&gt;</h3><p>
        This command is used ot enable/disable the RECMASTER capability for a node at runtime. This capability determines whether or not a node can be used as an RECMASTER for the cluster. A node that does not have the RECMASTER capability can not win a recmaster election. A node that already is the recmaster for the cluster when the capability is stripped off the node will remain the recmaster until the next cluster election.
       </p><p>
        Nodes will by default have this capability, but it can be stripped off nodes by the setting in the sysconfig file or by using this command.
       </p><p>
        See also "ctdb getcapabilities"
-      </p></div><div class="refsect2" lang="en"><a name="id2529105"></a><h3>killtcp &lt;srcip:port&gt; &lt;dstip:port&gt;</h3><p>
+      </p></div><div class="refsect2" lang="en"><a name="id2529249"></a><h3>killtcp &lt;srcip:port&gt; &lt;dstip:port&gt;</h3><p>
         This command will kill the specified TCP connection by issuing a
         TCP RST to the srcip:port endpoint. This is a command used by the 
        ctdb eventscripts.
-      </p></div><div class="refsect2" lang="en"><a name="id2529118"></a><h3>gratiousarp &lt;ip&gt; &lt;interface&gt;</h3><p>
+      </p></div><div class="refsect2" lang="en"><a name="id2529261"></a><h3>gratiousarp &lt;ip&gt; &lt;interface&gt;</h3><p>
        This command will send out a gratious arp for the specified interface
        through the specified interface. This command is mainly used by the
        ctdb eventscripts.
-      </p></div><div class="refsect2" lang="en"><a name="id2529130"></a><h3>reloadnodes</h3><p>
+      </p></div><div class="refsect2" lang="en"><a name="id2529274"></a><h3>reloadnodes</h3><p>
       This command is used when adding new nodes, or removing existing nodes from an existing cluster.
       </p><p>
       Procedure to add a node:
@@ -442,7 +442,7 @@ Reclock file:/gpfs/.ctdb/shared
       </p><p>
       5, Use 'ctdb status' on all nodes and verify that the deleted node no longer shows up in the list..
       </p><p>
-      </p></div><div class="refsect2" lang="en"><a name="id2529214"></a><h3>tickle &lt;srcip:port&gt; &lt;dstip:port&gt;</h3><p>
+      </p></div><div class="refsect2" lang="en"><a name="id2529357"></a><h3>tickle &lt;srcip:port&gt; &lt;dstip:port&gt;</h3><p>
         This command will will send a TCP tickle to the source host for the
         specified TCP connection.
        A TCP tickle is a TCP ACK packet with an invalid sequence and 
@@ -454,10 +454,10 @@ Reclock file:/gpfs/.ctdb/shared
         TCP connection has been disrupted and that the client will need
         to reestablish. This greatly speeds up the time it takes for a client
         to detect and reestablish after an IP failover in the ctdb cluster.
-      </p></div><div class="refsect2" lang="en"><a name="id2529239"></a><h3>gettickles &lt;ip&gt;</h3><p>
+      </p></div><div class="refsect2" lang="en"><a name="id2529382"></a><h3>gettickles &lt;ip&gt;</h3><p>
        This command is used to show which TCP connections are registered with
        CTDB to be "tickled" if there is a failover.
-      </p></div><div class="refsect2" lang="en"><a name="id2529250"></a><h3>repack [max_freelist]</h3><p>
+      </p></div><div class="refsect2" lang="en"><a name="id2529394"></a><h3>repack [max_freelist]</h3><p>
        Over time, when records are created and deleted in a TDB, the TDB list of free space will become fragmented. This can lead to a slowdown in accessing TDB records.
        This command is used to defragment a TDB database and pruning the freelist.
       </p><p>
@@ -472,7 +472,7 @@ Reclock file:/gpfs/.ctdb/shared
        Example: ctdb repack 1000
       </p><p>
         By default, this operation is issued from the 00.ctdb event script every 5 minutes.
-      </p></div><div class="refsect2" lang="en"><a name="id2529296"></a><h3>vacuum [max_records]</h3><p>
+      </p></div><div class="refsect2" lang="en"><a name="id2529440"></a><h3>vacuum [max_records]</h3><p>
        Over time CTDB databases will fill up with empty deleted records which will lead to a progressive slow down of CTDB database access.
        This command is used to prune all databases and delete all empty records from the cluster.
       </p><p>
@@ -488,17 +488,17 @@ Reclock file:/gpfs/.ctdb/shared
        Example: ctdb vacuum
       </p><p>
         By default, this operation is issued from the 00.ctdb event script every 5 minutes.
-      </p></div><div class="refsect2" lang="en"><a name="id2529332"></a><h3>backupdb &lt;database&gt; &lt;file&gt;</h3><p>
+      </p></div><div class="refsect2" lang="en"><a name="id2529476"></a><h3>backupdb &lt;database&gt; &lt;file&gt;</h3><p>
         This command can be used to copy the entire content of a database out to a file. This file can later be read back into ctdb using the restoredb command.
 This is mainly useful for backing up persistent databases such as secrets.tdb and similar.
-      </p></div><div class="refsect2" lang="en"><a name="id2529346"></a><h3>restoredb &lt;file&gt;</h3><p>
+      </p></div><div class="refsect2" lang="en"><a name="id2529490"></a><h3>restoredb &lt;file&gt;</h3><p>
         This command restores a persistent database that was previously backed up using backupdb.
-      </p></div></div><div class="refsect1" lang="en"><a name="id2529358"></a><h2>Debugging Commands</h2><p>
+      </p></div></div><div class="refsect1" lang="en"><a name="id2529502"></a><h2>Debugging Commands</h2><p>
       These commands are primarily used for CTDB development and testing and
       should not be used for normal administration.
-    </p><div class="refsect2" lang="en"><a name="id2529368"></a><h3>process-exists &lt;pid&gt;</h3><p>
+    </p><div class="refsect2" lang="en"><a name="id2529512"></a><h3>process-exists &lt;pid&gt;</h3><p>
         This command checks if a specific process exists on the CTDB host. This is mainly used by Samba to check if remote instances of samba are still running or not.
-      </p></div><div class="refsect2" lang="en"><a name="id2529381"></a><h3>getdbmap</h3><p>
+      </p></div><div class="refsect2" lang="en"><a name="id2529524"></a><h3>getdbmap</h3><p>
         This command lists all clustered TDB databases that the CTDB daemon has attached to. Some databases are flagged as PERSISTENT, this means that the database stores data persistently and the data will remain across reboots. One example of such a database is secrets.tdb where information about how the cluster was joined to the domain is stored.
        </p><p>
        Most databases are not persistent and only store the state information that the currently running samba daemons need. These databases are always wiped when ctdb/samba starts and when a node is rebooted.
@@ -517,25 +517,25 @@ dbid:0x2672a57f name:idmap2.tdb path:/var/ctdb/persistent/idmap2.tdb.0 PERSISTEN
 dbid:0xb775fff6 name:secrets.tdb path:/var/ctdb/persistent/secrets.tdb.0 PERSISTENT
 dbid:0xe98e08b6 name:group_mapping.tdb path:/var/ctdb/persistent/group_mapping.tdb.0 PERSISTENT
 dbid:0x7bbbd26c name:passdb.tdb path:/var/ctdb/persistent/passdb.tdb.0 PERSISTENT
-      </pre></div><div class="refsect2" lang="en"><a name="id2529427"></a><h3>catdb &lt;dbname&gt;</h3><p>
+      </pre></div><div class="refsect2" lang="en"><a name="id2529558"></a><h3>catdb &lt;dbname&gt;</h3><p>
         This command will dump a clustered TDB database to the screen. This is a debugging command.
-      </p></div><div class="refsect2" lang="en"><a name="id2529438"></a><h3>getmonmode</h3><p>
+      </p></div><div class="refsect2" lang="en"><a name="id2476137"></a><h3>getmonmode</h3><p>
         This command returns the monutoring mode of a node. The monitoring mode is either ACTIVE or DISABLED. Normally a node will continously monitor that all other nodes that are expected are in fact connected and that they respond to commands.
       </p><p>
         ACTIVE - This is the normal mode. The node is actively monitoring all other nodes, both that the transport is connected and also that the node responds to commands. If a node becomes unavailable, it will be marked as DISCONNECTED and a recovery is initiated to restore the cluster.
       </p><p>
         DISABLED - This node is not monitoring that other nodes are available. In this mode a node failure will not be detected and no recovery will be performed. This mode is useful when for debugging purposes one wants to attach GDB to a ctdb process but wants to prevent the rest of the cluster from marking this node as DISCONNECTED and do a recovery.
-      </p></div><div class="refsect2" lang="en"><a name="id2529468"></a><h3>setmonmode &lt;0|1&gt;</h3><p>
+      </p></div><div class="refsect2" lang="en"><a name="id2476168"></a><h3>setmonmode &lt;0|1&gt;</h3><p>
         This command can be used to explicitely disable/enable monitoring mode on a node. The main purpose is if one wants to attach GDB to a running ctdb daemon but wants to prevent the other nodes from marking it as DISCONNECTED and issuing a recovery. To do this, set monitoring mode to 0 on all nodes before attaching with GDB. Remember to set monitoring mode back to 1 afterwards.
-      </p></div><div class="refsect2" lang="en"><a name="id2529484"></a><h3>attach &lt;dbname&gt;</h3><p>
+      </p></div><div class="refsect2" lang="en"><a name="id2476183"></a><h3>attach &lt;dbname&gt;</h3><p>
         This is a debugging command. This command will make the CTDB daemon create a new CTDB database and attach to it.
-      </p></div><div class="refsect2" lang="en"><a name="id2529495"></a><h3>dumpmemory</h3><p>
+      </p></div><div class="refsect2" lang="en"><a name="id2476195"></a><h3>dumpmemory</h3><p>
         This is a debugging command. This command will make the ctdb
         daemon to write a fill memory allocation map to standard output.
-      </p></div><div class="refsect2" lang="en"><a name="id2529507"></a><h3>rddumpmemory</h3><p>
+      </p></div><div class="refsect2" lang="en"><a name="id2476206"></a><h3>rddumpmemory</h3><p>
         This is a debugging command. This command will dump the talloc memory
        allocation tree for the recovery daemon to standard output.
-      </p></div><div class="refsect2" lang="en"><a name="id2529518"></a><h3>freeze</h3><p>
+      </p></div><div class="refsect2" lang="en"><a name="id2476218"></a><h3>freeze</h3><p>
         This command will lock all the local TDB databases causing clients 
         that are accessing these TDBs such as samba3 to block until the
         databases are thawed.
@@ -543,26 +543,26 @@ dbid:0x7bbbd26c name:passdb.tdb path:/var/ctdb/persistent/passdb.tdb.0 PERSISTEN
         This is primarily used by the recovery daemon to stop all samba
         daemons from accessing any databases while the database is recovered
         and rebuilt.
-      </p></div><div class="refsect2" lang="en"><a name="id2529537"></a><h3>thaw</h3><p>
+      </p></div><div class="refsect2" lang="en"><a name="id2476236"></a><h3>thaw</h3><p>
         Thaw a previously frozen node.
-      </p></div><div class="refsect2" lang="en"><a name="id2529546"></a><h3>eventscript &lt;arguments&gt;</h3><p>
+      </p></div><div class="refsect2" lang="en"><a name="id2476246"></a><h3>eventscript &lt;arguments&gt;</h3><p>
         This is a debugging command. This command can be used to manually
        invoke and run the eventscritps with arbitrary arguments.
-      </p></div><div class="refsect2" lang="en"><a name="id2529558"></a><h3>ban &lt;bantime|0&gt;</h3><p>
+      </p></div><div class="refsect2" lang="en"><a name="id2476257"></a><h3>ban &lt;bantime|0&gt;</h3><p>
         Administratively ban a node for bantime seconds. A bantime of 0 means that the node should be permanently banned. 
       </p><p>
         A banned node does not participate in the cluster and does not host any records for the clustered TDB. Its ip address has been taken over by an other node and no services are hosted.
       </p><p>
         Nodes are automatically banned if they are the cause of too many
         cluster recoveries.
-      </p></div><div class="refsect2" lang="en"><a name="id2476137"></a><h3>unban</h3><p>
+      </p></div><div class="refsect2" lang="en"><a name="id2476281"></a><h3>unban</h3><p>
         This command is used to unban a node that has either been 
         administratively banned using the ban command or has been automatically
         banned by the recovery daemon.
-      </p></div></div><div class="refsect1" lang="en"><a name="id2476150"></a><h2>SEE ALSO</h2><p>
+      </p></div></div><div class="refsect1" lang="en"><a name="id2476294"></a><h2>SEE ALSO</h2><p>
       ctdbd(1), onnode(1)
       <a class="ulink" href="http://ctdb.samba.org/" target="_top">http://ctdb.samba.org/</a>
-    </p></div><div class="refsect1" lang="en"><a name="id2476163"></a><h2>COPYRIGHT/LICENSE</h2><div class="literallayout"><p><br>
+    </p></div><div class="refsect1" lang="en"><a name="id2476307"></a><h2>COPYRIGHT/LICENSE</h2><div class="literallayout"><p><br>
 Copyright (C) Andrew Tridgell 2007<br>
 Copyright (C) Ronnie sahlberg 2007<br>
 <br>
index cca626ce1e2f28b112626d30503d96b647995dae..512dff4663a97630a8ff164dc9507808284ac239 100644 (file)
@@ -271,7 +271,7 @@ Recovery master:0
 
     <refsect2><title>uptime</title>
       <para>
-        This command shows the uptime for the ctdb daemon. When the last recovery completed and how long the last recovery took. If the "duration" is shown as a negative number, this indicates that there is a recovery in progress and it started that many seconds ago.
+        This command shows the uptime for the ctdb daemon. When the last recovery or ip-failover completed and how long it took. If the "duration" is shown as a negative number, this indicates that there is a recovery/failover in progress and it started that many seconds ago.
       </para>
 
       <para>
@@ -279,10 +279,10 @@ Recovery master:0
       </para>
       <para>Example output:</para>
       <screen format="linespecific">
-Current time of node  : Tue Mar 24 18:27:54 2009
-Ctdbd start time      : (000 00:00:05) Tue Mar 24 18:27:49 2009
-Time of last recovery : (000 00:00:05) Tue Mar 24 18:27:49 2009
-Duration of last recovery : 0.000000 seconds
+Current time of node          :                Thu Oct 29 10:38:54 2009
+Ctdbd start time              : (000 16:54:28) Wed Oct 28 17:44:26 2009
+Time of last recovery/failover: (000 16:53:31) Wed Oct 28 17:45:23 2009
+Duration of last recovery/failover: 2.248552 seconds
       </screen>
     </refsect2>
 
index abe09a3f966dfd2464336764212fa3d1158a510f..db4c5ccc4bfd2bf8cea225a4c44f334a011f1bd6 100644 (file)
@@ -111,6 +111,10 @@ struct ctdb_call_info {
 */
 #define CTDB_SRVID_TAKEOVER_RUN_RESPONSE  0xFD00000000000000LL
 
+/* A port reserved for samba (top 32 bits)
+ */
+#define CTDB_SRVID_SAMBA_NOTIFY  0xFE00000000000000LL
+
 /* used on the domain socket, send a pdu to the local daemon */
 #define CTDB_CURRENT_NODE     0xF0000001
 /* send a broadcast to all nodes in the cluster, active or not */
@@ -144,6 +148,15 @@ struct ctdb_client_control_state {
        } async;        
 };
 
+struct ctdb_client_notify_register {
+       uint64_t srvid;
+       uint32_t len;
+       uint8_t notify_data[1];
+};
+
+struct ctdb_client_notify_deregister {
+       uint64_t srvid;
+};
 
 struct event_context;
 
@@ -196,7 +209,7 @@ int ctdb_ip_to_nodeid(struct ctdb_context *ctdb, const char *nodeip);
   start the ctdb protocol
 */
 int ctdb_start(struct ctdb_context *ctdb);
-int ctdb_start_daemon(struct ctdb_context *ctdb, bool do_fork);
+int ctdb_start_daemon(struct ctdb_context *ctdb, bool do_fork, bool use_syslog);
 
 /*
   attach to a ctdb database
index 2f4937e60f844a1f3a8c234d1efe7b6e10072a91..ebb6d4ae0a1de29c1c78d7c6f2c9632bde008a6f 100644 (file)
@@ -53,6 +53,11 @@ struct takeover_run_reply {
        uint64_t srvid;
 };
 
+/*
+ * pid of the ctdbd daemon
+ */
+extern pid_t ctdbd_pid;
+
 /*
   a tcp connection description
  */
@@ -160,7 +165,6 @@ typedef void (*ctdb_control_callback_fn_t)(struct ctdb_context *,
                                           int32_t status, TDB_DATA data, 
                                           const char *errormsg,
                                           void *private_data);
-
 /*
   structure describing a connected client in the daemon
  */
@@ -173,6 +177,7 @@ struct ctdb_client {
        struct ctdb_tcp_list *tcp_list;
        uint32_t db_id;
        uint32_t num_persistent_updates;
+       struct ctdb_client_notify_list *notify;
 };
 
 
@@ -445,8 +450,9 @@ struct ctdb_context {
        TALLOC_CTX *eventscripts_ctx; /* a context to hold data for the RUN_EVENTSCRIPTS control */
        uint32_t *recd_ping_count;
        TALLOC_CTX *release_ips_ctx; /* a context used to automatically drop all IPs if we fail to recover the node */
-       TALLOC_CTX *script_monitoring_ctx; /* a context where we store results while running the monitor event */
-       TALLOC_CTX *last_monitoring_ctx; 
+       TALLOC_CTX *script_monitor_ctx; /* a context where we store results while running the monitor event */
+       TALLOC_CTX *last_monitor_ctx; 
+       TALLOC_CTX *event_script_ctx;  /* non-monitoring events */
        TALLOC_CTX *banning_ctx;
 };
 
@@ -612,6 +618,9 @@ enum ctdb_controls {CTDB_CONTROL_PROCESS_EXISTS          = 0,
                    CTDB_CONTROL_SET_DB_PRIORITY         = 111,
                    CTDB_CONTROL_GET_DB_PRIORITY         = 112,
                    CTDB_CONTROL_TRANSACTION_CANCEL      = 113,
+                   CTDB_CONTROL_REGISTER_NOTIFY         = 114,
+                   CTDB_CONTROL_DEREGISTER_NOTIFY       = 115,
+                   CTDB_CONTROL_TRANS2_ACTIVE           = 116,
 };     
 
 /*
@@ -1461,6 +1470,9 @@ int32_t ctdb_control_trans2_finished(struct ctdb_context *ctdb,
                                     struct ctdb_req_control *c);
 int32_t ctdb_control_trans2_error(struct ctdb_context *ctdb, 
                                  struct ctdb_req_control *c);
+int32_t ctdb_control_trans2_active(struct ctdb_context *ctdb,
+                                  struct ctdb_req_control *c,
+                                  uint32_t db_id);
 
 char *ctdb_addr_to_str(ctdb_sock_addr *addr);
 unsigned ctdb_addr_to_port(ctdb_sock_addr *addr);
@@ -1501,4 +1513,10 @@ int32_t ctdb_control_set_ban_state(struct ctdb_context *ctdb, TDB_DATA indata);
 int32_t ctdb_control_get_ban_state(struct ctdb_context *ctdb, TDB_DATA *outdata);
 int32_t ctdb_control_set_db_priority(struct ctdb_context *ctdb, TDB_DATA indata);
 
+int32_t ctdb_control_register_notify(struct ctdb_context *ctdb, uint32_t client_id, TDB_DATA indata);
+
+int32_t ctdb_control_deregister_notify(struct ctdb_context *ctdb, uint32_t client_id, TDB_DATA indata);
+
+int start_syslog_daemon(struct ctdb_context *ctdb);
+
 #endif
index d10eb79ea78813ce0b43a721a948d7f2d309c818..0dfdb79517a6955dbd7d79710aa59239f1664ff2 100644 (file)
@@ -21,6 +21,7 @@
 */
 
 #include "includes.h"
+#include "system/time.h"
 #include "system/filesys.h"
 #include "system/network.h"
 #include "lib/util/dlinklist.h"
@@ -28,6 +29,8 @@
 #include "lib/events/events_internal.h"
 #include <sys/epoll.h>
 
+extern pid_t ctdbd_pid;
+
 struct epoll_event_context {
        /* a pointer back to the generic event_context */
        struct event_context *ev;
@@ -457,12 +460,27 @@ static int epoll_event_loop_once(struct event_context *ev)
 */
 static int epoll_event_loop_wait(struct event_context *ev)
 {
+       static time_t t=0;
+       time_t new_t;
        struct epoll_event_context *epoll_ev = talloc_get_type(ev->additional_data,
                                                           struct epoll_event_context);
        while (epoll_ev->num_fd_events) {
                if (epoll_event_loop_once(ev) != 0) {
                        break;
                }
+               if (getpid() == ctdbd_pid) {
+                       new_t=time(NULL);
+                       if (t != 0) {
+                               if (t > new_t) {
+                                       DEBUG(0,("ERROR Time skipped backward by %d seconds\n", (int)(t-new_t)));
+                               }
+                               /* We assume here that we get at least one event every 5 seconds */
+                               if (new_t > (t+5)) {
+                                       DEBUG(0,("ERROR Time jumped forward by %d seconds\n", (int)(new_t-t)));
+                               }
+                       }
+                       t=new_t;
+               }
        }
 
        return 0;
index 3f9eeb5617cdef24bd68bfb23ed54c255ca78040..404cd8c370adb6903789d60ddc4c94645f6fa219 100644 (file)
 */
 
 #include "includes.h"
+#include "system/time.h"
 #include "system/filesys.h"
 #include "system/select.h"
 #include "lib/util/dlinklist.h"
 #include "lib/events/events.h"
 #include "lib/events/events_internal.h"
 
+extern pid_t ctdbd_pid;
+
 struct select_event_context {
        /* a pointer back to the generic event_context */
        struct event_context *ev;
@@ -270,6 +273,8 @@ static int select_event_loop_once(struct event_context *ev)
 */
 static int select_event_loop_wait(struct event_context *ev)
 {
+       static time_t t=0;
+       time_t new_t;
        struct select_event_context *select_ev = talloc_get_type(ev->additional_data,
                                                           struct select_event_context);
        select_ev->exit_code = 0;
@@ -278,6 +283,19 @@ static int select_event_loop_wait(struct event_context *ev)
                if (select_event_loop_once(ev) != 0) {
                        break;
                }
+               if (getpid() == ctdbd_pid) {
+                       new_t=time(NULL);
+                       if (t != 0) {
+                               if (t > new_t) {
+                                       DEBUG(0,("ERROR Time skipped backward by %d seconds\n", (int)(t-new_t)));
+                               }
+                               /* We assume here that we get at least one event every 5 seconds */
+                               if (new_t > (t+5)) {
+                                       DEBUG(0,("ERROR Time jumped forward by %d seconds\n", (int)(new_t-t)));
+                               }
+                       }
+                       t=new_t;
+               }
        }
 
        return select_ev->exit_code;
index 5e529d66ab483bb0f2d1984a22b7ce9690958f3c..9ee2328225d2d4aea7e7e5005cb8857c119aa572 100644 (file)
@@ -28,6 +28,7 @@
 */
 
 #include "includes.h"
+#include "system/time.h"
 #include "system/filesys.h"
 #include "system/network.h"
 #include "system/select.h" /* needed for HAVE_EVENTS_EPOLL */
@@ -35,6 +36,8 @@
 #include "lib/events/events.h"
 #include "lib/events/events_internal.h"
 
+extern pid_t ctdbd_pid;
+
 struct std_event_context {
        /* a pointer back to the generic event_context */
        struct event_context *ev;
@@ -571,6 +574,8 @@ static int std_event_loop_once(struct event_context *ev)
 */
 static int std_event_loop_wait(struct event_context *ev)
 {
+       static time_t t=0;
+       time_t new_t;
        struct std_event_context *std_ev = talloc_get_type(ev->additional_data,
                                                           struct std_event_context);
        std_ev->exit_code = 0;
@@ -579,6 +584,19 @@ static int std_event_loop_wait(struct event_context *ev)
                if (std_event_loop_once(ev) != 0) {
                        break;
                }
+               if (getpid() == ctdbd_pid) {
+                       new_t=time(NULL);
+                       if (t != 0) {
+                               if (t > new_t) {
+                                       DEBUG(0,("ERROR Time skipped backward by %d seconds\n", (int)(t-new_t)));
+                               }
+                               /* We assume here that we get at least one event every 5 seconds */
+                               if (new_t > (t+5)) {
+                                       DEBUG(0,("ERROR Time jumped forward by %d seconds\n", (int)(new_t-t)));
+                               }
+                       }
+                       t=new_t;
+               }
        }
 
        return std_ev->exit_code;
similarity index 90%
rename from packaging/RPM/ctdb.spec
rename to packaging/RPM/ctdb.spec.in
index 536e7cffba021a4616173ca5b9c5c6ae910f47fe..24ded62c27afc7e933a5b48181dc86353e060ba3 100644 (file)
@@ -4,8 +4,8 @@ Summary: Clustered TDB
 Vendor: Samba Team
 Packager: Samba Team <samba@samba.org>
 Name: ctdb
-Version: 1.0.98
-Release: 1
+Version: 1.0.104
+Release: 1GITHASH
 Epoch: 0
 License: GNU GPL version 3
 Group: System Environment/Daemons
@@ -13,7 +13,7 @@ URL: http://ctdb.samba.org/
 
 Source: ctdb-%{version}.tar.gz
 
-Prereq: /sbin/chkconfig /bin/mktemp /usr/bin/killall
+Prereq: /bin/mktemp /usr/bin/killall
 Prereq: fileutils sed /etc/init.d
 
 Provides: ctdb = %{version}
@@ -74,15 +74,6 @@ find $RPM_BUILD_ROOT -name "*.old" -exec rm -f {} \;
 %clean
 rm -rf $RPM_BUILD_ROOT
 
-%post
-[ -x /sbin/chkconfig ] && /sbin/chkconfig --add ctdb
-
-%preun
-if [ $1 = 0 ] ; then
-    [ -x /sbin/chkconfig ] && /sbin/chkconfig --del ctdb
-fi
-exit 0
-
 
 #######################################################################
 ## Files section                                                     ##
@@ -127,6 +118,64 @@ exit 0
 %{_libdir}/pkgconfig/ctdb.pc
 
 %changelog
+* Fri Nov 6 2009 : Version 1.0.104
+ - Suggestion from Metze, we can now use killtcp to kill local connections
+   for nfs so change the killtcp script to kill both directions of an NFS
+   connection.
+   We used to deliberately only kill one direction in these cases due to
+   limitations.
+ - Suggestion from christian Ambach, when using natgw, try to avoid using a
+   UNHEALTHY node as the natgw master.
+ - From Michael Adam: Fix a SEGV bug in the recent change to the eventscripts
+   to allow the timeout to apply to each individual script.
+ - fix a talloc bug in teh vacuuming code that produced nasty valgrind
+   warnings.
+ - From Rusty: Set up ulimit to create core files for ctdb, and spawned
+   processes by default. This is useful for debugging and testing but can be
+   disabled by setting CTDB_SUPRESS_COREFILE=yes in the sysconfig file.
+ - Remove the wbinfo -t check from the startup check that winbindd is happy.
+ - Enhance the test for bond devices so we also check if the sysadmin have
+   disabled all slave devices using "ifdown".
+* Tue Nov 3 2009 : Version 1.0.103
+ - Dont use vacuuming on persistent databases
+ - Michael A : transaction updates to persistent databases
+ - Dont activate service automatically when installing the RPM. Leave this to the admin.
+ - Create a child process to send all log messages to, to prevent a hung/slow syslogd
+   from blocking the main daemon. In this case, discard log messages instead and let the child
+   process block.
+ - Michael A: updates to log messages
+* Thu Oct 29 2009 : Version 1.0.102
+ - Wolfgang: fix for the vacuuming code
+ - Wolfgang: stronger tests for persistent database filename tests
+ - Improve the log message when we refuse to startup since wbinfo -t fails
+   to make it easier to spot in the log.
+ - Update the uptime command output and the man page to indicate that
+   "time since last ..." if from either the last recovery OR the last failover
+ - Michael A: transaction updates
+* Wed Oct 28 2009 : Version 1.0.101
+ - create a separate context for non-monitoring events so they dont interfere with the monitor event
+ - make sure to return status 0 in teh callback when we abort an event
+* Wed Oct 28 2009 : Version 1.0.100
+ - Change eventscript handling to allow EventScriptTimeout for each individual script instead of for all scripts as a whole.
+ - Enhanced logging from the eventscripts, log the name and the duration for each script as it finishes.
+ - Add a check to use wbinfo -t for the startup event of samba
+ - TEMP: allow clients to attach to databases even when teh node is in recovery mode
+ - dont run the monitor event as frequently after an event has failed
+ - DEBUG: in the eventloops, check the local time and warn if the time changes backward or rapidly forward
+ - From Metze, fix a bug where recovery master becoming unhealthy did not trigger an ip failover.
+ - Disable the multipath script by default
+ - Automatically re-activate the reclock checking if the reclock file is specified at runtime. Update manpage to reflect this.
+ - Add a mechanism where samba can register a SRVID and if samba unexpectedly disconnects, a message will be broadcasted to all other samba daemons.
+ - Log the pstree on hung scripts to a file in /tmp isntead of /var/log/messages
+ - change ban count before unhealthy/banned to 10
+* Thu Oct 22 2009 : Version 1.0.99
+ - Fix a SEGV in the new db priority code.
+ - From Wolfgang : eliminate a ctdb_fatal() if there is a dmaster violation detected.
+ - During testing we often add/delete eventscripts at runtime. This could cause an eventscript to fail and mark the node unhealthy if an eventscript was deleted while we were listing the names. Handle the errorcode and make sure the node does not becomne unhealthy in this case.
+ - Lower the debuglevel for the messages when ctdb creates a filedescruiptor so we dont spam the logs with these messages.
+ - Dont have the RPM automatically restart ctdb
+ - Volker : add a missing transaction_cancel() in the handling of persistent databases
+ - Treat interfaces with the anme ethX* as bond devices in 10.interfaces so we do the correct test for if they are up or not.
 * Tue Oct 20 2009 : Version 1.0.98
  - Fix for the vacuuming database from Wolfgang M
  - Create a directory where the test framework can put temporary overrides
index 846ab7f70f8c13836a14e9ec839c7189376c3fca..a51099c543e9ab58e4b58cb717d149e55c9f70dd 100755 (executable)
@@ -41,8 +41,19 @@ SPECDIR=`rpm --eval %_specdir`
 SRCDIR=`rpm --eval %_sourcedir`
 
 SPECFILE="ctdb.spec"
+SPECFILE_IN="ctdb.spec.in"
 RPMBUILD="rpmbuild"
 
+GITHASH=".$(git log --pretty=format:%h -1)"
+
+if test "x$USE_GITHASH" = "xno" ; then
+       GITHASH=""
+fi
+
+sed -e s/GITHASH/${GITHASH}/g \
+       < ${DIRNAME}/${SPECFILE_IN} \
+       > ${DIRNAME}/${SPECFILE}
+
 VERSION=$(grep ^Version ${DIRNAME}/${SPECFILE} | sed -e 's/^Version:\ \+//')
 RELEASE=$(grep ^Release ${DIRNAME}/${SPECFILE} | sed -e 's/^Release:\ \+//')
 
index 1dac919925864e38336befcbcb4ec7b741b162b7..cd5286781153c29af140a8623be0acc4e6b3aa9e 100644 (file)
@@ -342,13 +342,10 @@ void ctdb_request_dmaster(struct ctdb_context *ctdb, struct ctdb_req_header *hdr
                         ctdb_db->db_id, hdr->generation, ctdb->vnn_map->generation,
                         (unsigned long long)c->rsn, (unsigned long long)header.rsn, c->hdr.reqid,
                         (key.dsize >= 4)?(*(uint32_t *)key.dptr):0));
-               /*
-                * with the new vacuuming code there are conditions where a node has outdated
-                * information about the real dmaster
-                * since here we are lmaster and always know who is the real dmaster
-                * we don't need to exit with a fatal error and we even don't have
-                * to initiate a recovery
-                */
+               if (header.rsn != 0 || header.dmaster != ctdb->pnn) {
+                       ctdb_fatal(ctdb, "ctdb_req_dmaster from non-master");
+                       return;
+               }
        }
 
        if (header.rsn > c->rsn) {
index 24d22d0df79796b00d41201717d7beba4db990c1..bf82e515fbd081a623df555d4c47600bd69cd89c 100644 (file)
@@ -424,6 +424,10 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb,
        case CTDB_CONTROL_TRANS2_FINISHED:
                return ctdb_control_trans2_finished(ctdb, c);
 
+       case CTDB_CONTROL_TRANS2_ACTIVE:
+               CHECK_CONTROL_DATA_SIZE(sizeof(uint32_t));
+               return ctdb_control_trans2_active(ctdb, c, *(uint32_t *)indata.dptr);
+
        case CTDB_CONTROL_RECD_PING:
                CHECK_CONTROL_DATA_SIZE(0);
                return ctdb_control_recd_ping(ctdb);
@@ -469,6 +473,7 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb,
                }
                if (indata.dsize > 0) {
                        ctdb->recovery_lock_file = talloc_strdup(ctdb, discard_const(indata.dptr));
+                       ctdb->tunable.verify_recovery_lock = 1;
                }
                return 0;
 
@@ -552,6 +557,13 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb,
                CHECK_CONTROL_DATA_SIZE(0);
                return ctdb_control_transaction_cancel(ctdb);
 
+       case CTDB_CONTROL_REGISTER_NOTIFY:
+               return ctdb_control_register_notify(ctdb, client_id, indata);
+
+       case CTDB_CONTROL_DEREGISTER_NOTIFY:
+               CHECK_CONTROL_DATA_SIZE(sizeof(struct ctdb_client_notify_deregister));
+               return ctdb_control_deregister_notify(ctdb, client_id, indata);
+
        default:
                DEBUG(DEBUG_CRIT,(__location__ " Unknown CTDB control opcode %u\n", opcode));
                return -1;
index 532887c7842f788f5c598721b5010fa7aa212043..ab0437164e521292220eb1ff71b89bab21d0ead3 100644 (file)
 
 static void daemon_incoming_packet(void *, struct ctdb_req_header *);
 
-
 static void print_exit_message(void)
 {
        DEBUG(DEBUG_NOTICE,("CTDB daemon shutting down\n"));
 }
 
-
 /* called when the "startup" event script has finished */
 static void ctdb_start_transport(struct ctdb_context *ctdb)
 {
@@ -658,7 +656,7 @@ static void sig_child_handler(struct event_context *ev,
 /*
   start the protocol going as a daemon
 */
-int ctdb_start_daemon(struct ctdb_context *ctdb, bool do_fork)
+int ctdb_start_daemon(struct ctdb_context *ctdb, bool do_fork, bool use_syslog)
 {
        int res, ret = -1;
        struct fd_event *fde;
@@ -691,6 +689,11 @@ int ctdb_start_daemon(struct ctdb_context *ctdb, bool do_fork)
        }
        block_signal(SIGPIPE);
 
+       ctdbd_pid = getpid();
+
+
+       DEBUG(DEBUG_ERR, ("Starting CTDBD as pid : %u\n", ctdbd_pid));
+
        if (ctdb->do_setsched) {
                /* try to set us up as realtime */
                ctdb_set_scheduler(ctdb);
@@ -771,6 +774,14 @@ int ctdb_start_daemon(struct ctdb_context *ctdb, bool do_fork)
                DEBUG(DEBUG_CRIT,("Failed to set up signal handler for SIGCHLD\n"));
                exit(1);
        }
+
+       if (use_syslog) {
+               if (start_syslog_daemon(ctdb)) {
+                       DEBUG(DEBUG_CRIT, ("Failed to start syslog daemon\n"));
+                       exit(10);
+               }
+       }
+
          
        /* go into a wait loop to allow other nodes to complete */
        event_loop_wait(ctdb->ev);
@@ -1043,3 +1054,105 @@ int ctdb_daemon_send_message(struct ctdb_context *ctdb, uint32_t pnn,
        return 0;
 }
 
+
+
+struct ctdb_client_notify_list {
+       struct ctdb_client_notify_list *next, *prev;
+       struct ctdb_context *ctdb;
+       uint64_t srvid;
+       TDB_DATA data;
+};
+
+
+static int ctdb_client_notify_destructor(struct ctdb_client_notify_list *nl)
+{
+       int ret;
+
+       DEBUG(DEBUG_ERR,("Sending client notify message for srvid:%llu\n", (unsigned long long)nl->srvid));
+
+       ret = ctdb_daemon_send_message(nl->ctdb, CTDB_BROADCAST_CONNECTED, (unsigned long long)nl->srvid, nl->data);
+       if (ret != 0) {
+               DEBUG(DEBUG_ERR,("Failed to send client notify message\n"));
+       }
+
+       return 0;
+}
+
+int32_t ctdb_control_register_notify(struct ctdb_context *ctdb, uint32_t client_id, TDB_DATA indata)
+{
+       struct ctdb_client_notify_register *notify = (struct ctdb_client_notify_register *)indata.dptr;
+        struct ctdb_client *client = ctdb_reqid_find(ctdb, client_id, struct ctdb_client); 
+       struct ctdb_client_notify_list *nl;
+
+       DEBUG(DEBUG_ERR,("Register srvid %llu for client %d\n", (unsigned long long)notify->srvid, client_id));
+
+       if (indata.dsize < offsetof(struct ctdb_client_notify_register, notify_data)) {
+               DEBUG(DEBUG_ERR,(__location__ " Too little data in control : %d\n", (int)indata.dsize));
+               return -1;
+       }
+
+       if (indata.dsize != (notify->len + offsetof(struct ctdb_client_notify_register, notify_data))) {
+               DEBUG(DEBUG_ERR,(__location__ " Wrong amount of data in control. Got %d, expected %d\n", (int)indata.dsize, (int)(notify->len + offsetof(struct ctdb_client_notify_register, notify_data))));
+               return -1;
+       }
+
+
+        if (client == NULL) {
+                DEBUG(DEBUG_ERR,(__location__ " Could not find client parent structure. You can not send this control to a remote node\n"));
+                return -1;
+        }
+
+       for(nl=client->notify; nl; nl=nl->next) {
+               if (nl->srvid == notify->srvid) {
+                       break;
+               }
+       }
+       if (nl != NULL) {
+                DEBUG(DEBUG_ERR,(__location__ " Notification for srvid:%llu already exists for this client\n", (unsigned long long)notify->srvid));
+                return -1;
+        }
+
+       nl = talloc(client, struct ctdb_client_notify_list);
+       CTDB_NO_MEMORY(ctdb, nl);
+       nl->ctdb       = ctdb;
+       nl->srvid      = notify->srvid;
+       nl->data.dsize = notify->len;
+       nl->data.dptr  = talloc_size(nl, nl->data.dsize);
+       CTDB_NO_MEMORY(ctdb, nl->data.dptr);
+       memcpy(nl->data.dptr, notify->notify_data, nl->data.dsize);
+       
+       DLIST_ADD(client->notify, nl);
+       talloc_set_destructor(nl, ctdb_client_notify_destructor);
+
+       return 0;
+}
+
+int32_t ctdb_control_deregister_notify(struct ctdb_context *ctdb, uint32_t client_id, TDB_DATA indata)
+{
+       struct ctdb_client_notify_deregister *notify = (struct ctdb_client_notify_deregister *)indata.dptr;
+        struct ctdb_client *client = ctdb_reqid_find(ctdb, client_id, struct ctdb_client); 
+       struct ctdb_client_notify_list *nl;
+
+       DEBUG(DEBUG_ERR,("Deregister srvid %llu for client %d\n", (unsigned long long)notify->srvid, client_id));
+
+        if (client == NULL) {
+                DEBUG(DEBUG_ERR,(__location__ " Could not find client parent structure. You can not send this control to a remote node\n"));
+                return -1;
+        }
+
+       for(nl=client->notify; nl; nl=nl->next) {
+               if (nl->srvid == notify->srvid) {
+                       break;
+               }
+       }
+       if (nl == NULL) {
+                DEBUG(DEBUG_ERR,(__location__ " No notification for srvid:%llu found for this client\n", (unsigned long long)notify->srvid));
+                return -1;
+        }
+
+       DLIST_REMOVE(client->notify, nl);
+       talloc_set_destructor(nl, NULL);
+       talloc_free(nl);
+
+       return 0;
+}
index 7cd58ad14286c4ab02113350f7b9d5f8ca3150db..a404cdf02e1792cff3f8dbb3c72d7c0077939f05 100644 (file)
 
 #include "includes.h"
 #include "lib/events/events.h"
+#include "../include/ctdb.h"
 #include "../include/ctdb_private.h"
 #include "system/syslog.h"
 #include "system/time.h"
 #include "system/filesys.h"
 
+static bool syslogd_is_started;
+
+struct syslog_message {
+       uint32_t level;
+       uint32_t len;
+       char message[1];
+};
+
+
+
+/*
+ * this is for the syslog daemon, we can not use DEBUG here
+ */
+int start_syslog_daemon(struct ctdb_context *ctdb)
+{
+       pid_t child;
+       int syslog_fd = -1;
+       struct sockaddr_in syslog_sin;
+
+       child = fork();
+       if (child == (pid_t)-1) {
+               printf("Failed to create syslog child process\n");
+               return -1;
+       }
+
+       syslogd_is_started = 1;
+
+       if (child != 0) {
+               return 0;
+       }
+
+       syslog_fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
+       if (syslog_fd == -1) {
+               printf("Failed to create syslog socket\n");
+               return -1;
+       }
+
+       syslog_sin.sin_family = AF_INET;
+       syslog_sin.sin_port   = htons(CTDB_PORT);
+       syslog_sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK);    
+
+       if (bind(syslog_fd, &syslog_sin, sizeof(syslog_sin)) == -1) {
+               if (errno == EADDRINUSE) {
+                       /* this is ok, we already have a syslog daemon */
+                       _exit(0);
+               }
+               printf("syslog daemon failed to bind to socket. errno:%d(%s)\n", errno, strerror(errno));
+               _exit(10);
+       }
+
+       /* just loop over the messages */
+       while (1) {
+               int count;
+               char str[1024];
+               struct syslog_message *msg;
+
+               count = recv(syslog_fd, str, sizeof(str), 0);
+               if (count < sizeof(struct syslog_message)) {
+                       continue;
+               }
+               msg = (struct syslog_message *)str;
+
+               syslog(msg->level, "%s", msg->message);
+       }
+       _exit(10);
+}
+
 struct ctdb_log_state {
        int fd, pfd;
        char buf[1024];
@@ -39,7 +107,18 @@ static struct ctdb_log_state *log_state;
  */
 static void ctdb_syslog_log(const char *format, va_list ap)
 {
+       struct syslog_message *msg;
        int level = LOG_DEBUG;
+       char *s = NULL;
+       int len, ret;
+       int syslog_fd;
+       struct sockaddr_in syslog_sin;
+
+       ret = vasprintf(&s, format, ap);
+       if (ret == -1) {
+               return;
+       }
+
        switch (this_log_level) {
        case DEBUG_EMERG: 
                level = LOG_EMERG; 
@@ -66,7 +145,41 @@ static void ctdb_syslog_log(const char *format, va_list ap)
                level = LOG_DEBUG;
                break;          
        }
-       vsyslog(level, format, ap);
+
+       len = offsetof(struct syslog_message, message) + strlen(s) + 1;
+       msg = malloc(len);
+       if (msg == NULL) {
+               free(s);
+               return;
+       }
+       msg->level = level;
+       msg->len   = strlen(s);
+       strcpy(msg->message, s);
+
+       if (syslogd_is_started == 0) {
+               syslog(msg->level, "%s", msg->message);
+       } else {
+               syslog_fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
+               if (syslog_fd == -1) {
+                       printf("Failed to create syslog socket\n");
+                       free(s);
+                       free(msg);
+                       return;
+               }
+
+               syslog_sin.sin_family = AF_INET;
+               syslog_sin.sin_port   = htons(CTDB_PORT);
+               syslog_sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK);    
+
+       
+               ret = sendto(syslog_fd, msg, len, 0, &syslog_sin, sizeof(syslog_sin));
+               /* no point in checking here since we cant log an error */
+
+               close(syslog_fd);
+       }
+
+       free(s);
+       free(msg);
 }
 
 
@@ -128,12 +241,15 @@ static void ctdb_logfile_log_add(const char *format, va_list ap)
        }
 }
 
+
+
 /*
   choose the logfile location
 */
 int ctdb_set_logfile(struct ctdb_context *ctdb, const char *logfile, bool use_syslog)
 {
        int ret;
+
        ctdb->log = talloc_zero(ctdb, struct ctdb_log_state);
        if (ctdb->log == NULL) {
                printf("talloc_zero failed\n");
index ec29076c8d8a13753cedbf0d636029cc0a2023dd..1aa0f697476042e4d4574fbe74d0fc32c4ae7a22 100644 (file)
@@ -26,6 +26,7 @@
 #include "../include/ctdb_private.h"
 #include "db_wrap.h"
 #include "lib/util/dlinklist.h"
+#include <ctype.h>
 
 /*
   this is the dummy null procedure that all databases support
@@ -294,7 +295,8 @@ static int ctdb_local_attach(struct ctdb_context *ctdb, const char *db_name, boo
 
        ret = ctdb_vacuum_init(ctdb_db);
        if (ret != 0) {
-               DEBUG(DEBUG_CRIT,("Failed to setup vacuuming for database '%s'\n", ctdb_db->db_name));
+               DEBUG(DEBUG_CRIT,("Failed to setup vacuuming for "
+                                 "database '%s'\n", ctdb_db->db_name));
                talloc_free(ctdb_db);
                return -1;
        }
@@ -316,7 +318,9 @@ int32_t ctdb_control_db_attach(struct ctdb_context *ctdb, TDB_DATA indata,
 {
        const char *db_name = (const char *)indata.dptr;
        struct ctdb_db_context *db;
+#if 0
        struct ctdb_node *node = ctdb->nodes[ctdb->pnn];
+#endif
 
        /* the client can optionally pass additional tdb flags, but we
           only allow a subset of those on the database in ctdb. Note
@@ -324,25 +328,26 @@ int32_t ctdb_control_db_attach(struct ctdb_context *ctdb, TDB_DATA indata,
           srvid to the attach control */
        tdb_flags &= TDB_NOSYNC;
 
-       /* If the node is inactive it is not part of the cluster
-          and we should not allow clients to attach to any
-          databases
-       */
-       if (node->flags & NODE_FLAGS_INACTIVE) {
-               DEBUG(DEBUG_ERR,("DB Attach to database %s refused since node is inactive (disconnected or banned)\n", db_name));
-               return -1;
-       }
-
-
        /* see if we already have this name */
        db = ctdb_db_handle(ctdb, db_name);
-       if (db) {
+       if (db != NULL) {
                outdata->dptr  = (uint8_t *)&db->db_id;
                outdata->dsize = sizeof(db->db_id);
                tdb_add_flags(db->ltdb->tdb, tdb_flags);
                return 0;
        }
 
+#if 0
+       /* If the node is inactive it is not part of the cluster
+          and we should not allow clients to attach to any new
+          databases
+       */
+       if (node->flags & NODE_FLAGS_INACTIVE) {
+               DEBUG(DEBUG_ERR,("DB Attach to database %s refused since node is inactive (disconnected or banned)\n", db_name));
+               return -1;
+       }
+#endif
+
        if (ctdb_local_attach(ctdb, db_name, persistent) != 0) {
                return -1;
        }
@@ -386,26 +391,30 @@ int ctdb_attach_persistent(struct ctdb_context *ctdb)
        }
 
        while ((de=readdir(d))) {
-               char *p, *s;
+               char *p, *s, *q;
                size_t len = strlen(de->d_name);
                uint32_t node;
+               int invalid_name = 0;
                
                s = talloc_strdup(ctdb, de->d_name);
                CTDB_NO_MEMORY(ctdb, s);
 
-               /* ignore names ending in .bak */
-               p = strstr(s, ".bak");
-               if (p != NULL) {
-                       continue;
-               }
-
                /* only accept names ending in .tdb */
                p = strstr(s, ".tdb.");
                if (len < 7 || p == NULL) {
                        talloc_free(s);
                        continue;
                }
-               if (sscanf(p+5, "%u", &node) != 1 || node != ctdb->pnn) {
+
+               /* only accept names ending with .tdb. and any number of digits */
+               q = p+5;
+               while (*q != 0 && invalid_name == 0) {
+                       if (!isdigit(*q++)) {
+                               invalid_name = 1;
+                       }
+               }
+               if (invalid_name == 1 || sscanf(p+5, "%u", &node) != 1 || node != ctdb->pnn) {
+                       DEBUG(DEBUG_ERR,("Ignoring persistent database '%s'\n", de->d_name));
                        talloc_free(s);
                        continue;
                }
index 056d8311150bdcb7f0fe17bbe8ec7b7a94e5faa7..efba8f9e14294dc2cc19e8cc3d4ba1eec239495f 100644 (file)
@@ -126,7 +126,7 @@ static void ctdb_health_callback(struct ctdb_context *ctdb, int status, void *p)
        if (status != 0 && !(node->flags & NODE_FLAGS_UNHEALTHY)) {
                DEBUG(DEBUG_NOTICE,("monitor event failed - disabling node\n"));
                node->flags |= NODE_FLAGS_UNHEALTHY;
-               ctdb->monitor->next_interval = 1;
+               ctdb->monitor->next_interval = 5;
                if (ctdb->tunable.disable_when_unhealthy != 0) {
                        DEBUG(DEBUG_INFO, ("DISABLING node since it became unhealthy\n"));
                        node->flags |= NODE_FLAGS_DISABLED;
@@ -144,7 +144,7 @@ static void ctdb_health_callback(struct ctdb_context *ctdb, int status, void *p)
        } else if (status == 0 && (node->flags & NODE_FLAGS_UNHEALTHY)) {
                DEBUG(DEBUG_NOTICE,("monitor event OK - node re-enabled\n"));
                node->flags &= ~NODE_FLAGS_UNHEALTHY;
-               ctdb->monitor->next_interval = 1;
+               ctdb->monitor->next_interval = 5;
 
                ctdb_run_notification_script(ctdb, "healthy");
 
@@ -194,7 +194,7 @@ static void ctdb_startup_callback(struct ctdb_context *ctdb, int status, void *p
        } else if (status == 0) {
                DEBUG(DEBUG_NOTICE,("startup event OK - enabling monitoring\n"));
                ctdb->done_startup = true;
-               ctdb->monitor->next_interval = 1;
+               ctdb->monitor->next_interval = 5;
                ctdb_run_notification_script(ctdb, "startup");
        }
 
@@ -211,7 +211,7 @@ static void ctdb_check_health(struct event_context *ev, struct timed_event *te,
                              struct timeval t, void *private_data)
 {
        struct ctdb_context *ctdb = talloc_get_type(private_data, struct ctdb_context);
-       int ret;
+       int ret = 0;
 
        if (ctdb->recovery_mode != CTDB_RECOVERY_NORMAL ||
            (ctdb->monitor->monitoring_mode == CTDB_MONITORING_DISABLED && ctdb->done_startup)) {
@@ -223,7 +223,7 @@ static void ctdb_check_health(struct event_context *ev, struct timed_event *te,
        
        if (!ctdb->done_startup) {
                ret = ctdb_event_script_callback(ctdb, 
-                                                timeval_current_ofs(ctdb->tunable.script_timeout, 0),
+                                                timeval_set(ctdb->tunable.script_timeout, 0),
                                                 ctdb->monitor->monitor_context, ctdb_startup_callback, 
                                                 ctdb, "startup");
        } else {
@@ -241,26 +241,26 @@ static void ctdb_check_health(struct event_context *ev, struct timed_event *te,
                                break;
                        }
                }
-               if (skip_monitoring) {
+               if (skip_monitoring != 0) {
                        event_add_timed(ctdb->ev, ctdb->monitor->monitor_context,
                                        timeval_current_ofs(ctdb->monitor->next_interval, 0), 
                                        ctdb_check_health, ctdb);
                        return;
                } else {
                        ret = ctdb_event_script_callback(ctdb, 
-                                                timeval_current_ofs(ctdb->tunable.script_timeout, 0),
-                                                ctdb->monitor->monitor_context, ctdb_health_callback, 
-                                                ctdb, "monitor");
+                                       timeval_set(ctdb->tunable.script_timeout, 0),
+                                       ctdb->monitor->monitor_context, ctdb_health_callback,
+                                       ctdb, "monitor");
                }
        }
 
        if (ret != 0) {
                DEBUG(DEBUG_ERR,("Unable to launch monitor event script\n"));
-               ctdb->monitor->next_interval = 1;
+               ctdb->monitor->next_interval = 5;
                event_add_timed(ctdb->ev, ctdb->monitor->monitor_context, 
-                               timeval_current_ofs(1, 0), 
-                               ctdb_check_health, ctdb);
-       }       
+                       timeval_current_ofs(5, 0), 
+                       ctdb_check_health, ctdb);
+       }
 }
 
 /* 
@@ -279,7 +279,7 @@ void ctdb_disable_monitoring(struct ctdb_context *ctdb)
 void ctdb_enable_monitoring(struct ctdb_context *ctdb)
 {
        ctdb->monitor->monitoring_mode  = CTDB_MONITORING_ACTIVE;
-       ctdb->monitor->next_interval = 2;
+       ctdb->monitor->next_interval = 5;
        DEBUG(DEBUG_INFO,("Monitoring has been enabled\n"));
 }
 
@@ -292,7 +292,7 @@ void ctdb_stop_monitoring(struct ctdb_context *ctdb)
        ctdb->monitor->monitor_context = NULL;
 
        ctdb->monitor->monitoring_mode  = CTDB_MONITORING_DISABLED;
-       ctdb->monitor->next_interval = 1;
+       ctdb->monitor->next_interval = 5;
        DEBUG(DEBUG_NOTICE,("Monitoring has been stopped\n"));
 }
 
@@ -310,7 +310,7 @@ void ctdb_start_monitoring(struct ctdb_context *ctdb)
        ctdb->monitor = talloc(ctdb, struct ctdb_monitor_state);
        CTDB_NO_MEMORY_FATAL(ctdb, ctdb->monitor);
 
-       ctdb->monitor->next_interval = 1;
+       ctdb->monitor->next_interval = 5;
 
        ctdb->monitor->monitor_context = talloc_new(ctdb->monitor);
        CTDB_NO_MEMORY_FATAL(ctdb, ctdb->monitor->monitor_context);
@@ -342,7 +342,9 @@ int32_t ctdb_control_modflags(struct ctdb_context *ctdb, TDB_DATA indata)
 
        node         = ctdb->nodes[c->pnn];
        old_flags    = node->flags;
-       c->old_flags  = node->flags;
+       if (c->pnn != ctdb->pnn) {
+               c->old_flags  = node->flags;
+       }
        node->flags   = c->new_flags & ~NODE_FLAGS_DISCONNECTED;
        node->flags  |= (c->old_flags & NODE_FLAGS_DISCONNECTED);
 
index cb77bf092d107c9763686f49176487c7a844cf74..02ca7c8d9ca7fb3128fb47bb9aeec346c5010cbb 100644 (file)
@@ -113,7 +113,7 @@ int32_t ctdb_control_trans2_commit(struct ctdb_context *ctdb,
        ctdb_db = find_ctdb_db(ctdb, m->db_id);
        if (ctdb_db == NULL) {
                DEBUG(DEBUG_ERR,(__location__ " ctdb_control_trans2_commit: "
-                                "Unknown database 0x%08x\n", m->db_id));
+                                "Unknown database db_id[0x%08x]\n", m->db_id));
                return -1;
        }
 
@@ -138,8 +138,11 @@ int32_t ctdb_control_trans2_commit(struct ctdb_context *ctdb,
        switch (c->opcode) {
        case CTDB_CONTROL_PERSISTENT_STORE:
                if (ctdb_db->transaction_active) {
-                       DEBUG(DEBUG_ERR, (__location__ " trans2_commit client db_id[%d] transaction active - refusing persistent store\n",
-                               client->db_id));
+                       DEBUG(DEBUG_ERR, (__location__ " trans2_commit: a "
+                                         "transaction is active on database "
+                                         "db_id[0x%08x] - refusing persistent "
+                                        " store for client id[0x%08x]\n",
+                                         ctdb_db->db_id, client->client_id));
                        return -1;
                }
                if (client->num_persistent_updates > 0) {
@@ -148,30 +151,41 @@ int32_t ctdb_control_trans2_commit(struct ctdb_context *ctdb,
                break;
        case CTDB_CONTROL_TRANS2_COMMIT:
                if (ctdb_db->transaction_active) {
-                       DEBUG(DEBUG_ERR,(__location__ " trans2_commit: client "
-                                        "already has a transaction commit "
-                                        "active on db_id[%d]\n",
-                                        client->db_id));
+                       DEBUG(DEBUG_ERR,(__location__ " trans2_commit: there is"
+                                        " already a transaction commit "
+                                        "active on db_id[0x%08x] - forbidding "
+                                        "client_id[0x%08x] to commit\n",
+                                        ctdb_db->db_id, client->client_id));
                        return -1;
                }
                if (client->db_id != 0) {
                        DEBUG(DEBUG_ERR,(__location__ " ERROR: trans2_commit: "
-                                        "client-db_id[%d] != 0\n",
-                                        client->db_id));
+                                        "client-db_id[0x%08x] != 0 "
+                                        "(client_id[0x%08x])\n",
+                                        client->db_id, client->client_id));
                        return -1;
                }
                client->num_persistent_updates++;
                ctdb_db->transaction_active = true;
                client->db_id = m->db_id;
+               DEBUG(DEBUG_DEBUG, (__location__ " client id[0x%08x] started to"
+                                 " commit transaction on db id[0x%08x]\n",
+                                 client->client_id, client->db_id));
                break;
        case CTDB_CONTROL_TRANS2_COMMIT_RETRY:
                /* already updated from the first commit */
                if (client->db_id != m->db_id) {
                        DEBUG(DEBUG_ERR,(__location__ " ERROR: trans2_commit "
-                                        "retry: client-db_id[%d] != db_id[%d]"
-                                        "\n", client->db_id, m->db_id));
+                                        "retry: client-db_id[0x%08x] != "
+                                        "db_id[0x%08x] (client_id[0x%08x])\n",
+                                        client->db_id,
+                                        m->db_id, client->client_id));
                        return -1;
                }
+               DEBUG(DEBUG_DEBUG, (__location__ " client id[0x%08x] started "
+                                   "transaction commit retry on "
+                                   "db_id[0x%08x]\n",
+                                   client->client_id, client->db_id));
                break;
        }
 
@@ -563,6 +577,10 @@ int32_t ctdb_control_trans2_finished(struct ctdb_context *ctdb,
        }
        client->num_persistent_updates--;
 
+       DEBUG(DEBUG_DEBUG, (__location__ " client id[0x%08x] finished "
+                           "transaction commit db_id[0x%08x]\n",
+                           client->client_id, ctdb_db->db_id));
+
        return 0;
 }
 
@@ -598,12 +616,40 @@ int32_t ctdb_control_trans2_error(struct ctdb_context *ctdb,
                client->num_persistent_updates--;
        }
 
-       DEBUG(DEBUG_ERR,(__location__ " Forcing recovery\n"));
+       DEBUG(DEBUG_ERR,(__location__ " An error occurred during transaction on"
+                        " db_id[0x%08x] - forcing recovery\n",
+                        ctdb_db->db_id));
        client->ctdb->recovery_mode = CTDB_RECOVERY_ACTIVE;
 
        return 0;
 }
 
+/**
+ * Tell whether a transaction is active on this node on the give DB.
+ */
+int32_t ctdb_control_trans2_active(struct ctdb_context *ctdb,
+                                  struct ctdb_req_control *c,
+                                  uint32_t db_id)
+{
+       struct ctdb_db_context *ctdb_db;
+       struct ctdb_client *client = ctdb_reqid_find(ctdb, c->client_id, struct ctdb_client);
+
+       ctdb_db = find_ctdb_db(ctdb, db_id);
+       if (!ctdb_db) {
+               DEBUG(DEBUG_ERR,(__location__ " Unknown db 0x%08x\n", db_id));
+               return -1;
+       }
+
+       if (client->db_id == db_id) {
+               return 0;
+       }
+
+       if (ctdb_db->transaction_active) {
+               return 1;
+       } else {
+               return 0;
+       }
+}
 
 /*
   backwards compatibility:
index 862168e97eab2c778d1eebc5592a2c5319cd5450..ccac8e62e6d723f9c6dfc9afd4501bd007e2e222 100644 (file)
@@ -963,7 +963,7 @@ int32_t ctdb_control_end_recovery(struct ctdb_context *ctdb,
        ctdb_disable_monitoring(ctdb);
 
        ret = ctdb_event_script_callback(ctdb, 
-                                        timeval_current_ofs(ctdb->tunable.script_timeout, 0),
+                                        timeval_set(ctdb->tunable.script_timeout, 0),
                                         state, 
                                         ctdb_end_recovery_callback, 
                                         state, "recovered");
@@ -1017,7 +1017,7 @@ int32_t ctdb_control_start_recovery(struct ctdb_context *ctdb,
        ctdb_disable_monitoring(ctdb);
 
        ret = ctdb_event_script_callback(ctdb, 
-                                        timeval_current_ofs(ctdb->tunable.script_timeout, 0),
+                                        timeval_set(ctdb->tunable.script_timeout, 0),
                                         state, 
                                         ctdb_start_recovery_callback, 
                                         state, "startrecovery");
@@ -1231,7 +1231,7 @@ int32_t ctdb_control_stop_node(struct ctdb_context *ctdb, struct ctdb_req_contro
        ctdb_disable_monitoring(ctdb);
 
        ret = ctdb_event_script_callback(ctdb, 
-                                        timeval_current_ofs(ctdb->tunable.script_timeout, 0),
+                                        timeval_set(ctdb->tunable.script_timeout, 0),
                                         state, 
                                         ctdb_stop_node_callback, 
                                         state, "stopped");
index 432af0710eee320e159cc315f5085d396e3b8e55..ecdcd99dd189676c645e5978d3f03ddc2fa102f1 100644 (file)
@@ -1856,14 +1856,14 @@ static void process_ipreallocate_requests(struct ctdb_context *ctdb, struct ctdb
 
        for (callers=rec->reallocate_callers; callers; callers=callers->next) {
                DEBUG(DEBUG_INFO,("Sending ip reallocate reply message to "
-                                 "%u:%lu\n", (unsigned)callers->rd->pnn,
-                                 (long unsigned)callers->rd->srvid));
+                                 "%u:%llu\n", (unsigned)callers->rd->pnn,
+                                 (unsigned long long)callers->rd->srvid));
                ret = ctdb_send_message(ctdb, callers->rd->pnn, callers->rd->srvid, result);
                if (ret != 0) {
                        DEBUG(DEBUG_ERR,("Failed to send ip reallocate reply "
-                                        "message to %u:%lu\n",
+                                        "message to %u:%llu\n",
                                         (unsigned)callers->rd->pnn,
-                                        (long unsigned)callers->rd->srvid));
+                                        (unsigned long long)callers->rd->srvid));
                }
        }
 
@@ -2056,11 +2056,47 @@ static void push_flags_handler(struct ctdb_context *ctdb, uint64_t srvid,
 {
        int ret;
        struct ctdb_node_flag_change *c = (struct ctdb_node_flag_change *)data.dptr;
+       struct ctdb_node_map *nodemap=NULL;
+       TALLOC_CTX *tmp_ctx = talloc_new(ctdb);
+       uint32_t recmaster;
+       uint32_t *nodes;
 
-       ret = ctdb_ctrl_modflags(ctdb, CONTROL_TIMEOUT(), c->pnn, c->new_flags, ~c->new_flags);
+       /* find the recovery master */
+       ret = ctdb_ctrl_getrecmaster(ctdb, tmp_ctx, CONTROL_TIMEOUT(), CTDB_CURRENT_NODE, &recmaster);
        if (ret != 0) {
-               DEBUG(DEBUG_ERR, (__location__ " Unable to update nodeflags on remote nodes\n"));
+               DEBUG(DEBUG_ERR, (__location__ " Unable to get recmaster from local node\n"));
+               talloc_free(tmp_ctx);
+               return;
+       }
+
+       /* read the node flags from the recmaster */
+       ret = ctdb_ctrl_getnodemap(ctdb, CONTROL_TIMEOUT(), recmaster, tmp_ctx, &nodemap);
+       if (ret != 0) {
+               DEBUG(DEBUG_ERR, (__location__ " Unable to get nodemap from node %u\n", c->pnn));
+               talloc_free(tmp_ctx);
+               return;
        }
+       if (c->pnn >= nodemap->num) {
+               DEBUG(DEBUG_ERR,(__location__ " Nodemap from recmaster does not contain node %d\n", c->pnn));
+               talloc_free(tmp_ctx);
+               return;
+       }
+
+       /* send the flags update to all connected nodes */
+       nodes = list_of_connected_nodes(ctdb, nodemap, tmp_ctx, true);
+
+       if (ctdb_client_async_control(ctdb, CTDB_CONTROL_MODIFY_FLAGS,
+                                     nodes, 0, CONTROL_TIMEOUT(),
+                                     false, data,
+                                     NULL, NULL,
+                                     NULL) != 0) {
+               DEBUG(DEBUG_ERR, (__location__ " ctdb_control to modify node flags failed\n"));
+
+               talloc_free(tmp_ctx);
+               return;
+       }
+
+       talloc_free(tmp_ctx);
 }
 
 
index 559f7fbf166f82daa4b31009735e250c0bd2e9e1..a140578abed4633915090e43160e8e560d7cb750 100644 (file)
@@ -235,7 +235,7 @@ int32_t ctdb_control_takeover_ip(struct ctdb_context *ctdb,
                vnn->iface));
 
        ret = ctdb_event_script_callback(ctdb, 
-                                        timeval_current_ofs(ctdb->tunable.script_timeout, 0),
+                                        timeval_set(ctdb->tunable.script_timeout, 0),
                                         state, takeover_ip_callback, state,
                                         "takeip %s %s %u",
                                         vnn->iface, 
@@ -391,7 +391,7 @@ int32_t ctdb_control_release_ip(struct ctdb_context *ctdb,
        state->vnn   = vnn;
 
        ret = ctdb_event_script_callback(ctdb, 
-                                        timeval_current_ofs(ctdb->tunable.script_timeout, 0),
+                                        timeval_set(ctdb->tunable.script_timeout, 0),
                                         state, release_ip_callback, state,
                                         "releaseip %s %s %u",
                                         vnn->iface, 
@@ -2094,7 +2094,7 @@ int32_t ctdb_control_del_public_address(struct ctdb_context *ctdb, TDB_DATA inda
                        DLIST_REMOVE(ctdb->vnn, vnn);
 
                        ret = ctdb_event_script_callback(ctdb, 
-                                        timeval_current_ofs(ctdb->tunable.script_timeout, 0),
+                                        timeval_set(ctdb->tunable.script_timeout, 0),
                                         mem_ctx, delete_ip_callback, mem_ctx,
                                         "releaseip %s %s %u",
                                         vnn->iface, 
index c461bcaaaf23f46448dda62715eb89d4aa8f25ce..0bf87b93fc22c0c31e039b8407bea61d4cb95be0 100644 (file)
@@ -37,8 +37,8 @@ static const struct {
        { "TakeoverTimeout",      5,  offsetof(struct ctdb_tunable, takeover_timeout) },
        { "MonitorInterval",     15,  offsetof(struct ctdb_tunable, monitor_interval) },
        { "TickleUpdateInterval",20,  offsetof(struct ctdb_tunable, tickle_update_interval) },
-       { "EventScriptTimeout",  60,  offsetof(struct ctdb_tunable, script_timeout) },
-       { "EventScriptBanCount",  5,  offsetof(struct ctdb_tunable, script_ban_count) },
+       { "EventScriptTimeout",  30,  offsetof(struct ctdb_tunable, script_timeout) },
+       { "EventScriptBanCount", 10,  offsetof(struct ctdb_tunable, script_ban_count) },
        { "EventScriptUnhealthyOnTimeout", 0, offsetof(struct ctdb_tunable, script_unhealthy_on_timeout) },
        { "RecoveryGracePeriod", 120,  offsetof(struct ctdb_tunable, recovery_grace_period) },
        { "RecoveryBanPeriod",  300,  offsetof(struct ctdb_tunable, recovery_ban_period) },
index 6612d0bd370a207762429f7a06bd4a9114a6d1ea..da887db4f0c949bbc8cd54371071f81cb4bcca92 100644 (file)
@@ -131,7 +131,7 @@ static int vacuum_traverse(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data,
 
                hash = ctdb_hash(&key);
                if (trbt_lookup32(vdata->delete_tree, hash)) {
-                       DEBUG(DEBUG_INFO, (__location__ " Hash collission when vacuuming, skipping this record.\n"));
+                       DEBUG(DEBUG_DEBUG, (__location__ " Hash collission when vacuuming, skipping this record.\n"));
                } 
                else {
                        struct delete_record_data *dd;
@@ -401,8 +401,18 @@ static int repack_traverse(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data,
                 * there might be hash collisions so we have to compare the keys here to be sure
                 */
                if (kd && kd->key.dsize == key.dsize && memcmp(kd->key.dptr, key.dptr, key.dsize) == 0) {
-                       vdata->vacuumed++;
-                       return 0;
+                       struct ctdb_ltdb_header *hdr = (struct ctdb_ltdb_header *)data.dptr;
+                       /*
+                        * we have to check if the record hasn't changed in the meantime in order to
+                        * savely remove it from the database
+                        */
+                       if (data.dsize == sizeof(struct ctdb_ltdb_header) &&
+                               hdr->dmaster == kd->ctdb->pnn &&
+                               ctdb_lmaster(kd->ctdb, &(kd->key)) == kd->ctdb->pnn &&
+                               kd->hdr.rsn == hdr->rsn) {
+                               vdata->vacuumed++;
+                               return 0;
+                       }
                }
        }
        if (tdb_store(vdata->dest_db, key, data, TDB_INSERT) != 0) {
@@ -636,8 +646,8 @@ static int ctdb_repack_db(struct ctdb_db_context *ctdb_db, TALLOC_CTX *mem_ctx)
         * decide if a repack is necessary
         */
        if (size < repack_limit && vdata->delete_count < vacuum_limit) {
-               talloc_free(vdata);
                update_tuning_db(ctdb_db, vdata, size);
+               talloc_free(vdata);
                return 0;
        }
 
@@ -862,6 +872,11 @@ ctdb_vacuum_event(struct event_context *ev, struct timed_event *te,
  */
 int ctdb_vacuum_init(struct ctdb_db_context *ctdb_db)
 {
+       if (ctdb_db->persistent != 0) {
+               DEBUG(DEBUG_ERR,("Vacuuming is disabled for persistent database %s\n", ctdb_db->db_name));
+               return 0;
+       }
+
        ctdb_db->vacuum_handle = talloc(ctdb_db, struct ctdb_vacuum_handle);
        CTDB_NO_MEMORY(ctdb_db->ctdb, ctdb_db->vacuum_handle);
 
index 0410ad99e51604aa9e357c5980d7225c999f292a..8647aad189284c956e5c474f3e146217b1a7c50d 100644 (file)
@@ -322,5 +322,5 @@ int main(int argc, const char *argv[])
        }
 
        /* start the protocol running (as a child) */
-       return ctdb_start_daemon(ctdb, interactive?False:True);
+       return ctdb_start_daemon(ctdb, interactive?False:True, options.use_syslog);
 }
index aae5eef11d4987ee2a8ac9b111e229664198ee47..7ad66c6c6d00f2cb7032a4d6751233b1d1a400d9 100644 (file)
@@ -18,6 +18,7 @@
 */
 
 #include "includes.h"
+#include <time.h>
 #include "system/filesys.h"
 #include "system/wait.h"
 #include "system/dir.h"
@@ -31,45 +32,30 @@ static struct {
        const char *script_running;
 } child_state;
 
+static void ctdb_event_script_timeout(struct event_context *ev, struct timed_event *te, struct timeval t, void *p);
+
 /*
   ctdbd sends us a SIGTERM when we should time out the current script
  */
 static void sigterm(int sig)
 {
-       FILE *p;
+       char tbuf[100], buf[200];
+       time_t t;
 
        DEBUG(DEBUG_ERR,("Timed out running script '%s' after %.1f seconds pid :%d\n", 
                 child_state.script_running, timeval_elapsed(&child_state.start), getpid()));
 
-       p = popen("pstree -p", "r");
-       if (p == NULL) {
-               DEBUG(DEBUG_ERR,("Failed popen to collect pstree for hung script\n"));
-       } else {
-               char buf[256];
-               int count;
-
-               DEBUG(DEBUG_ERR,("PSTREE:\n"));
-               while(!feof(p)){
-                       count=fread(buf, 1, 255, p);
-                       if (count == EOF) {
-                               break;
-                       }
-                       if (count < 0) {
-                               break;
-                       }
-                       if (count == 0) {
-                               break;
-                       }
-                       buf[count] = 0;
-                       DEBUG(DEBUG_ERR,("%s", buf)); 
-               }
-               DEBUG(DEBUG_ERR,("END OF PSTREE OUTPUT\n"));
-               pclose(p);
-       }
+       t = time(NULL);
+
+       strftime(tbuf, sizeof(tbuf)-1, "%Y%m%d%H%M%S",  localtime(&t));
+       sprintf(buf, "pstree -p >/tmp/ctdb.event.%s.%d", tbuf, getpid());
+       system(buf);
+
+       DEBUG(DEBUG_ERR,("Logged timedout eventscript : %s\n", buf));
 
        /* all the child processes will be running in the same process group */
        kill(-getpgrp(), SIGKILL);
-       exit(1);
+       _exit(1);
 }
 
 struct ctdb_event_script_state {
@@ -79,6 +65,8 @@ struct ctdb_event_script_state {
        int fd[2];
        void *private_data;
        const char *options;
+        struct timed_event *te;
+       struct timeval timeout;
 };
 
 
@@ -93,11 +81,12 @@ struct ctdb_monitor_script_status {
        char *output;
 };
 
-struct ctdb_monitoring_status {
+struct ctdb_monitor_status {
        struct timeval start;
        struct timeval finished;
        int32_t status;
        struct ctdb_monitor_script_status *scripts;
+       struct ctdb_event_script_state *state;
 };
 
 
@@ -106,9 +95,7 @@ struct ctdb_monitoring_status {
  */
 int ctdb_log_event_script_output(struct ctdb_context *ctdb, char *str, uint16_t len)
 {
-       struct ctdb_monitoring_status *monitoring_status =
-               talloc_get_type(ctdb->script_monitoring_ctx,
-                       struct ctdb_monitoring_status);
+       struct ctdb_monitor_status *monitoring_status = (struct ctdb_monitor_status *)ctdb->script_monitor_ctx;
        struct ctdb_monitor_script_status *script;
 
        if (monitoring_status == NULL) {
@@ -134,21 +121,15 @@ int ctdb_log_event_script_output(struct ctdb_context *ctdb, char *str, uint16_t
  */
 int32_t ctdb_control_event_script_init(struct ctdb_context *ctdb)
 {
-       struct ctdb_monitoring_status *monitoring_status;
+       struct ctdb_monitor_status *monitoring_status = (struct ctdb_monitor_status *)ctdb->script_monitor_ctx;
 
        DEBUG(DEBUG_INFO, ("event script init called\n"));
-       if (ctdb->script_monitoring_ctx != NULL) {
-               talloc_free(ctdb->script_monitoring_ctx);
-               ctdb->script_monitoring_ctx = NULL;
-       }
 
-       monitoring_status = talloc_zero(ctdb, struct ctdb_monitoring_status);
        if (monitoring_status == NULL) {
-               DEBUG(DEBUG_ERR, (__location__ " ERROR: Failed to talloc script_monitoring context\n"));
-               return -1;
+               DEBUG(DEBUG_ERR,(__location__ " Init called when context is NULL\n"));
+               return 0;
        }
 
-       ctdb->script_monitoring_ctx = monitoring_status;
        monitoring_status->start = timeval_current();   
 
        return 0;
@@ -161,9 +142,8 @@ int32_t ctdb_control_event_script_init(struct ctdb_context *ctdb)
 int32_t ctdb_control_event_script_start(struct ctdb_context *ctdb, TDB_DATA indata)
 {
        const char *name = (const char *)indata.dptr;
-       struct ctdb_monitoring_status *monitoring_status =
-               talloc_get_type(ctdb->script_monitoring_ctx,
-                       struct ctdb_monitoring_status);
+       struct ctdb_monitor_status *monitoring_status = (struct ctdb_monitor_status *)ctdb->script_monitor_ctx;
+       struct ctdb_event_script_state *state;
        struct ctdb_monitor_script_status *script;
 
        DEBUG(DEBUG_INFO, ("event script start called : %s\n", name));
@@ -185,6 +165,19 @@ int32_t ctdb_control_event_script_start(struct ctdb_context *ctdb, TDB_DATA inda
        script->start = timeval_current();
        monitoring_status->scripts = script;
 
+       state = monitoring_status->state;
+       if (state != NULL) {
+               /* reset the timeout for the next eventscript */
+               if (!timeval_is_zero(&state->timeout)) {
+                       if (state->te != NULL) {
+                               talloc_free(state->te);
+                               state->te = NULL;
+                       }
+                       state->te = event_add_timed(ctdb->ev, state, timeval_current_ofs(state->timeout.tv_sec, state->timeout.tv_usec), ctdb_event_script_timeout, state);
+               }
+
+       }
+
        return 0;
 }
 
@@ -194,13 +187,9 @@ int32_t ctdb_control_event_script_start(struct ctdb_context *ctdb, TDB_DATA inda
 int32_t ctdb_control_event_script_stop(struct ctdb_context *ctdb, TDB_DATA indata)
 {
        int32_t res = *((int32_t *)indata.dptr);
-       struct ctdb_monitoring_status *monitoring_status =
-               talloc_get_type(ctdb->script_monitoring_ctx,
-                       struct ctdb_monitoring_status);
+       struct ctdb_monitor_status *monitoring_status = (struct ctdb_monitor_status *)ctdb->script_monitor_ctx;
        struct ctdb_monitor_script_status *script;
 
-       DEBUG(DEBUG_INFO, ("event script stop called : %d\n", (int)res));
-
        if (monitoring_status == NULL) {
                DEBUG(DEBUG_ERR,(__location__ " script_status is NULL when script finished.\n"));
                return -1;
@@ -215,6 +204,8 @@ int32_t ctdb_control_event_script_stop(struct ctdb_context *ctdb, TDB_DATA indat
        script->finished = timeval_current();
        script->status   = res;
 
+       DEBUG(DEBUG_INFO, ("event script stop called for script:%s duration:%.1f status:%d\n", script->name, timeval_elapsed(&script->start), (int)res));
+
        return 0;
 }
 
@@ -223,9 +214,7 @@ int32_t ctdb_control_event_script_stop(struct ctdb_context *ctdb, TDB_DATA indat
 int32_t ctdb_control_event_script_disabled(struct ctdb_context *ctdb, TDB_DATA indata)
 {
        const char *name = (const char *)indata.dptr;
-       struct ctdb_monitoring_status *monitoring_status =
-               talloc_get_type(ctdb->script_monitoring_ctx,
-                       struct ctdb_monitoring_status);
+       struct ctdb_monitor_status *monitoring_status = (struct ctdb_monitor_status *)ctdb->script_monitor_ctx;
        struct ctdb_monitor_script_status *script;
 
        DEBUG(DEBUG_INFO, ("event script disabed called for script %s\n", name));
@@ -253,9 +242,7 @@ int32_t ctdb_control_event_script_disabled(struct ctdb_context *ctdb, TDB_DATA i
  */
 int32_t ctdb_control_event_script_finished(struct ctdb_context *ctdb)
 {
-       struct ctdb_monitoring_status *monitoring_status =
-               talloc_get_type(ctdb->script_monitoring_ctx,
-                       struct ctdb_monitoring_status);
+       struct ctdb_monitor_status *monitoring_status = (struct ctdb_monitor_status *)ctdb->script_monitor_ctx;
 
        DEBUG(DEBUG_INFO, ("event script finished called\n"));
 
@@ -266,11 +253,13 @@ int32_t ctdb_control_event_script_finished(struct ctdb_context *ctdb)
 
        monitoring_status->finished = timeval_current();        
        monitoring_status->status   = MONITOR_SCRIPT_OK;
-       if (ctdb->last_monitoring_ctx) {
-               talloc_free(ctdb->last_monitoring_ctx);
+
+       if (ctdb->last_monitor_ctx) {
+               talloc_free(ctdb->last_monitor_ctx);
+               ctdb->last_monitor_ctx = NULL;
        }
-       ctdb->last_monitoring_ctx = ctdb->script_monitoring_ctx;
-       ctdb->script_monitoring_ctx = NULL;
+       ctdb->last_monitor_ctx = talloc_steal(ctdb, ctdb->script_monitor_ctx);
+       ctdb->script_monitor_ctx = NULL;
 
        return 0;
 }
@@ -314,9 +303,7 @@ static struct ctdb_monitoring_wire *marshall_monitoring_scripts(TALLOC_CTX *mem_
 
 int32_t ctdb_control_get_event_script_status(struct ctdb_context *ctdb, TDB_DATA *outdata)
 {
-       struct ctdb_monitoring_status *monitoring_status =
-               talloc_get_type(ctdb->last_monitoring_ctx,
-                       struct ctdb_monitoring_status);
+       struct ctdb_monitor_status *monitoring_status = (struct ctdb_monitor_status *)ctdb->last_monitor_ctx;
        struct ctdb_monitoring_wire *monitoring_scripts;
 
        if (monitoring_status == NULL) {
@@ -643,8 +630,6 @@ static void ctdb_event_script_handler(struct event_context *ev, struct fd_event
 {
        struct ctdb_event_script_state *state = 
                talloc_get_type(p, struct ctdb_event_script_state);
-       void (*callback)(struct ctdb_context *, int, void *) = state->callback;
-       void *private_data = state->private_data;
        struct ctdb_context *ctdb = state->ctdb;
        signed char rt = -1;
 
@@ -652,10 +637,13 @@ static void ctdb_event_script_handler(struct event_context *ev, struct fd_event
 
        DEBUG(DEBUG_INFO,(__location__ " Eventscript %s finished with state %d\n", state->options, rt));
 
+       if (state->callback) {
+               state->callback(ctdb, rt, state->private_data);
+               state->callback = NULL;
+       }
+
        talloc_set_destructor(state, NULL);
        talloc_free(state);
-       callback(ctdb, rt, private_data);
-
        ctdb->event_script_timeouts = 0;
 }
 
@@ -679,19 +667,20 @@ static void ctdb_event_script_timeout(struct event_context *ev, struct timed_eve
                                      struct timeval t, void *p)
 {
        struct ctdb_event_script_state *state = talloc_get_type(p, struct ctdb_event_script_state);
-       void (*callback)(struct ctdb_context *, int, void *) = state->callback;
        void *private_data = state->private_data;
        struct ctdb_context *ctdb = state->ctdb;
        char *options;
-       struct ctdb_monitoring_status *monitoring_status =
-               talloc_get_type(ctdb->script_monitoring_ctx,
-                       struct ctdb_monitoring_status);
+       struct ctdb_monitor_status *monitoring_status = (struct ctdb_monitor_status *)ctdb->script_monitor_ctx;
+
+       state->te = NULL;
 
        DEBUG(DEBUG_ERR,("Event script timed out : %s count : %u  pid : %d\n", state->options, ctdb->event_script_timeouts, state->child));
        if (kill(state->child, 0) != 0) {
                DEBUG(DEBUG_ERR,("Event script child process already dead, errno %s(%d)\n", strerror(errno), errno));
-               callback(ctdb, 0, private_data);
-
+               if (state->callback) {
+                       state->callback(ctdb, 0, private_data);
+                       state->callback = NULL;
+               }
                talloc_set_destructor(state, NULL);
                talloc_free(state);
                return;
@@ -700,7 +689,6 @@ static void ctdb_event_script_timeout(struct event_context *ev, struct timed_eve
        options = talloc_strdup(ctdb, state->options);
        CTDB_NO_MEMORY_VOID(ctdb, options);
 
-       talloc_free(state);
        if (!strcmp(options, "monitor")) {
                /* if it is a monitor event, we allow it to "hang" a few times
                   before we declare it a failure and ban ourself (and make
@@ -712,27 +700,42 @@ static void ctdb_event_script_timeout(struct event_context *ev, struct timed_eve
                if (ctdb->event_script_timeouts > ctdb->tunable.script_ban_count) {
                        if (ctdb->tunable.script_unhealthy_on_timeout != 0) {
                                DEBUG(DEBUG_ERR, ("Maximum timeout count %u reached for eventscript. Making node unhealthy\n", ctdb->tunable.script_ban_count));
-                               callback(ctdb, -ETIME, private_data);
+                               if (state->callback) {
+                                       state->callback(ctdb, -ETIME, private_data);
+                                       state->callback = NULL;
+                               }
                        } else {
                                ctdb->event_script_timeouts = 0;
                                DEBUG(DEBUG_ERR, ("Maximum timeout count %u reached for eventscript. Banning self for %d seconds\n", ctdb->tunable.script_ban_count, ctdb->tunable.recovery_ban_period));
                                ctdb_ban_self(ctdb, ctdb->tunable.recovery_ban_period);
-                               callback(ctdb, -1, private_data);
+                               if (state->callback) {
+                                       state->callback(ctdb, -1, private_data);
+                                       state->callback = NULL;
+                               }
                        }
                } else {
-                       callback(ctdb, 0, private_data);
+                       if (state->callback) {
+                               state->callback(ctdb, 0, private_data);
+                               state->callback = NULL;
+                       }
                }
        } else if (!strcmp(options, "startup")) {
                DEBUG(DEBUG_ERR, (__location__ " eventscript for startup event timedout.\n"));
-               callback(ctdb, -1, private_data);
+               if (state->callback) {
+                       state->callback(ctdb, -1, private_data);
+                       state->callback = NULL;
+               }
        } else {
                /* if it is not a monitor event we ban ourself immediately */
                DEBUG(DEBUG_ERR, (__location__ " eventscript for NON-monitor/NON-startup event timedout. Immediately banning ourself for %d seconds\n", ctdb->tunable.recovery_ban_period));
                ctdb_ban_self(ctdb, ctdb->tunable.recovery_ban_period);
-               callback(ctdb, -1, private_data);
+               if (state->callback) {
+                       state->callback(ctdb, -1, private_data);
+                       state->callback = NULL;
+               }
        }
 
-       if (monitoring_status != NULL) {
+       if ((!strcmp(options, "monitor")) && (monitoring_status != NULL)) {
                struct ctdb_monitor_script_status *script;
 
                script = monitoring_status->scripts;
@@ -740,13 +743,15 @@ static void ctdb_event_script_timeout(struct event_context *ev, struct timed_eve
                        script->timedout = 1;
                }
                monitoring_status->status = MONITOR_SCRIPT_TIMEOUT;
-               if (ctdb->last_monitoring_ctx) {
-                       talloc_free(ctdb->last_monitoring_ctx);
-                       ctdb->last_monitoring_ctx = ctdb->script_monitoring_ctx;
-                       ctdb->script_monitoring_ctx = NULL;
+               if (ctdb->last_monitor_ctx) {
+                       talloc_free(ctdb->last_monitor_ctx);
+                       ctdb->last_monitor_ctx = NULL;
                }
+               ctdb->last_monitor_ctx = talloc_steal(ctdb, ctdb->script_monitor_ctx);
+               ctdb->script_monitor_ctx = NULL;
        }
 
+       talloc_free(state);
        talloc_free(options);
 }
 
@@ -757,6 +762,11 @@ static int event_script_destructor(struct ctdb_event_script_state *state)
 {
        DEBUG(DEBUG_ERR,(__location__ " Sending SIGTERM to child pid:%d\n", state->child));
 
+       if (state->callback) {
+               state->callback(state->ctdb, 0, state->private_data);
+               state->callback = NULL;
+       }
+
        if (kill(state->child, SIGTERM) != 0) {
                DEBUG(DEBUG_ERR,("Failed to kill child process for eventscript, errno %s(%d)\n", strerror(errno), errno));
        }
@@ -770,22 +780,50 @@ static int event_script_destructor(struct ctdb_event_script_state *state)
  */
 static int ctdb_event_script_callback_v(struct ctdb_context *ctdb, 
                                        struct timeval timeout,
-                                       TALLOC_CTX *mem_ctx,
                                        void (*callback)(struct ctdb_context *, int, void *),
                                        void *private_data,
                                        const char *fmt, va_list ap)
 {
+       struct ctdb_monitor_status *monitoring_status;
        struct ctdb_event_script_state *state;
        int ret;
 
-       state = talloc(mem_ctx, struct ctdb_event_script_state);
-       CTDB_NO_MEMORY(ctdb, state);
+       if (!strcmp(fmt, "monitor")) {
+               if (ctdb->script_monitor_ctx != NULL) {
+                       talloc_free(ctdb->script_monitor_ctx);
+                       ctdb->script_monitor_ctx = NULL;
+               }
+               monitoring_status = talloc_zero(ctdb, struct ctdb_monitor_status);
+       } else {
+               if (ctdb->event_script_ctx == NULL) {
+                       ctdb->event_script_ctx = talloc_zero(ctdb, struct ctdb_monitor_status);
+               }
+               monitoring_status = ctdb->event_script_ctx;
+       }
+
+       if (monitoring_status == NULL) {
+               DEBUG(DEBUG_ERR, (__location__ " ERROR: Failed to talloc script_monitoring context\n"));
+               return -1;
+       }
+
+       state = talloc(monitoring_status, struct ctdb_event_script_state);
+       if (state == NULL) {
+               DEBUG(DEBUG_ERR,(__location__ " could not allocate state\n"));
+               return -1;
+       }
+       monitoring_status->state = state;
 
        state->ctdb = ctdb;
        state->callback = callback;
        state->private_data = private_data;
        state->options = talloc_vasprintf(state, fmt, ap);
-       CTDB_NO_MEMORY(ctdb, state->options);
+       state->timeout = timeout;
+       state->te = NULL;
+       if (state->options == NULL) {
+               DEBUG(DEBUG_ERR, (__location__ " could not allocate state->options\n"));
+               talloc_free(state);
+               return -1;
+       }
 
        DEBUG(DEBUG_INFO,(__location__ " Starting eventscript %s\n", state->options));
        
@@ -812,12 +850,18 @@ static int ctdb_event_script_callback_v(struct ctdb_context *ctdb,
 
                rt = ctdb_event_script_v(ctdb, state->options);
                while ((ret = write(state->fd[1], &rt, sizeof(rt))) != sizeof(rt)) {
-                       sleep(1);
+                       write(state->fd[1], &rt, sizeof(rt));
+                       usleep(100000);
                }
                _exit(rt);
        }
 
        talloc_set_destructor(state, event_script_destructor);
+       if (!strcmp(fmt, "monitor")) {
+               ctdb->script_monitor_ctx = monitoring_status;
+       } else {
+               ctdb->event_script_ctx  = monitoring_status;
+       }
 
        close(state->fd[1]);
        set_close_on_exec(state->fd[0]);
@@ -827,8 +871,8 @@ static int ctdb_event_script_callback_v(struct ctdb_context *ctdb,
        event_add_fd(ctdb->ev, state, state->fd[0], EVENT_FD_READ|EVENT_FD_AUTOCLOSE,
                     ctdb_event_script_handler, state);
 
-       if (!timeval_is_zero(&timeout)) {
-               event_add_timed(ctdb->ev, state, timeout, ctdb_event_script_timeout, state);
+       if (!timeval_is_zero(&state->timeout)) {
+               state->te = event_add_timed(ctdb->ev, state, timeval_current_ofs(state->timeout.tv_sec, state->timeout.tv_usec), ctdb_event_script_timeout, state);
        } else {
                DEBUG(DEBUG_ERR, (__location__ " eventscript %s called with no timeout\n", state->options));
        }
@@ -852,7 +896,7 @@ int ctdb_event_script_callback(struct ctdb_context *ctdb,
        int ret;
 
        va_start(ap, fmt);
-       ret = ctdb_event_script_callback_v(ctdb, timeout, mem_ctx, callback, private_data, fmt, ap);
+       ret = ctdb_event_script_callback_v(ctdb, timeout, callback, private_data, fmt, ap);
        va_end(ap);
 
        return ret;
@@ -882,17 +926,15 @@ int ctdb_event_script(struct ctdb_context *ctdb, const char *fmt, ...)
 {
        va_list ap;
        int ret;
-       TALLOC_CTX *tmp_ctx = talloc_new(ctdb);
        struct callback_status status;
 
        va_start(ap, fmt);
        ret = ctdb_event_script_callback_v(ctdb, 
-                       timeval_current_ofs(ctdb->tunable.script_timeout, 0),
-                       tmp_ctx, event_script_callback, &status, fmt, ap);
+                       timeval_set(ctdb->tunable.script_timeout, 0),
+                       event_script_callback, &status, fmt, ap);
        va_end(ap);
 
        if (ret != 0) {
-               talloc_free(tmp_ctx);
                return ret;
        }
 
@@ -901,8 +943,6 @@ int ctdb_event_script(struct ctdb_context *ctdb, const char *fmt, ...)
 
        while (status.done == false && event_loop_once(ctdb->ev) == 0) /* noop */;
 
-       talloc_free(tmp_ctx);
-
        return status.status;
 }
 
@@ -967,7 +1007,7 @@ int32_t ctdb_run_eventscripts(struct ctdb_context *ctdb,
        ctdb_disable_monitoring(ctdb);
 
        ret = ctdb_event_script_callback(ctdb, 
-                        timeval_current_ofs(ctdb->tunable.script_timeout, 0),
+                        timeval_set(ctdb->tunable.script_timeout, 0),
                         state, run_eventscripts_callback, state,
                         "%s", (const char *)indata.dptr);
 
index c74487be863b6fcc60e7f0cbce4e7ccc73606373..e1c927d804934a86a35fb2adad7ac154e6797d88 100644 (file)
@@ -353,9 +353,16 @@ static int ctdb_tcp_listen_automatic(struct ctdb_context *ctdb)
                setsockopt(ctcp->listen_fd,SOL_SOCKET,SO_REUSEADDR,(char *)&one,sizeof(one));
 
                if (bind(ctcp->listen_fd, (struct sockaddr * )&sock, sock_size) == 0) {
-                       DEBUG(DEBUG_ERR,(__location__ " Failed to bind() to socket. %s(%d)\n", strerror(errno), errno));
                        break;
                }
+
+               if (errno == EADDRNOTAVAIL) {
+                       DEBUG(DEBUG_DEBUG,(__location__ " Failed to bind() to socket. %s(%d)\n",
+                                       strerror(errno), errno));
+               } else {
+                       DEBUG(DEBUG_ERR,(__location__ " Failed to bind() to socket. %s(%d)\n",
+                                       strerror(errno), errno));
+               }
        }
        
        if (i == ctdb->num_nodes) {
index fdd2e896223ad1c6c78a662f8bedad77bc80a382..c747e1adda479a7fa4d909d4597b13021941b75f 100644 (file)
@@ -197,7 +197,7 @@ static void test_store_records(struct ctdb_context *ctdb, struct event_context *
                        ret = ctdb_transaction_commit(h);
                        if (ret != 0) {
                                DEBUG(DEBUG_ERR,("Failed to commit transaction\n"));
-                               //exit(1);
+                               exit(1);
                        }
                        if (verbose) printf("transaction committed\n");
                } else {
index 2f78ebe76fbfc11cb8bae026ab00e31183eaf83f..838efdb7d8bf39b1a5330237fa3654cb51aa23cb 100644 (file)
@@ -31,7 +31,6 @@
 #include "../common/rb_tree.h"
 #include "db_wrap.h"
 
-
 #define ERR_TIMEOUT    20      /* timed out trying to reach node */
 #define ERR_NONODE     21      /* node does not exist */
 #define ERR_DISNODE    22      /* node is disconnected */
@@ -319,7 +318,7 @@ static int control_uptime(struct ctdb_context *ctdb, int argc, const char **argv
        }
 
        if (options.machinereadable){
-               printf(":Current Node Time:Ctdb Start Time:Last Recovery Time:Last Recovery Duration:\n");
+               printf(":Current Node Time:Ctdb Start Time:Last Recovery/Failover Time:Last Recovery/IPFailover Duration:\n");
                printf(":%u:%u:%u:%lf\n",
                        (unsigned int)uptime->current_time.tv_sec,
                        (unsigned int)uptime->ctdbd_start_time.tv_sec,
@@ -330,7 +329,7 @@ static int control_uptime(struct ctdb_context *ctdb, int argc, const char **argv
                return 0;
        }
 
-       printf("Current time of node  : %s", ctime(&uptime->current_time.tv_sec));
+       printf("Current time of node          :                %s", ctime(&uptime->current_time.tv_sec));
 
        tmp = uptime->current_time.tv_sec - uptime->ctdbd_start_time.tv_sec;
        seconds = tmp%60;
@@ -340,7 +339,7 @@ static int control_uptime(struct ctdb_context *ctdb, int argc, const char **argv
        hours   = tmp%24;
        tmp    /= 24;
        days    = tmp;
-       printf("Ctdbd start time      : (%03d %02d:%02d:%02d) %s", days, hours, minutes, seconds, ctime(&uptime->ctdbd_start_time.tv_sec));
+       printf("Ctdbd start time              : (%03d %02d:%02d:%02d) %s", days, hours, minutes, seconds, ctime(&uptime->ctdbd_start_time.tv_sec));
 
        tmp = uptime->current_time.tv_sec - uptime->last_recovery_finished.tv_sec;
        seconds = tmp%60;
@@ -350,9 +349,9 @@ static int control_uptime(struct ctdb_context *ctdb, int argc, const char **argv
        hours   = tmp%24;
        tmp    /= 24;
        days    = tmp;
-       printf("Time of last recovery : (%03d %02d:%02d:%02d) %s", days, hours, minutes, seconds, ctime(&uptime->last_recovery_finished.tv_sec));
+       printf("Time of last recovery/failover: (%03d %02d:%02d:%02d) %s", days, hours, minutes, seconds, ctime(&uptime->last_recovery_finished.tv_sec));
        
-       printf("Duration of last recovery : %lf seconds\n",
+       printf("Duration of last recovery/failover: %lf seconds\n",
                timeval_delta(&uptime->last_recovery_finished,
                              &uptime->last_recovery_started));
 
@@ -677,15 +676,24 @@ static int control_natgwlist(struct ctdb_context *ctdb, int argc, const char **a
                i++;
        }               
 
-       /* print the natgw master
-        * we dont allow STOPPED or DELETED nodes to become the natgwmaster
+       /* pick a node to be natgwmaster
+        * we dont allow STOPPED, DELETED, BANNED or UNHEALTHY nodes to become the natgwmaster
         */
        for(i=0;i<nodemap->num;i++){
-               if (!(nodemap->nodes[i].flags & (NODE_FLAGS_DISCONNECTED|NODE_FLAGS_STOPPED|NODE_FLAGS_DELETED))) {
+               if (!(nodemap->nodes[i].flags & (NODE_FLAGS_DISCONNECTED|NODE_FLAGS_STOPPED|NODE_FLAGS_DELETED|NODE_FLAGS_BANNED|NODE_FLAGS_UNHEALTHY))) {
                        printf("%d %s\n", nodemap->nodes[i].pnn,ctdb_addr_to_str(&nodemap->nodes[i].addr));
                        break;
                }
        }
+       /* we couldnt find any healthy node, try unhealthy ones */
+       if (i == nodemap->num) {
+               for(i=0;i<nodemap->num;i++){
+                       if (!(nodemap->nodes[i].flags & (NODE_FLAGS_DISCONNECTED|NODE_FLAGS_STOPPED|NODE_FLAGS_DELETED))) {
+                               printf("%d %s\n", nodemap->nodes[i].pnn,ctdb_addr_to_str(&nodemap->nodes[i].addr));
+                               break;
+                       }
+               }
+       }
        /* unless all nodes are STOPPED, when we pick one anyway */
        if (i == nodemap->num) {
                for(i=0;i<nodemap->num;i++){
index 7b48299433b1a35bcafd80613cc690694ff3d8af..2cdf3ccdfcf44f74cf8f1300895eb7d8b42efa5f 100755 (executable)
@@ -167,8 +167,8 @@ show_all "netstat -s"
 show_all "free"
 show_all "crontab -l"
 show_all "sysctl -a"
-show_all "/sbin/iptables -L -n"
-show_all "/sbin/iptables -L -n -t nat"
+show_all "iptables -L -n"
+show_all "iptables -L -n -t nat"
 show_all "/usr/sbin/rpcinfo -p"
 show_all "/usr/sbin/showmount -a"
 show_all "/usr/sbin/showmount -e"