ctdb-takeover: IPAllocAlgorithm replaces LCP2PublicIPs, DeterministicIPs
authorMartin Schwenke <martin@meltin.net>
Thu, 15 Dec 2016 03:09:16 +0000 (14:09 +1100)
committerAmitay Isaacs <amitay@samba.org>
Mon, 19 Dec 2016 03:07:08 +0000 (04:07 +0100)
Introduce a single new tunable IPAllocAlgorithm to set the IP
allocation algorithm.  This defaults to 2 for LCP2 IP address
allocation.

Tunables LCP2PublicIPs and DeterministicIPs are obsolete.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/common/tunable.c
ctdb/doc/ctdb-tunables.7.xml
ctdb/doc/ctdb.1.xml
ctdb/protocol/protocol.h
ctdb/server/ctdb_takeover.c
ctdb/server/ipalloc_deterministic.c
ctdb/tests/simple/04_ctdb_setvar.sh
ctdb/tests/simple/23_ctdb_moveip.sh
ctdb/tests/tool/ctdb.listvars.001.sh

index 5f360887f24af2e508780ea19bf56f436586c17f..5b640d9a902daf4cb8c8d7d31740e7c1ad8846b7 100644 (file)
@@ -75,9 +75,9 @@ static struct {
                offsetof(struct ctdb_tunable_list, rerecovery_timeout) },
        { "EnableBans", 1, false,
                offsetof(struct ctdb_tunable_list, enable_bans) },
-       { "DeterministicIPs", 0, false,
+       { "DeterministicIPs", 0, true,
                offsetof(struct ctdb_tunable_list, deterministic_public_ips) },
-       { "LCP2PublicIPs", 1, false,
+       { "LCP2PublicIPs", 1, true,
                offsetof(struct ctdb_tunable_list, lcp2_public_ip_assignment) },
        { "ReclockPingPeriod", 60, true,
                offsetof(struct ctdb_tunable_list,  reclock_ping_period) },
@@ -153,6 +153,8 @@ static struct {
                offsetof(struct ctdb_tunable_list, rec_buffer_size_limit) },
        { "QueueBufferSize", 1024, false,
                offsetof(struct ctdb_tunable_list, queue_buffer_size) },
+       { "IPAllocAlgorithm", 2, false,
+               offsetof(struct ctdb_tunable_list, ip_alloc_algorithm) },
        { NULL, 0, true, }
 };
 
index 1e263dac9a412782112f2edb694e6e2719d58b4b..8a789a5e3dc287510448998e67f5dcb0da6444d6 100644 (file)
       </para>
     </refsect2>
 
-    <refsect2>
-      <title>DeterministicIPs</title>
-      <para>Default: 0</para>
-      <para>
-       When set to 1, ctdb will try to keep public IP addresses locked
-       to specific nodes as far as possible. This makes it easier
-       for debugging since you can know that as long as all nodes are
-       healthy public IP X will always be hosted by node Y.
-      </para>
-      <para>
-       The cost of using deterministic IP address assignment is that it
-       disables part of the logic where ctdb tries to reduce the number
-       of public IP assignment changes in the cluster. This tunable may
-       increase the number of IP failover/failbacks that are performed
-       on the cluster by a small margin.
-      </para>
-    </refsect2>
-
     <refsect2>
       <title>DisableIPFailover</title>
       <para>Default: 0</para>
       </para>
     </refsect2>
 
+    <refsect2>
+      <title>IPAllocAlgorithm</title>
+      <para>Default: 2</para>
+      <para>
+       Selects the algorithm that CTDB should use when doing public
+       IP address allocation.  Meaningful values are:
+      </para>
+      <variablelist>
+       <varlistentry>
+         <term>0</term>
+         <listitem>
+           <para>
+             Deterministic IP address allocation.
+           </para>
+           <para>
+             This is a simple and fast option.  However, it can cause
+             unnecessary address movement during fail-over because
+             each address has a "home" node.  Works badly when some
+             nodes do not have any addresses defined.  Should be used
+             with care when addresses are defined across multiple
+             networks.
+           </para>
+         </listitem>
+       </varlistentry>
+       <varlistentry>
+         <term>1</term>
+         <listitem>
+           <para>
+             Non-deterministic IP address allocation.
+           </para>
+           <para>
+             This is a relatively fast option that attempts to do a
+             minimise unnecessary address movements.  Addresses do
+             not have a "home" node.  Rebalancing is limited but it
+             usually adequate.  Works badly when addresses are
+             defined across multiple networks.
+           </para>
+         </listitem>
+       </varlistentry>
+       <varlistentry>
+         <term>2</term>
+         <listitem>
+           <para>
+             LCP2 IP address allocation.
+           </para>
+           <para>
+             Uses a heuristic to assign addresses defined across
+             multiple networks, usually balancing addresses on each
+             network evenly across nodes.  Addresses do not have a
+             "home" node.  Minimises unnecessary address movements.
+             The algorithm is complex, so is slower than other
+             choices for a large number of addresses.  However, it
+             can calculate an optimal assignment of 900 addresses in
+             under 10 seconds on modern hardware.
+           </para>
+         </listitem>
+       </varlistentry>
+      </variablelist>
+      <para>
+       If the specified value is not one of these then the default
+       will be used.
+      </para>
+    </refsect2>
+
     <refsect2>
       <title>KeepaliveInterval</title>
       <para>Default: 5</para>
       </para>
     </refsect2>
 
-    <refsect2>
-      <title>LCP2PublicIPs</title>
-      <para>Default: 1</para>
-      <para>
-       When set to 1, ctdb uses the LCP2 ip allocation algorithm.
-      </para>
-    </refsect2>
-
     <refsect2>
       <title>LockProcessesPerDB</title>
       <para>Default: 200</para>
index 2f371c0a86c2ceba525e24621ae4b7e42a7144dc..1d6979a4890a244903c6767cdeba04fb28e4b9b4 100644 (file)
@@ -813,8 +813,6 @@ DatabaseHashSize        = 100001
 DatabaseMaxDead         = 5
 RerecoveryTimeout       = 10
 EnableBans              = 1
-DeterministicIPs        = 0
-LCP2PublicIPs           = 1
 NoIPFailback            = 0
 DisableIPFailover       = 0
 VerboseMemoryNames      = 0
@@ -845,9 +843,11 @@ DBRecordSizeWarn        = 10000000
 DBSizeWarn              = 100000000
 PullDBPreallocation     = 10485760
 NoIPHostOnAllDisabled   = 0
-Samba3AvoidDeadlocks    = 0
 TDBMutexEnabled         = 0
 LockProcessesPerDB      = 200
+RecBufferSizeLimit      = 1000000
+QueueBufferSize         = 1024
+IPAllocAlgorithm        = 2
        </screen>
       </refsect3>
     </refsect2>
@@ -1201,7 +1201,7 @@ DB Statistics: locking.tdb
        when you have changed the tunables for the daemon to:
       </para>
       <para>
-       DeterministicIPs = 0
+       IPAllocAlgorithm != 0
       </para>
       <para>
        NoIPFailback = 1
index c4a7c010de567909a97f217ada8a21c2815fb4e0..7b5a5983be11229ba1f84ec7dc6fa132dafa3a16 100644 (file)
@@ -631,6 +631,7 @@ struct ctdb_tunable_list {
        uint32_t lock_processes_per_db;
        uint32_t rec_buffer_size_limit;
        uint32_t queue_buffer_size;
+       uint32_t ip_alloc_algorithm;
 };
 
 struct ctdb_tickle_list {
index 883951ffc6c67e5e06e7367af48b10e23d052cbf..19b7f07b45e3e0a7dec2c1b192c27b6d592ed0b5 100644 (file)
@@ -1278,13 +1278,16 @@ static bool set_ipflags(struct ctdb_context *ctdb,
 static enum ipalloc_algorithm
 determine_algorithm(const struct ctdb_tunable_list *tunables)
 {
-       if (1 == tunables->lcp2_public_ip_assignment) {
-               return IPALLOC_LCP2;
-       } else if (1 == tunables->deterministic_public_ips) {
+       switch (tunables->ip_alloc_algorithm) {
+       case 0:
                return IPALLOC_DETERMINISTIC;
-       } else {
+       case 1:
                return IPALLOC_NONDETERMINISTIC;
-       }
+       case 2:
+               return IPALLOC_LCP2;
+       default:
+               return IPALLOC_LCP2;
+       };
 }
 
 struct takeover_callback_data {
index c11d5f9dc71a05e1498ec328c2ed5fdec8a35716..097d8169da8277b03e63833a43437bb9146b0b8a 100644 (file)
@@ -49,7 +49,8 @@ bool ipalloc_deterministic(struct ipalloc_state *ipalloc_state)
         * back IPs to their "home" node.
         */
        if (ipalloc_state->no_ip_failback) {
-               DEBUG(DEBUG_WARNING, ("WARNING: 'NoIPFailback' set but ignored - incompatible with 'DeterministicIPs\n"));
+               D_WARNING("WARNING: 'NoIPFailback' set but ignored - "
+                         "incompatible with 'Deterministic IPs\n");
        }
 
        unassign_unsuitable_ips(ipalloc_state);
index 5012e318cc82366218978810393fab84481431c9..7d1d495211bc8ddf6c9acb071b23cab76d4020ee 100755 (executable)
@@ -18,8 +18,8 @@ Steps:
 1. Verify that the status on all of the ctdb nodes is 'OK'.
 2. Get a list of all the ctdb tunable variables, using the 'ctdb
    listvars' command.
-3. Set the value of one of the variables using the 'setvar' control on
-   one of the nodes.  E.g. 'ctdb setvar DeterministicIPs 0'.
+3. Increment the value of one of the variables using the 'setvar' control on
+   one of the nodes.  E.g. 'ctdb setvar RecoverTimeout 31'.
 4. Verify that the 'listvars' control now shows the new value for the
    variable.
 
index f92d7f78ee63e3e02b0a82cf0e17a9c7df177a09..c6e70bf4e94585f965fd33e9a47e9dddd8be4db0 100755 (executable)
@@ -8,7 +8,8 @@ Verify that  'ctdb moveip' allows movement of public IPs between cluster nodes.
 This test does not do any network level checks to make sure IP
 addresses are actually on interfaces.  It just consults "ctdb ip".
 
-To work, this test unsets DeterministicIPs and sets NoIPFailback.
+To work, this test ensures that IPAllocAlgorithm is not set to 0
+(Deterministic IPs) and sets NoIPFailback.
 EOF
 }
 
@@ -49,8 +50,8 @@ fi
 
 echo "Target node is ${to_node}"
 
-echo "Turning off DeterministicIPs..."
-try_command_on_node -q all $CTDB setvar DeterministicIPs 0
+echo "Setting IPAllocAlgorithm=2 to avoid Deterministic IPs..."
+try_command_on_node -q all $CTDB setvar IPAllocAlgorithm 2
 
 echo "Turning on NoIPFailback..."
 try_command_on_node -q all $CTDB setvar NoIPFailback 1
index 539dd2f11dc09a817c37c91aa70ed6c897178175..03e2995db9b3f0eda3b153333dcc0697c156ec3d 100755 (executable)
@@ -31,8 +31,6 @@ DatabaseHashSize           = 100001
 DatabaseMaxDead            = 5
 RerecoveryTimeout          = 10
 EnableBans                 = 1
-DeterministicIPs           = 0
-LCP2PublicIPs              = 1
 NoIPFailback               = 0
 DisableIPFailover          = 0
 VerboseMemoryNames         = 0
@@ -65,6 +63,7 @@ TDBMutexEnabled            = 0
 LockProcessesPerDB         = 200
 RecBufferSizeLimit         = 1000000
 QueueBufferSize            = 1024
+IPAllocAlgorithm           = 2
 EOF
 
 simple_test