[SCM] CTDB repository - branch 1.0.114 updated - ctdb-1.0.114.7-27-gb7c4e6d

Michael Adam obnox at samba.org
Wed Jun 25 09:07:03 MDT 2014


The branch, 1.0.114 has been updated
       via  b7c4e6d98c9d4e2674b2015adc4cbebadf080b93 (commit)
       via  f53613bdf3bf919828fa65819f0b34ad8dee4fcd (commit)
       via  d889cc4dc622dbda2a2ade4aa9ab9006022261ba (commit)
       via  9fea542d0acd222aab0070827a0de453c13edaab (commit)
       via  b8b1625e5fc3d403ed5bd866f8aea1973f607d44 (commit)
       via  920083b1d53c9affd67e9aaf220d111358a591c6 (commit)
       via  f3fe9132d891e8681a62fff5cdc7ea92e4d8d57d (commit)
       via  13839cefa8332380dc3a7dbee00dcbf374c18efd (commit)
       via  02b1af9cd062a1fc82da906aa398822fa973cf86 (commit)
       via  c5a953f762d4d8955d83dc8c6e0cdcb1c91a2abd (commit)
       via  651b5f1441954f6e3e0fb7797d910d940e668f2e (commit)
       via  362ed8f12666ee6afc0ab4567dab8fc7062ce23d (commit)
       via  55f0db526c8573bf90d0c17be614dedbacc70f94 (commit)
       via  642823628faef67dd729679e2af6858242f56cba (commit)
       via  44496bb329ba82df4ee0c637157c0181c982e119 (commit)
       via  e478aa863b1bc8a9fd4f029c1093f0de8c12caf2 (commit)
       via  f65fe7815574cbfe12b0d6fb353e2fb4f4dbfdea (commit)
       via  db0cf14308b193d8678600c28e50e770b7b304a9 (commit)
       via  2a89dda07ec81ad327d4b7faa317dfc604893d44 (commit)
       via  48d840d8da695078719a8160399011c8ddb53790 (commit)
       via  0f65e2dbdcd089ac1931146c36e26adeff422951 (commit)
       via  10cbcca079de2fdbe280ca6c1092f73f5e84159b (commit)
       via  26704bd06d04ca40f928ce1cdf599b772d2ce7d8 (commit)
       via  529912716ae29062679c80806faf0855f18adbeb (commit)
       via  fe65f04a2cad94d2bf2f90f6c5bd262c7baaf057 (commit)
      from  21bf0bd397b9075963f268110c9108f6be854164 (commit)

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


- Log -----------------------------------------------------------------
commit b7c4e6d98c9d4e2674b2015adc4cbebadf080b93
Author: Michael Adam <obnox at samba.org>
Date:   Wed Jun 25 15:37:15 2014 +0200

    New version 1.0.114.8
    
    Signed-off-by: Michael Adam <obnox at samba.org>

commit f53613bdf3bf919828fa65819f0b34ad8dee4fcd
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Mon Aug 5 17:38:42 2013 +1000

    ctdbd: Avoid leaking file descriptor if talloc fails
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    (cherry picked from commit d7f6bc3fed2dc61e6e587b4c0ec0ac27d533bbbe)

commit d889cc4dc622dbda2a2ade4aa9ab9006022261ba
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Mon Aug 30 19:42:30 2010 +1000

    ouch,   the ordering of the constants and the strings must be kept in sync
    manually   and ther eis no check for errors.     should fix this later
    
    (cherry picked from commit e824af1a41f8ceec1edf6b3d1d6e1758fa00deb2)

commit 9fea542d0acd222aab0070827a0de453c13edaab
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Mon Jan 10 16:51:56 2011 +1100

    recoverd: avoid triggering a full recovery if just some ip allocation
    has failed.
    We dont need to rebuild the databases in this situation, we just
    need to try again to sort out the ip address allocations.
    
    (cherry picked from commit 044c398ffea23d36ee033c8ddf07d11028197346)

commit b8b1625e5fc3d403ed5bd866f8aea1973f607d44
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Wed Sep 21 11:42:19 2011 +1000

    when checking that the interfaces exist in ctdb_add_public_address()
    cant talloc off vnn since it is not yet initialized and might not always be NULL
    (cherry picked from commit 3d37be3e2bfb61ede824028aeebaa18ba304faae)

commit 920083b1d53c9affd67e9aaf220d111358a591c6
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Wed Jun 20 15:10:05 2012 +1000

    When we find an ip we shouldnt host, just release it
    
    Dont call a full blown clusterwide ipreallocation,  just release it locally
    (cherry picked from commit 9a806dec8687e2ec08a308853b61af6aed5e5d1e)

commit f3fe9132d891e8681a62fff5cdc7ea92e4d8d57d
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Wed Apr 4 14:42:23 2012 +1000

    recoverd: Fix spurious warnings when running with --nopublicipcheck
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    (cherry picked from commit 7f8096f56d8274151705ac822b582d972078f8fe)

commit 13839cefa8332380dc3a7dbee00dcbf374c18efd
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Jul 11 14:46:07 2012 +1000

    ctdbd: Stop takeovers and releases from colliding in mid-air
    
    There's a race here where release and takeover events for an IP can
    run at the same time.  For example, a "ctdb deleteip" and a takeover
    initiated by the recovery daemon.  The timeline is as follows:
    
    1. The release code registers a callback to update the VNN.  The
       callback is executed *after* the eventscripts run the releaseip
       event.
    
    2. The release code calls the eventscripts for the releaseip event,
       removing IP from its interface.
    
       The takeover code "updates" the VNN saying that IP is on some
       iface.... even if/though the address is already there.
    
    3. The release callback runs, removing the iface associated with IP in
       the VNN.
    
       The takeover code calls the eventscripts for the takeip event,
       adding IP to an interface.
    
    As a result, CTDB doesn't think it should be hosting IP but IP is on
    an interface.  The recovery daemon fixes this later... but it
    shouldn't happen.
    
    This patch can cause some additional noise in the logs:
    
      Release of IP 10.0.2.133/24 on interface eth2  node:2
      recoverd:We are still serving a public address '10.0.2.133' that we should not be serving. Removing it.
      Release of IP 10.0.2.133/24 rejected update for this IP already in flight
      recoverd:client/ctdb_client.c:2455 ctdb_control for release_ip failed
      recoverd:Failed to release local ip address
    
    In this case the node has started releasing an IP when the recovery
    daemon notices the addresses is still hosted and initiates another
    release.  This noise is harmless but annoying.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    (cherry picked from commit bfe16cf69bf2eee93c0d831f76d88bba0c2b96c2)

commit 02b1af9cd062a1fc82da906aa398822fa973cf86
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Jul 2 14:09:32 2012 +1000

    ctdbd: Fix ctdb_control_release_ip() on local daemons
    
    When running on local daemons no IPs are actually assigned to
    interfaces.  Commit 9a806dec8687e2ec08a308853b61af6aed5e5d1e broke
    ctdb_control_release_ip() for local daemons because it asks the system
    which interface the given IP is on, instead of the old behaviour of
    trusting CTDB's internal records.
    
    For local deamons (i.e. !ctdb->do_checkpublicip) revert to the old
    behaviour of looking up the interface internally.  This is good
    enough, given that the tests don't tend to misconfigure the addresses.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    (cherry picked from commit 38e8651b955afdbaf0ae87c24c55c052f8209290)

commit c5a953f762d4d8955d83dc8c6e0cdcb1c91a2abd
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Wed Jun 20 10:08:11 2012 +1000

    When we release an ip, get the interface name from the kernel
    
    instead of using the interface where ctdb thinks the ip is hosted at.
    The difference is that this now allows us to handle cases where we want to release an ip   but ctdbd does not know which interface the ip is assigned on.
    (user has used 'ip addr add...'  and manually assigned an ip to the wrong interface)
    (cherry picked from commit c6bf22ba5c01001b7febed73dd16a03bd3fd2bed)

commit 651b5f1441954f6e3e0fb7797d910d940e668f2e
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Wed Apr 4 14:42:56 2012 +1000

    ctdbd: Fix spurious warnings when running with --nopublicipcheck
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    (cherry picked from commit 67b909a0718d6cfce82ffce0830da3a6ff1f6c4b)

commit 362ed8f12666ee6afc0ab4567dab8fc7062ce23d
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Tue Sep 6 17:02:19 2011 +1000

    Interface monitoring: add a event to trigger every 30 seconds to check that all interfaces referenced by the public address list actually exists.
    
    This will make it much easier to root-cause problems such as
    S1029023
    when an external application deleted the interface while it is still is in use by ctdbd.
    (cherry picked from commit 9abf9c919a7e6789695490e2c3de56c21b63fa57)

commit 55f0db526c8573bf90d0c17be614dedbacc70f94
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Mon Mar 14 09:55:28 2011 +1100

    IP reallocation. If a public address is already hosted on the node when we startup, log a warning message but do not cause the recovery to fail.
    
    CQ S1022356
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    (cherry picked from commit 89f8169c24da96c1fdd0ac19b8a1e0e1df01a72a)

commit 642823628faef67dd729679e2af6858242f56cba
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Thu Jan 13 09:35:37 2011 +1100

    IPALLOCATION : If the node is held pinned down in "init" state
    by external services failing to start, or blocking CTDBD from finishing the startup phase,
    we can encounter a situation where we have not yet fully initialized, but a
    remote recovery master tries to release a certain ip clusterwide.
    
    In this situation the node that is pinned down in init/startup phase
    would fail to perform the release of the ip address since we are not yet fully operational and not yet host any valid interfaces.
    
    In this situation, we just need to remain unhealthy, there is on need to
    also ban the node.
    
    Remove the autobanning for this condition and just let the node remain in
    unhealthy mode.
    Banning is overkill in this situation when the system is broken and just
    draws attention to ctdbd instead of the root cause.
    (cherry picked from commit d8af74e4c4961deb94c18dde8ba7fc07e944729c)

commit 44496bb329ba82df4ee0c637157c0181c982e119
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Tue Jun 1 16:22:48 2010 +1000

    When adding an ip at runtime, it might not yet have an iface assigned to it, so ensure that the next takover_ip call will fall through to accept the ip and add it.
    (cherry picked from commit 2d60f96680d16c2992e2a35517822f88c12538b7)

commit e478aa863b1bc8a9fd4f029c1093f0de8c12caf2
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Mon Sep 13 15:42:00 2010 +1000

    add a new serverid to send a message everytime an ip address is taken on the local node
    
    (cherry picked from commit 1261f3d9702800a4e59550c881350daf479f00ef)
    
    Conflicts:
    
    	include/ctdb_protocol.h

commit f65fe7815574cbfe12b0d6fb353e2fb4f4dbfdea
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Mar 22 15:27:25 2012 +1100

    Undo damage done by d8d37493478a26c5f1809a5f3df89ffd6e149281
    
    The implementation of DisableIPFailover got intermingled with
    --nopublicipcheck.  This just looks wrong - Ronnie must have been
    having a bad day.  :-)
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    (cherry picked from commit 5083b266dd68b292c4275505f3d1b878dbf12f11)
    
    Conflicts:
    
    	include/ctdb_private.h

commit db0cf14308b193d8678600c28e50e770b7b304a9
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Fri Dec 3 13:28:35 2010 +1100

    during ip allocation, there are failure modes where a node might hold a ip address
    but thinks it is still unassigned (-1).
    
    add code to the recovery daemon to detect this case and trigger a reallocation
    so that the ip gets covered
    
    and change the takeip code to allow for this condition, taking on an ip address that is
    already hosted.
    
    cq s1021073
    (cherry picked from commit 9020baf27cab7821c9094cda185206fb7af0fee7)

commit 2a89dda07ec81ad327d4b7faa317dfc604893d44
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Wed Nov 10 14:46:05 2010 +1100

    Dont check remote ip allocation if public ip mgmt is disabled
    (cherry picked from commit 441ad00af842a8b7b5291de60d8ab08a064f5327)

commit 48d840d8da695078719a8160399011c8ddb53790
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Wed Nov 10 12:06:05 2010 +1100

    dont check the public ip assignment or if even we are hosting them and shouldnt
    when public ips have been disabled
    (cherry picked from commit 7d07a74dc7f907ac757d20626f68e257d7ba16be)

commit 0f65e2dbdcd089ac1931146c36e26adeff422951
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Mon May 3 15:52:02 2010 +1000

        Dont check ip assignment across the cluster while ip-verification
        checks are disabled
    (cherry picked from commit 189f4a5af1053271b0834522e35c336df959aa03)

commit 10cbcca079de2fdbe280ca6c1092f73f5e84159b
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Tue Nov 9 15:19:06 2010 +1100

    Add a new tunable : DisableIPFailover that when set to non 0
    will stopp any ip reallocations at all from happening.
    (cherry picked from commit d8d37493478a26c5f1809a5f3df89ffd6e149281)
    
    Conflicts:
    
    	server/ctdb_tunables.c

commit 26704bd06d04ca40f928ce1cdf599b772d2ce7d8
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Mon Aug 30 18:08:38 2010 +1000

        Add a new event "ipreallocated"
        This is called everytime a reallocation is performed.
    
        While STARTRECOVERY/RECOVERED events are only called when
        we do ipreallocation as part of a full database/cluster recovery,
        this new event can be used to trigger on when we just do a light
        failover due to a node becomming unhealthy.
    
        I.e. situations where we do a failover but we do not perform a full
        cluster recovery.
    
        Use this to trigger for natgw so we select a new natgw master node
        when failover happens and not just when cluster rebuilds happen.
    (cherry picked from commit 7f4c591388adae20e98984001385cba26598ec67)
    
    Conflicts:
    
    	include/ctdb_protocol.h

commit 529912716ae29062679c80806faf0855f18adbeb
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Wed Jun 20 13:32:02 2012 +1000

    Add new command to find which interface is located on
    
    (cherry picked from commit f07376309e70f5ccdb7de8453caacc71b451ab48)
    
    Conflicts:
    
    	tools/ctdb.c

commit fe65f04a2cad94d2bf2f90f6c5bd262c7baaf057
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Tue Sep 6 16:11:00 2011 +1000

    Check interfaces:  when reading the public addresses file to create the vnn list
    check that the actual interface exist, print error and fail startup if the interface does not exist.
    (cherry picked from commit cd33bbe6454b7b0316bdfffbd06c67b29779e873)

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

Summary of changes:
 common/ctdb_util.c         |    3 +-
 common/system_aix.c        |    4 +
 common/system_common.c     |   84 ++++++++++++++++
 common/system_linux.c      |   22 ++++
 config/events.d/11.natgw   |    2 +-
 include/ctdb.h             |    6 +
 include/ctdb_private.h     |   12 ++-
 packaging/RPM/ctdb.spec.in |    7 +-
 server/ctdb_control.c      |    5 +-
 server/ctdb_daemon.c       |    4 +-
 server/ctdb_recover.c      |   24 ++++-
 server/ctdb_recoverd.c     |   67 ++++++++-----
 server/ctdb_takeover.c     |  231 +++++++++++++++++++++++++++++++++++++++-----
 server/ctdb_tunables.c     |    1 +
 server/ctdbd.c             |    1 -
 server/eventscript.c       |    1 +
 tools/ctdb.c               |   22 ++++
 17 files changed, 434 insertions(+), 62 deletions(-)


Changeset truncated at 500 lines:

diff --git a/common/ctdb_util.c b/common/ctdb_util.c
index 63abc02..a79cf29 100644
--- a/common/ctdb_util.c
+++ b/common/ctdb_util.c
@@ -671,5 +671,6 @@ const char *ctdb_eventscript_call_names[] = {
 	"status",
 	"shutdown",
 	"reload",
-	"updateip"
+	"updateip",
+	"ipreallocated"
 };
diff --git a/common/system_aix.c b/common/system_aix.c
index 5fe5413..1404a82 100644
--- a/common/system_aix.c
+++ b/common/system_aix.c
@@ -357,4 +357,8 @@ int ctdb_sys_read_tcp_packet(int s, void *private_data,
 }
 
 
+bool ctdb_sys_check_iface_exists(const char *iface)
+{
+	return true;
+}
 
diff --git a/common/system_common.c b/common/system_common.c
index 9aa4620..78eeb82 100644
--- a/common/system_common.c
+++ b/common/system_common.c
@@ -70,3 +70,87 @@ bool ctdb_sys_have_ip(ctdb_sock_addr *_addr)
 	close(s);
 	return ret == 0;
 }
+
+
+/* find which interface an ip address is currently assigned to */
+char *ctdb_sys_find_ifname(ctdb_sock_addr *addr)
+{
+	int s;
+	int size;
+	struct ifconf ifc;
+	char *ptr;
+
+	s = socket(AF_INET, SOCK_RAW, htons(IPPROTO_RAW));
+	if (s == -1) {
+		DEBUG(DEBUG_CRIT,(__location__ " failed to open raw socket (%s)\n",
+			 strerror(errno)));
+		return NULL;
+	}
+
+
+	size = sizeof(struct ifreq);
+	ifc.ifc_buf = NULL;
+	ifc.ifc_len = size;
+
+	while(ifc.ifc_len > (size - sizeof(struct ifreq))) {
+		size *= 2;
+
+		free(ifc.ifc_buf);	
+		ifc.ifc_len = size;
+		ifc.ifc_buf = malloc(size);
+		memset(ifc.ifc_buf, 0, size);
+		if (ioctl(s, SIOCGIFCONF, (caddr_t)&ifc) < 0) {
+			DEBUG(DEBUG_CRIT,("Failed to read ifc buffer from socket\n"));
+			free(ifc.ifc_buf);	
+			close(s);
+			return NULL;
+		}
+	}
+
+	for (ptr =(char *)ifc.ifc_buf; ptr < ((char *)ifc.ifc_buf) + ifc.ifc_len; ) {
+		char *ifname;
+		struct ifreq *ifr;
+
+		ifr = (struct ifreq *)ptr;
+
+#ifdef HAVE_SOCKADDR_LEN
+		if (ifr->ifr_addr.sa_len > sizeof(struct sockaddr)) {
+			ptr += sizeof(ifr->ifr_name) + ifr->ifr_addr.sa_len;
+		} else {
+			ptr += sizeof(ifr->ifr_name) + sizeof(struct sockaddr);
+		}
+#else
+		ptr += sizeof(struct ifreq);
+#endif
+
+		if (ifr->ifr_addr.sa_family != addr->sa.sa_family) {
+			continue;
+		}
+
+		switch (addr->sa.sa_family) {
+		case AF_INET:
+
+
+			if (memcmp(&addr->ip.sin_addr, &((struct sockaddr_in *)&ifr->ifr_addr)->sin_addr, sizeof(addr->ip.sin_addr))) {
+				continue;
+			}
+			break;
+		case AF_INET6:
+			if (memcmp(&addr->ip6.sin6_addr, &((struct sockaddr_in6 *)&ifr->ifr_addr)->sin6_addr, sizeof(addr->ip6.sin6_addr))) {
+				continue;
+			}
+			break;
+		}
+
+		ifname = strdup(ifr->ifr_name);
+		free(ifc.ifc_buf);	
+		close(s);
+		return ifname;
+	}
+
+
+	free(ifc.ifc_buf);	
+	close(s);
+
+	return NULL;
+}
diff --git a/common/system_linux.c b/common/system_linux.c
index b36a78d..102a348 100644
--- a/common/system_linux.c
+++ b/common/system_linux.c
@@ -538,3 +538,25 @@ int ctdb_sys_read_tcp_packet(int s, void *private_data,
 }
 
 
+bool ctdb_sys_check_iface_exists(const char *iface)
+{
+	int s;
+	struct ifreq ifr;
+
+	s = socket(PF_PACKET, SOCK_RAW, 0);
+	if (s == -1){
+		/* We dont know if the interface exists, so assume yes */
+		DEBUG(DEBUG_CRIT,(__location__ " failed to open raw socket\n"));
+		return true;
+	}
+
+	strncpy(ifr.ifr_name, iface, sizeof(ifr.ifr_name));
+	if (ioctl(s, SIOCGIFINDEX, &ifr) < 0 && errno == ENODEV) {
+		DEBUG(DEBUG_CRIT,(__location__ " interface '%s' not found\n", iface));
+		close(s);
+		return false;
+	}
+	close(s);
+	
+	return true;
+}
diff --git a/config/events.d/11.natgw b/config/events.d/11.natgw
index b226b81..ba1d42d 100644
--- a/config/events.d/11.natgw
+++ b/config/events.d/11.natgw
@@ -35,7 +35,7 @@ case "$1" in
 	ctdb setnatgwstate on
 	;;
 
-    recovered|updatenatgw)
+    recovered|updatenatgw|ipreallocated)
 	MYPNN=`ctdb pnn | cut -d: -f2`
 	NATGWMASTER=`ctdb natgwlist | head -1 | sed -e "s/ .*//"`
 	NATGWIP=`ctdb natgwlist | head -1 | sed -e "s/^[^ ]* *//"`
diff --git a/include/ctdb.h b/include/ctdb.h
index ec1e5e6..af33dee 100644
--- a/include/ctdb.h
+++ b/include/ctdb.h
@@ -72,6 +72,11 @@ struct ctdb_call_info {
 #define CTDB_SRVID_RELEASE_IP 0xF300000000000000LL
 
 /* 
+   a message handler ID meaning that an IP address has been taken
+ */
+#define CTDB_SRVID_TAKE_IP 0xF301000000000000LL
+
+/* 
    a message ID to set the node flags in the recovery daemon
  */
 #define CTDB_SRVID_SET_NODE_FLAGS 0xF400000000000000LL
@@ -704,6 +709,7 @@ enum ctdb_eventscript_call {
 	CTDB_EVENT_SHUTDOWN,		/* CTDB shutting down: no args. */
 	CTDB_EVENT_RELOAD,		/* magic */
 	CTDB_EVENT_UPDATE_IP,		/* IP updating: old interface, new interface, IP address, netmask bits. */
+	CTDB_EVENT_IPREALLOCATED,	/* when a takeover_run() completes */
 	CTDB_EVENT_MAX
 };
 
diff --git a/include/ctdb_private.h b/include/ctdb_private.h
index 355f361..e0b39ee 100644
--- a/include/ctdb_private.h
+++ b/include/ctdb_private.h
@@ -113,6 +113,7 @@ struct ctdb_tunable {
 	uint32_t deterministic_public_ips;
 	uint32_t reclock_ping_period;
 	uint32_t no_ip_failback;
+	uint32_t disable_ip_failover;
 	uint32_t verbose_memory_names;
 	uint32_t recd_ping_timeout;
 	uint32_t recd_ping_failcount;
@@ -208,6 +209,10 @@ struct ctdb_vnn {
 	TALLOC_CTX *takeover_ctx;
 
 	struct ctdb_kill_tcp *killtcp;
+
+	/* Set to true any time an update to this VNN is in flight.
+	   This helps to avoid races. */
+	bool update_in_flight;
 };
 
 /*
@@ -401,6 +406,7 @@ struct ctdb_context {
 	uint32_t recovery_mode;
 	TALLOC_CTX *tickle_update_context;
 	TALLOC_CTX *keepalive_ctx;
+	TALLOC_CTX *check_public_ifaces_ctx;
 	struct ctdb_tunable tunable;
 	enum ctdb_freeze_mode freeze_mode[NUM_DB_PRIORITIES+1];
 	struct ctdb_freeze_handle *freeze_handles[NUM_DB_PRIORITIES+1];
@@ -443,7 +449,7 @@ struct ctdb_context {
 	struct ctdb_call_state *pending_calls;
 	struct ctdb_client_ip *client_ip_list;
 	bool do_checkpublicip;
-	struct trbt_tree *server_ids;	
+	struct trbt_tree *server_ids;
 	const char *event_script_dir;
 	const char *notification_script;
 	const char *default_public_interface;
@@ -1417,6 +1423,8 @@ int ctdb_ctrl_set_iface_link(struct ctdb_context *ctdb,
 uint32_t uint16_checksum(uint16_t *data, size_t n);
 int ctdb_sys_send_arp(const ctdb_sock_addr *addr, const char *iface);
 bool ctdb_sys_have_ip(ctdb_sock_addr *addr);
+char *ctdb_sys_find_ifname(ctdb_sock_addr *addr);
+bool ctdb_sys_check_iface_exists(const char *iface);
 int ctdb_sys_send_tcp(const ctdb_sock_addr *dest, 
 		      const ctdb_sock_addr *src,
 		      uint32_t seq, uint32_t ack, int rst);
@@ -1710,4 +1718,6 @@ void ctdb_local_remove_from_delete_queue(struct ctdb_db_context *ctdb_db,
 
 struct ctdb_ltdb_header *ctdb_header_from_record_handle(struct ctdb_record_handle *h);
 
+int ctdb_deferred_drop_all_ips(struct ctdb_context *ctdb);
+
 #endif
diff --git a/packaging/RPM/ctdb.spec.in b/packaging/RPM/ctdb.spec.in
index 7f7b651..bf71296 100644
--- a/packaging/RPM/ctdb.spec.in
+++ b/packaging/RPM/ctdb.spec.in
@@ -4,7 +4,7 @@ Summary: Clustered TDB
 Vendor: Samba Team
 Packager: Samba Team <samba at samba.org>
 Name: ctdb
-Version: 1.0.114.7
+Version: 1.0.114.8
 Release: 1GITHASH
 Epoch: 0
 License: GNU GPL version 3
@@ -127,6 +127,11 @@ rm -rf $RPM_BUILD_ROOT
 %{_docdir}/ctdb/tests/bin/ctdb_transaction
 
 %changelog
+* Wed Jun 25 2014 : Version 1.0.114.8
+ - Michael Adam: Less verbosity when there is no public_addresses file.
+ - Michael Adam: Debug message fix.  (backported from master)
+ - Ronnie Sahlberg, Amitay Isaacs, Martin Schwenke: backported several
+   patches to increase robustness with respect to banning and ip failover.
 * Wed Sep 04 2013 : Version 1.0.114.7
  - Amitay Isaacs, Martin Schwenke, Michael Adam: banning robustness fixes.
  - Amitay Isaacs: Fix record bouncing bug introduced by 3-phase vacuuming.
diff --git a/server/ctdb_control.c b/server/ctdb_control.c
index 0a3c761..d98740f 100644
--- a/server/ctdb_control.c
+++ b/server/ctdb_control.c
@@ -53,7 +53,10 @@ int32_t ctdb_dump_memory(struct ctdb_context *ctdb, TDB_DATA *outdata)
 	fsize = ftell(f);
 	rewind(f);
 	outdata->dptr = talloc_size(outdata, fsize);
-	CTDB_NO_MEMORY(ctdb, outdata->dptr);
+	if (outdata->dptr == NULL) {
+		fclose(f);
+		CTDB_NO_MEMORY(ctdb, outdata->dptr);
+	}
 	outdata->dsize = fread(outdata->dptr, 1, fsize, f);
 	fclose(f);
 	if (outdata->dsize != fsize) {
diff --git a/server/ctdb_daemon.c b/server/ctdb_daemon.c
index 37a756b..a3caa5a 100644
--- a/server/ctdb_daemon.c
+++ b/server/ctdb_daemon.c
@@ -828,7 +828,9 @@ int ctdb_start_daemon(struct ctdb_context *ctdb, bool do_fork, bool use_syslog)
 	}
 
 	/* release any IPs we hold from previous runs of the daemon */
-	ctdb_release_all_ips(ctdb);
+	if (ctdb->tunable.disable_ip_failover == 0) {
+		ctdb_release_all_ips(ctdb);
+	}
 
 	/* start the transport going */
 	ctdb_start_transport(ctdb);
diff --git a/server/ctdb_recover.c b/server/ctdb_recover.c
index ed6fe41..8ec935d 100644
--- a/server/ctdb_recover.c
+++ b/server/ctdb_recover.c
@@ -587,6 +587,22 @@ ctdb_drop_all_ips_event(struct event_context *ev, struct timed_event *te,
 }
 
 /*
+ * Set up an event to drop all public ips if we remain in recovery for too
+ * long
+ */
+int ctdb_deferred_drop_all_ips(struct ctdb_context *ctdb)
+{
+	if (ctdb->release_ips_ctx != NULL) {
+		talloc_free(ctdb->release_ips_ctx);
+	}
+	ctdb->release_ips_ctx = talloc_new(ctdb);
+	CTDB_NO_MEMORY(ctdb, ctdb->release_ips_ctx);
+
+	event_add_timed(ctdb->ev, ctdb->release_ips_ctx, timeval_current_ofs(ctdb->tunable.recovery_drop_all_ips, 0), ctdb_drop_all_ips_event, ctdb);
+	return 0;
+}
+
+/*
   set the recovery mode
  */
 int32_t ctdb_control_set_recmode(struct ctdb_context *ctdb, 
@@ -606,11 +622,9 @@ int32_t ctdb_control_set_recmode(struct ctdb_context *ctdb,
 		talloc_free(ctdb->release_ips_ctx);
 		ctdb->release_ips_ctx = NULL;
 	} else {
-		talloc_free(ctdb->release_ips_ctx);
-		ctdb->release_ips_ctx = talloc_new(ctdb);
-		CTDB_NO_MEMORY(ctdb, ctdb->release_ips_ctx);
-
-		event_add_timed(ctdb->ev, ctdb->release_ips_ctx, timeval_current_ofs(ctdb->tunable.recovery_drop_all_ips, 0), ctdb_drop_all_ips_event, ctdb);
+		if (ctdb_deferred_drop_all_ips(ctdb) != 0) {
+			DEBUG(DEBUG_ERR,("Failed to set up deferred drop all ips\n"));
+		}
 	}
 
 	if (recmode != ctdb->recovery_mode) {
diff --git a/server/ctdb_recoverd.c b/server/ctdb_recoverd.c
index 0426258..75e839c 100644
--- a/server/ctdb_recoverd.c
+++ b/server/ctdb_recoverd.c
@@ -1287,9 +1287,13 @@ static int ctdb_reload_remote_public_ips(struct ctdb_context *ctdb,
 			return -1;
 		}
 
-		if (verify_remote_ip_allocation(ctdb, ctdb->nodes[j]->known_public_ips)) {
-			DEBUG(DEBUG_ERR,("Node %d has inconsistent public ip allocation and needs update.\n", ctdb->nodes[j]->pnn));
-			rec->need_takeover_run = true;
+		if (ctdb->do_checkpublicip) {
+			if (rec->ip_check_disable_ctx == NULL) {
+				if (verify_remote_ip_allocation(ctdb, ctdb->nodes[j]->known_public_ips)) {
+					DEBUG(DEBUG_ERR,("Node %d has inconsistent public ip allocation and needs update.\n", ctdb->nodes[j]->pnn));
+					rec->need_takeover_run = true;
+				}
+			}
 		}
 
 		/* grab a new shiny list of public ips from the node */
@@ -1612,13 +1616,14 @@ static int do_recovery(struct ctdb_recoverd *rec,
 	if (ret != 0) {
 		DEBUG(DEBUG_ERR,("Failed to read public ips from remote node %d\n",
 				 culprit));
+		rec->need_takeover_run = true;
 		return -1;
 	}
 	rec->need_takeover_run = false;
 	ret = ctdb_takeover_run(ctdb, nodemap);
 	if (ret != 0) {
-		DEBUG(DEBUG_ERR, (__location__ " Unable to setup public takeover addresses\n"));
-		return -1;
+		DEBUG(DEBUG_ERR, (__location__ " Unable to setup public takeover addresses. ctdb_takeover_run() failed.\n"));
+		rec->need_takeover_run = true;
 	}
 	DEBUG(DEBUG_NOTICE, (__location__ " Recovery - takeip finished\n"));
 
@@ -2033,8 +2038,7 @@ static void process_ipreallocate_requests(struct ctdb_context *ctdb, struct ctdb
 	if (ret == 0) {
 		ret = ctdb_takeover_run(ctdb, rec->nodemap);
 		if (ret != 0) {
-			DEBUG(DEBUG_ERR,("Failed to read public ips from remote node %d\n",
-					 culprit));
+			DEBUG(DEBUG_ERR,("Failed to reallocate addresses: ctdb_takeover_run() failed.\n"));
 			rec->need_takeover_run = true;
 		}
 	}
@@ -2476,7 +2480,7 @@ static enum monitor_result verify_recmaster(struct ctdb_recoverd *rec, struct ct
 
 /* called to check that the local allocation of public ip addresses is ok.
 */
-static int verify_local_ip_allocation(struct ctdb_context *ctdb, struct ctdb_recoverd *rec, uint32_t pnn)
+static int verify_local_ip_allocation(struct ctdb_context *ctdb, struct ctdb_recoverd *rec, uint32_t pnn, struct ctdb_node_map *nodemap)
 {
 	TALLOC_CTX *mem_ctx = talloc_new(NULL);
 	struct ctdb_control_get_ifaces *ifaces = NULL;
@@ -2567,20 +2571,32 @@ static int verify_local_ip_allocation(struct ctdb_context *ctdb, struct ctdb_rec
 	   and we dont have ones we shouldnt have.
 	   if we find an inconsistency we set recmode to
 	   active on the local node and wait for the recmaster
-	   to do a full blown recovery
+	   to do a full blown recovery.
+	   also if the pnn is -1 and we are healthy and can host the ip
+	   we also request a ip reallocation.
 	*/
-	for (j=0; j<ips->num; j++) {
-		if (ips->ips[j].pnn == pnn) {
-			if (!ctdb_sys_have_ip(&ips->ips[j].addr)) {
-				DEBUG(DEBUG_CRIT,("Public address '%s' is missing and we should serve this ip\n",
-					ctdb_addr_to_str(&ips->ips[j].addr)));
-				need_takeover_run = true;
-			}
-		} else {
-			if (ctdb_sys_have_ip(&ips->ips[j].addr)) {
-				DEBUG(DEBUG_CRIT,("We are still serving a public address '%s' that we should not be serving.\n", 
-					ctdb_addr_to_str(&ips->ips[j].addr)));
+	if (ctdb->tunable.disable_ip_failover == 0) {
+		for (j=0; j<ips->num; j++) {
+			if (ips->ips[j].pnn == -1 && nodemap->nodes[pnn].flags == 0) {
+				DEBUG(DEBUG_CRIT,("Public address '%s' is not assigned and we could serve this ip\n",
+						ctdb_addr_to_str(&ips->ips[j].addr)));
 				need_takeover_run = true;
+			} else if (ips->ips[j].pnn == pnn) {
+				if (ctdb->do_checkpublicip && !ctdb_sys_have_ip(&ips->ips[j].addr)) {
+					DEBUG(DEBUG_CRIT,("Public address '%s' is missing and we should serve this ip\n",
+						ctdb_addr_to_str(&ips->ips[j].addr)));
+					need_takeover_run = true;
+				}
+			} else {
+				if (ctdb->do_checkpublicip && ctdb_sys_have_ip(&ips->ips[j].addr)) {
+
+					DEBUG(DEBUG_CRIT,("We are still serving a public address '%s' that we should not be serving. Removing it.\n", 
+						ctdb_addr_to_str(&ips->ips[j].addr)));
+
+					if (ctdb_ctrl_release_ip(ctdb, CONTROL_TIMEOUT(), CTDB_CURRENT_NODE, &ips->ips[j]) != 0) {
+						DEBUG(DEBUG_ERR,("Failed to release local ip address\n"));
+					}
+				}
 			}
 		}
 	}
@@ -3099,9 +3115,9 @@ static void main_loop(struct ctdb_context *ctdb, struct ctdb_recoverd *rec,
 	/* verify that we have all ip addresses we should have and we dont
 	 * have addresses we shouldnt have.
 	 */ 
-	if (ctdb->do_checkpublicip) {
+	if (ctdb->tunable.disable_ip_failover == 0) {
 		if (rec->ip_check_disable_ctx == NULL) {
-			if (verify_local_ip_allocation(ctdb, rec, pnn) != 0) {
+			if (verify_local_ip_allocation(ctdb, rec, pnn, nodemap) != 0) {
 				DEBUG(DEBUG_ERR, (__location__ " Public IPs were inconsistent.\n"));
 			}
 		}
@@ -3375,8 +3391,7 @@ static void main_loop(struct ctdb_context *ctdb, struct ctdb_recoverd *rec,
 		if (ret != 0) {
 			DEBUG(DEBUG_ERR,("Failed to read public ips from remote node %d\n",
 					 culprit));
-			ctdb_set_culprit(rec, culprit);
-			do_recovery(rec, mem_ctx, pnn, nodemap, vnnmap);
+			rec->need_takeover_run = true;
 			return;
 		}
 
@@ -3391,9 +3406,7 @@ static void main_loop(struct ctdb_context *ctdb, struct ctdb_recoverd *rec,
 
 		ret = ctdb_takeover_run(ctdb, nodemap);
 		if (ret != 0) {
-			DEBUG(DEBUG_ERR, (__location__ " Unable to setup public takeover addresses - starting recovery\n"));
-			ctdb_set_culprit(rec, ctdb->pnn);
-			do_recovery(rec, mem_ctx, pnn, nodemap, vnnmap);
+			DEBUG(DEBUG_ERR, (__location__ " Unable to setup public takeover addresses. Try again later\n"));
 			return;
 		}
 
diff --git a/server/ctdb_takeover.c b/server/ctdb_takeover.c
index 62f54d8..56c7599 100644
--- a/server/ctdb_takeover.c
+++ b/server/ctdb_takeover.c
@@ -331,6 +331,7 @@ static void ctdb_do_takeip_callback(struct ctdb_context *ctdb, int status,
 	struct ctdb_do_takeip_state *state =
 		talloc_get_type(private_data, struct ctdb_do_takeip_state);
 	int32_t ret;
+	TDB_DATA data;
 
 	if (status != 0) {
 		if (status == -ETIME) {
@@ -344,6 +345,8 @@ static void ctdb_do_takeip_callback(struct ctdb_context *ctdb, int status,
 		return;
 	}
 
+	if (ctdb->do_checkpublicip) {
+
 	ret = ctdb_announce_vnn_iface(ctdb, state->vnn);
 	if (ret != 0) {
 		ctdb_request_control_reply(ctdb, state->c, NULL, -1, NULL);
@@ -351,12 +354,27 @@ static void ctdb_do_takeip_callback(struct ctdb_context *ctdb, int status,
 		return;
 	}
 
+	}
+


-- 
CTDB repository


More information about the samba-cvs mailing list