martins/ctdb.git
10 years agotools/ctdb: CTDB_BASE is the default location of configuration files
Martin Schwenke [Mon, 21 Oct 2013 08:43:47 +0000 (19:43 +1100)]
tools/ctdb: CTDB_BASE is the default location of configuration files

Ensure that environment variable CTDB_BASE is set.

Update defaults for nodes and natgw_nodes to use CTDB_BASE.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Pair-programmed-with: Amitay Isaacs <amitay@gmail.com>

10 years agoctdbd: Don't check CTDB_BASE before setting it, just don't override
Martin Schwenke [Tue, 15 Oct 2013 03:02:31 +0000 (14:02 +1100)]
ctdbd: Don't check CTDB_BASE before setting it, just don't override

That's what the 3rd argument to setenv(3) is for...  :-)

Signed-off-by: Martin Schwenke <martin@meltin.net>
10 years agotests/integration: Pass --valgrinding option when running under valgrind
Martin Schwenke [Tue, 22 Oct 2013 04:36:30 +0000 (15:36 +1100)]
tests/integration: Pass --valgrinding option when running under valgrind

Signed-off-by: Martin Schwenke <martin@meltin.net>
10 years agoctdbd: Fix some errors in the popt configuration
Martin Schwenke [Mon, 21 Oct 2013 08:42:32 +0000 (19:42 +1100)]
ctdbd: Fix some errors in the popt configuration

That 4th argument isn't a default or similar, so consistently make it 0.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Pair-programmed-with: Amitay Isaacs <amitay@gmail.com>

10 years agoinitscript: New configuration variable CTDB_DBDIR_STATE
Martin Schwenke [Fri, 18 Oct 2013 05:43:26 +0000 (16:43 +1100)]
initscript: New configuration variable CTDB_DBDIR_STATE

Signed-off-by: Martin Schwenke <martin@meltin.net>
10 years agoscripts: Make detect_init_style() more readable
Martin Schwenke [Fri, 18 Oct 2013 02:24:03 +0000 (13:24 +1100)]
scripts: Make detect_init_style() more readable

Signed-off-by: Martin Schwenke <martin@meltin.net>
10 years agoeventscripts: Rework the iSCSI eventscript
Martin Schwenke [Thu, 17 Oct 2013 05:44:24 +0000 (16:44 +1100)]
eventscripts: Rework the iSCSI eventscript

* It should run on "ipreallocated" instead of "recovered"
* Variable name NODE -> ip since that's what it is
* Simplify some logic

Signed-off-by: Martin Schwenke <martin@meltin.net>
10 years agoeventscripts: Don't update static routes on "recovered" event
Martin Schwenke [Thu, 17 Oct 2013 05:20:18 +0000 (16:20 +1100)]
eventscripts: Don't update static routes on "recovered" event

Routes only need to be updated when IPs have moved.  IP takeover runs
will generate "ipreallocated", which is enough.  "recovered" always
follows "ipreallocated" anyway, so avoid the redundancy.

Signed-off-by: Martin Schwenke <martin@meltin.net>
10 years agoeventscripts: NAT gateway script doesn't need to handle "recovered" event
Martin Schwenke [Thu, 17 Oct 2013 05:17:26 +0000 (16:17 +1100)]
eventscripts: NAT gateway script doesn't need to handle "recovered" event

Any time a node changes flags in any significant way there will be a
takeover run, which will generate an "ipreallocated" event.  The
"recovered" event always happens straight after a takeover run so we
update the NAT gateway twice.

Signed-off-by: Martin Schwenke <martin@meltin.net>
10 years agoeventscripts: Delete placeholder "recovered" and "shutdown" events
Martin Schwenke [Thu, 17 Oct 2013 05:14:14 +0000 (16:14 +1100)]
eventscripts: Delete placeholder "recovered" and "shutdown" events

Signed-off-by: Martin Schwenke <martin@meltin.net>
10 years agoeventscripts: Clean up comment at the top of 00.ctdb
Martin Schwenke [Thu, 17 Oct 2013 05:13:21 +0000 (16:13 +1100)]
eventscripts: Clean up comment at the top of 00.ctdb

Signed-off-by: Martin Schwenke <martin@meltin.net>
10 years agoeventscripts: Remove reconfigure check from samba and winbind eventscripts
Martin Schwenke [Thu, 17 Oct 2013 05:00:39 +0000 (16:00 +1100)]
eventscripts: Remove reconfigure check from samba and winbind eventscripts

There is no reconfigure code for these scripts so no need to check for
reconfiguration.

Signed-off-by: Martin Schwenke <martin@meltin.net>
10 years agoeventscripts: Remove reconfigure code from httpd eventscript
Martin Schwenke [Thu, 17 Oct 2013 04:58:25 +0000 (15:58 +1100)]
eventscripts: Remove reconfigure code from httpd eventscript

Nothing ever (or has ever) set the "needs reconfigure" flag, so this
code is unnecessary.

Signed-off-by: Martin Schwenke <martin@meltin.net>
10 years agoeventscripts: Fold ctdb_check_tcp_ports_ctdb() into ctdb_check_tcp_ports()
Martin Schwenke [Thu, 17 Oct 2013 04:23:35 +0000 (15:23 +1100)]
eventscripts: Fold ctdb_check_tcp_ports_ctdb() into ctdb_check_tcp_ports()

A generic framework is no longer needed now that the "ctdb" checker is
the only one left.  Simplify the code.

Signed-off-by: Martin Schwenke <martin@meltin.net>
10 years agoeventscripts: Remove TCP port checks other than the built-in CTDB one
Martin Schwenke [Thu, 17 Oct 2013 00:02:54 +0000 (11:02 +1100)]
eventscripts: Remove TCP port checks other than the built-in CTDB one

"ctdb checktcpport" is no longer experimental so the other checkers
are no longer required.

Remove tests related to the removed checkers.

Signed-off-by: Martin Schwenke <martin@meltin.net>
10 years agoscripts: Remove setting of PATH from functions file
Martin Schwenke [Wed, 16 Oct 2013 23:52:00 +0000 (10:52 +1100)]
scripts: Remove setting of PATH from functions file

The current setting is inconsistent with settings on most systems,
putting /bin before /sbin.  Use of /usr/local/bin, which may be
required on some systems, is also overridden.  This can make it
difficult to do interactive debugging of script problems.

Rely on the system PATH instead.

If system-specific changes need to be made then this can be done in a
configuration file.

Signed-off-by: Martin Schwenke <martin@meltin.net>
10 years agotests/eventscripts: Run scripts under sh by default
Martin Schwenke [Wed, 16 Oct 2013 23:39:09 +0000 (10:39 +1100)]
tests/eventscripts: Run scripts under sh by default

Some scripts are disabled by default so are no executable.  Explicitly
running them under sh allows them to be run without having to mess
around and make them executable or similar.

Signed-off-by: Martin Schwenke <martin@meltin.net>
10 years agotests/eventscripts: New tests for 20.multipathd
Martin Schwenke [Tue, 15 Oct 2013 05:44:45 +0000 (16:44 +1100)]
tests/eventscripts: New tests for 20.multipathd

Signed-off-by: Martin Schwenke <martin@meltin.net>
10 years agoeventscripts: Clean up 20.multipathd
Martin Schwenke [Tue, 15 Oct 2013 05:42:45 +0000 (16:42 +1100)]
eventscripts: Clean up 20.multipathd

Reduce the complexity, including the depth of background processes.

Signed-off-by: Martin Schwenke <martin@meltin.net>
10 years agoeventscripts: NAT gateway script should export CTDB_NATGW_NODES
Martin Schwenke [Tue, 15 Oct 2013 01:00:13 +0000 (12:00 +1100)]
eventscripts: NAT gateway script should export CTDB_NATGW_NODES

Otherwise calls to "ctdb natgwlist" will not behave as expected if a
non-standard file is used, since that command will use the default
file location.

Signed-off-by: Martin Schwenke <martin@meltin.net>
10 years agoscripts: Simplify script_log() to just look at CTDB_SYSLOG variable
Martin Schwenke [Tue, 15 Oct 2013 00:57:28 +0000 (11:57 +1100)]
scripts: Simplify script_log() to just look at CTDB_SYSLOG variable

The old logic was actually wrong.  If CTDB_LOGFILE is unset then a
default is used, not syslog.

Signed-off-by: Martin Schwenke <martin@meltin.net>
10 years agoscripts: Remove support for CTDB_OPTIONS configuration variable
Martin Schwenke [Tue, 15 Oct 2013 00:54:58 +0000 (11:54 +1100)]
scripts: Remove support for CTDB_OPTIONS configuration variable

Allowing people to put random options in CTDB_OPTIONS complicates some
logic (particularly around use of syslog).  If we're going to have
variables for options then let's make sure we have a variable for each
option and make people use them.

Signed-off-by: Martin Schwenke <martin@meltin.net>
10 years agoscripts: Remove unused configuration variable CTDB_MANAGES_SCP
Martin Schwenke [Tue, 15 Oct 2013 00:31:12 +0000 (11:31 +1100)]
scripts: Remove unused configuration variable CTDB_MANAGES_SCP

Signed-off-by: Martin Schwenke <martin@meltin.net>
10 years agoeventscripts: Deprecate NFS_SERVER_MODE, use CTDB_NFS_SERVER_MODE instead
Martin Schwenke [Tue, 15 Oct 2013 00:29:23 +0000 (11:29 +1100)]
eventscripts: Deprecate NFS_SERVER_MODE, use CTDB_NFS_SERVER_MODE instead

All CTDB configuration variables should start with CTDB_.

Signed-off-by: Martin Schwenke <martin@meltin.net>
10 years agorecoverd: Remove function reload_nodes_file()
Martin Schwenke [Mon, 14 Oct 2013 02:54:39 +0000 (13:54 +1100)]
recoverd: Remove function reload_nodes_file()

It is a 1 line wrapper around ctdb_load_nodes_file(), so use that
instead.  We need less code...  :-)

Signed-off-by: Martin Schwenke <martin@meltin.net>
10 years agoRevert "null out the pointer before we reload the nodes file"
Martin Schwenke [Mon, 14 Oct 2013 01:50:08 +0000 (12:50 +1100)]
Revert "null out the pointer before we reload the nodes file"

This reverts commit 4b0f32047e8bece0a052bdbe2209afe91b7e8ce3.

This is not necessary.  It just causes a memory leak.

Signed-off-by: Martin Schwenke <martin@meltin.net>
10 years agoclient: Fix a format string argument compiler warning
Martin Schwenke [Fri, 11 Oct 2013 04:53:40 +0000 (15:53 +1100)]
client: Fix a format string argument compiler warning

Signed-off-by: Martin Schwenke <martin@meltin.net>
10 years agorecoverd: Ignore failed flag updates on inactive nodes
Amitay Isaacs [Fri, 27 Sep 2013 08:02:39 +0000 (18:02 +1000)]
recoverd: Ignore failed flag updates on inactive nodes

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Pair-programmed-with: Martin Schwenke <martin@meltin.net>

10 years agocommon/util: Use AIX specific code for setting high priority for CTDB daemon
Amitay Isaacs [Thu, 26 Sep 2013 08:47:27 +0000 (18:47 +1000)]
common/util: Use AIX specific code for setting high priority for CTDB daemon

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
10 years agogit: Ignore generated documentation files
Martin Schwenke [Fri, 11 Oct 2013 04:09:11 +0000 (15:09 +1100)]
git: Ignore generated documentation files

Signed-off-by: Martin Schwenke <martin@meltin.net>
10 years agotests: When running local tests with run_tests.sh, use fixed TEST_VAR_DIR
Martin Schwenke [Fri, 11 Oct 2013 04:05:54 +0000 (15:05 +1100)]
tests: When running local tests with run_tests.sh, use fixed TEST_VAR_DIR

Otherwise we end up with lots of useless temporary directories.

Signed-off-by: Martin Schwenke <martin@meltin.net>
10 years agoeventscripts: Fix comment - CTDB_TCP_PORT_CHECKS -> CTDB_TCP_PORT_CHECKERS
Martin Schwenke [Thu, 26 Sep 2013 10:58:50 +0000 (20:58 +1000)]
eventscripts: Fix comment - CTDB_TCP_PORT_CHECKS -> CTDB_TCP_PORT_CHECKERS

Signed-off-by: Martin Schwenke <martin@meltin.net>
10 years agotests/integration: Tweak ctdbd startup options
Martin Schwenke [Mon, 23 Sep 2013 06:24:46 +0000 (16:24 +1000)]
tests/integration: Tweak ctdbd startup options

* --public-interface is not needed

* Add --sloppy-start to speed up restarts

Signed-off-by: Martin Schwenke <martin@meltin.net>
10 years agorecoverd: Fix the VNN lmaster consistency check
Martin Schwenke [Thu, 26 Sep 2013 03:11:04 +0000 (13:11 +1000)]
recoverd: Fix the VNN lmaster consistency check

It does cope with node that don't have the lmaster capability.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Pair-programmed-with: Amitay Isaacs <amitay@gmail.com>

10 years agotests: If transaction_start fails, try again
Amitay Isaacs [Tue, 1 Oct 2013 01:54:35 +0000 (11:54 +1000)]
tests: If transaction_start fails, try again

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
10 years agotests: Make sure test exits with zero status on successful completion
Amitay Isaacs [Tue, 1 Oct 2013 01:53:57 +0000 (11:53 +1000)]
tests: Make sure test exits with zero status on successful completion

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
10 years agotests: Re-enable transaction test code
Amitay Isaacs [Fri, 27 Sep 2013 01:26:27 +0000 (11:26 +1000)]
tests: Re-enable transaction test code

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
10 years agotools/ctdb: Remove setdbseqnum command
Amitay Isaacs [Tue, 24 Sep 2013 03:10:31 +0000 (13:10 +1000)]
tools/ctdb: Remove setdbseqnum command

This command was added to test persistent database recovery with sequence
numbers.  With the new persistent transaction code, sequence numbers get
updated automatically, so there is no need for this command.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
10 years agotests: No need to set sequence number when modifying persistent database
Amitay Isaacs [Tue, 24 Sep 2013 03:08:48 +0000 (13:08 +1000)]
tests: No need to set sequence number when modifying persistent database

With the new persistent transaction code, sequence numbers will be
automatically updated whenever a record is updated.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
10 years agoclient: Remove old persistent transaction code
Amitay Isaacs [Wed, 25 Sep 2013 09:16:53 +0000 (19:16 +1000)]
client: Remove old persistent transaction code

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
10 years agoclient: Reimplement persistent transaction code using TRANS3_COMMIT
Amitay Isaacs [Mon, 23 Sep 2013 08:30:04 +0000 (18:30 +1000)]
client: Reimplement persistent transaction code using TRANS3_COMMIT

Implementing persistent trasnaction code from Samba.

Persistent transaction code was reimplemented in Samba using g_lock.tdb
to hold transaction locks and using TRANS3_COMMIT control.

Implementation details:

1. When starting a transaction, create a record with "transaction-<dbid>"
   as key and store current server_id in the structure.

2. If a record already exists, some other client has already started a
   transaction.  Verify that the process corresponding to server_id stored
   in the record really exists or it's a stale record and overwrite it.

3. All modifications to the actual persistent database are stored in a
   marshal buffer.

4. When transaction is committed, read the sequence number of the
   persistent database and increment it.  Sequence number record is also
   stored in the marshal buffer.

5. Send the changed records (marshal buffer) in TRANS3_COMMIT control
   to all the active nodes.

6. If all controls succeed, verify that the sequence number has been
   incremented.  Commit is successful.  If any of the controls fail,
   abort the transaction.

7. In case sequence number has not yet been incremented, then database
   recovery has been triggered.  So repeat from step 5.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
10 years agoclient: Add functions to parse g_lock.tdb records
Amitay Isaacs [Fri, 4 Oct 2013 05:38:04 +0000 (15:38 +1000)]
client: Add functions to parse g_lock.tdb records

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
10 years agoclient: Add functions to handle server_id structure
Amitay Isaacs [Fri, 4 Oct 2013 05:37:24 +0000 (15:37 +1000)]
client: Add functions to handle server_id structure

server_id records are stored in g_lock.tdb for persistent transactions.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
10 years agoctdbd: Remove transaction code related to TRANS2 commits
Amitay Isaacs [Thu, 12 Sep 2013 06:43:43 +0000 (16:43 +1000)]
ctdbd: Remove transaction code related to TRANS2 commits

This removes data types and structure elements related to TRANS2
persistent transaction code.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
10 years agoctdbd: Deprecate TRANS2 commit controls
Amitay Isaacs [Thu, 12 Sep 2013 06:27:39 +0000 (16:27 +1000)]
ctdbd: Deprecate TRANS2 commit controls

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
10 years agoctdbd: Create a utility function to log error for "not implemented" controls
Amitay Isaacs [Thu, 12 Sep 2013 06:36:09 +0000 (16:36 +1000)]
ctdbd: Create a utility function to log error for "not implemented" controls

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
10 years agoinclude: Remove unused set_dmaster structure
Amitay Isaacs [Thu, 12 Sep 2013 06:35:17 +0000 (16:35 +1000)]
include: Remove unused set_dmaster structure

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
10 years agotests/tool: Remove references in libctdb in file and function names
Martin Schwenke [Wed, 18 Sep 2013 04:27:03 +0000 (14:27 +1000)]
tests/tool: Remove references in libctdb in file and function names

Main changes are:

  libctdb_test.c -> ctdb_test_stubs.c
  ctdb_tool_libctdb.c -> ctdb_functest.c

ctdb_tool_stubby.c is gone, replaced with existing ctdb_test.c.

Functions starting with "libctdb_test_" now start with
"ctdb_test_stubs_".

Signed-off-by: Martin Schwenke <martin@meltin.net>
Pair-programmed-with: Amitay Isaacs <amitay@gmail.com>

10 years agotests/tool: Rework test programs so they no longer expect libctdb
Martin Schwenke [Wed, 18 Sep 2013 04:01:00 +0000 (14:01 +1000)]
tests/tool: Rework test programs so they no longer expect libctdb

Instead, override controls using preprocessor magic.

Signed-off-by: Martin Schwenke <martin@meltin.net>
10 years agotests/tool: Fix some comment typos
Martin Schwenke [Wed, 18 Sep 2013 03:43:53 +0000 (13:43 +1000)]
tests/tool: Fix some comment typos

Signed-off-by: Martin Schwenke <martin@meltin.net>
10 years agotools/ctdb: Stop return value from being clobbered in control_lvsmaster()
Martin Schwenke [Wed, 18 Sep 2013 03:40:52 +0000 (13:40 +1000)]
tools/ctdb: Stop return value from being clobbered in control_lvsmaster()

ret is initialised too early and is clobbered by the call to
ctdb_ctrl_getcapabilities().  Initialising it later means that the
function returns -1 when no LVS master is found.

Signed-off-by: Martin Schwenke <martin@meltin.net>
10 years agoclient: Fix some format string compiler warnings
Martin Schwenke [Wed, 18 Sep 2013 03:40:10 +0000 (13:40 +1000)]
client: Fix some format string compiler warnings

Signed-off-by: Martin Schwenke <martin@meltin.net>
10 years agocommon: Fix setting of debug level in the client code
Amitay Isaacs [Fri, 30 Aug 2013 13:38:15 +0000 (23:38 +1000)]
common: Fix setting of debug level in the client code

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
10 years agolibctdb: Remove incomplete libctdb
Amitay Isaacs [Sun, 25 Aug 2013 11:44:59 +0000 (21:44 +1000)]
libctdb: Remove incomplete libctdb

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
10 years agotools/ctdb: Pass memory context for returning nodes in parse_nodestring
Amitay Isaacs [Tue, 27 Aug 2013 04:46:08 +0000 (14:46 +1000)]
tools/ctdb: Pass memory context for returning nodes in parse_nodestring

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
10 years agotests: Do not use libctdb code in tests
Amitay Isaacs [Sun, 25 Aug 2013 11:43:29 +0000 (21:43 +1000)]
tests: Do not use libctdb code in tests

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
10 years agotools/ctdb: Do not use libctdb for commandline tool
Amitay Isaacs [Thu, 29 Aug 2013 07:22:38 +0000 (17:22 +1000)]
tools/ctdb: Do not use libctdb for commandline tool

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
10 years agoclient: Add ctdb_ctrl_getdbseqnum() function
Amitay Isaacs [Fri, 23 Aug 2013 06:52:24 +0000 (16:52 +1000)]
client: Add ctdb_ctrl_getdbseqnum() function

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
10 years agoclient: Add ctdb_ctrl_getdbstatistics() function
Amitay Isaacs [Fri, 23 Aug 2013 06:52:02 +0000 (16:52 +1000)]
client: Add ctdb_ctrl_getdbstatistics() function

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
10 years agoclient: Add ctdb_client_check_message_handlers() function
Amitay Isaacs [Fri, 23 Aug 2013 06:51:26 +0000 (16:51 +1000)]
client: Add ctdb_client_check_message_handlers() function

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
10 years agoclient: Remove extra whitespaces
Amitay Isaacs [Fri, 23 Aug 2013 06:49:46 +0000 (16:49 +1000)]
client: Remove extra whitespaces

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
10 years agotests: Remove unused test program ctdb_fetch_lock_once
Amitay Isaacs [Fri, 23 Aug 2013 07:21:24 +0000 (17:21 +1000)]
tests: Remove unused test program ctdb_fetch_lock_once

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
10 years agotools/ctdb: When printing TDB data as a string, use correct length of the string
Amitay Isaacs [Thu, 29 Aug 2013 06:58:47 +0000 (16:58 +1000)]
tools/ctdb: When printing TDB data as a string, use correct length of the string

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
10 years agotools/ctdb: Remove un-implemented ctdb vacuum command
Amitay Isaacs [Fri, 23 Aug 2013 06:57:40 +0000 (16:57 +1000)]
tools/ctdb: Remove un-implemented ctdb vacuum command

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
10 years agotests: Add a simple test to test cluster wide database traverse
Amitay Isaacs [Wed, 25 Sep 2013 09:10:13 +0000 (19:10 +1000)]
tests: Add a simple test to test cluster wide database traverse

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
10 years agotraverse: Send traverse end record from traverse child process
Amitay Isaacs [Mon, 9 Sep 2013 02:46:26 +0000 (12:46 +1000)]
traverse: Send traverse end record from traverse child process

Traverse records are sent directly from traverse child process, but
the last empty record signalling end of traverse is sent from ctdbd.
This creates a race condition between ctdbd and traverse child.
There are two fds from traverse child to ctdbd - a pipe to track status
of the child process and unix socket connection for sending records.
It's possible that last few records are sitting in unix socket buffer
when ctdbd reads the status written from traverse child.  This will
be interpreted as end of traverse and ctdbd will send the last empty
record to originating node before it has processed the pending packets
in unix socket connection.

The race is avoided by sending the last empty record marking end of
traverse from the child process.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
10 years agotraverse: Wait till all data has been flushed from output queue
Amitay Isaacs [Tue, 10 Sep 2013 07:52:26 +0000 (17:52 +1000)]
traverse: Wait till all data has been flushed from output queue

To improve the traverse performance, records are directly sent from
traverse child process to the originating node.  Make sure that all the
data is sent via socket, before informing ctdbd that traverse is complete.

Without waiting for all the packets to be flushed from the queue,
child process can incorrectly signal ctdbd that traverse has ended.
This will cause the pending records in the queue never to make it to
the originating node and traverse information will not be complete.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
10 years agotraverse: Use ctdb local variable for convenience
Amitay Isaacs [Fri, 13 Sep 2013 03:28:31 +0000 (13:28 +1000)]
traverse: Use ctdb local variable for convenience

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
10 years agotraverse: Check if local traverse failed or succeeded
Amitay Isaacs [Fri, 6 Sep 2013 08:11:40 +0000 (18:11 +1000)]
traverse: Check if local traverse failed or succeeded

By passing the result of tdb_traverse_read() allows ctdbd to determine
if the local traverse succeeded or not.  In case of a problem with local
traverse, ctdbd can log an error.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
10 years agotraverse: Log information when traverse starts and ends
Amitay Isaacs [Fri, 6 Sep 2013 04:51:54 +0000 (14:51 +1000)]
traverse: Log information when traverse starts and ends

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
10 years agotool/ltdbtool: -h option does not require an argument
Martin Schwenke [Mon, 23 Sep 2013 06:23:36 +0000 (16:23 +1000)]
tool/ltdbtool: -h option does not require an argument

Signed-off-by: Martin Schwenke <martin@meltin.net>
10 years agoscripts: Add support for optional ctdbd.conf configuration file
Martin Schwenke [Mon, 23 Sep 2013 06:22:36 +0000 (16:22 +1000)]
scripts: Add support for optional ctdbd.conf configuration file

Signed-off-by: Martin Schwenke <martin@meltin.net>
Pair-programmed-with: Amitay Isaacs <amitay@gmail.com>

10 years agoutils: Make debug level strings case-insensitive
Martin Schwenke [Mon, 23 Sep 2013 06:21:30 +0000 (16:21 +1000)]
utils: Make debug level strings case-insensitive

Signed-off-by: Martin Schwenke <martin@meltin.net>
Pair-programmed-with: Amitay Isaacs <amitay@gmail.com>

10 years agotools/ctdb: Fix help messages for ctdb commands
Martin Schwenke [Mon, 23 Sep 2013 06:20:42 +0000 (16:20 +1000)]
tools/ctdb: Fix help messages for ctdb commands

Signed-off-by: Martin Schwenke <martin@meltin.net>
10 years agotools/ctdb: Ban time of 0 is invalid
Martin Schwenke [Mon, 23 Sep 2013 06:19:52 +0000 (16:19 +1000)]
tools/ctdb: Ban time of 0 is invalid

Apparently it used to mean a permanent ban but it is unclear if this
was ever supported.

Signed-off-by: Martin Schwenke <martin@meltin.net>
10 years agoeventscripts: Load CTDB configuration settings in 70.iscsi
Amitay Isaacs [Mon, 16 Sep 2013 04:35:13 +0000 (14:35 +1000)]
eventscripts: Load CTDB configuration settings in 70.iscsi

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
10 years agorecoverd: Disable takeover runs on other nodes for 5 minutes
Martin Schwenke [Wed, 18 Sep 2013 07:07:32 +0000 (17:07 +1000)]
recoverd: Disable takeover runs on other nodes for 5 minutes

60 seconds might not be long enough to kill all connections and
release IPs.

Signed-off-by: Martin Schwenke <martin@meltin.net>
10 years agorecoverd: Improve logging for takeover runs
Martin Schwenke [Wed, 18 Sep 2013 07:06:16 +0000 (17:06 +1000)]
recoverd: Improve logging for takeover runs

Takeover runs are currently silent when they succeed.  However, they
are important, so log something by default.

Signed-off-by: Martin Schwenke <martin@meltin.net>
10 years agotools/ctdb: Use the standard long timeout when disabling takeover runs
Martin Schwenke [Wed, 18 Sep 2013 06:35:18 +0000 (16:35 +1000)]
tools/ctdb: Use the standard long timeout when disabling takeover runs

This means that takeover runs will be disabled for about as long as the
reloadips control can take to complete.

Signed-off-by: Martin Schwenke <martin@meltin.net>
10 years agotools/ctdb: Fix arguments/semantics of rebalance node
Martin Schwenke [Fri, 6 Sep 2013 03:20:26 +0000 (13:20 +1000)]
tools/ctdb: Fix arguments/semantics of rebalance node

There's no reason why specifying a node should be compulsory.  This is
a cluster-wide operation because it is implemented by the recovery
master so multiple nodes should not be specified using -n.  However,
the command should be able to specify multiple nodes so let it have
its own nodestring argument.

This change should be backward compatible with the old requirement of
specifying a single node via -n.

Signed-off-by: Martin Schwenke <martin@meltin.net>
10 years agotools/ctdb: Make rebalancenode more robust
Martin Schwenke [Fri, 6 Sep 2013 03:19:09 +0000 (13:19 +1000)]
tools/ctdb: Make rebalancenode more robust

Use a broadcast instead of trying to win the race of determining the
recovery master and then sending the message before the recovery
master changes.

Signed-off-by: Martin Schwenke <martin@meltin.net>
10 years agotests/simple: Fix the reloadips test to cope with changes to reloadips
Martin Schwenke [Fri, 6 Sep 2013 01:29:14 +0000 (11:29 +1000)]
tests/simple: Fix the reloadips test to cope with changes to reloadips

Specifying nodes to reload no longer uses -n.

Signed-off-by: Martin Schwenke <martin@meltin.net>
10 years agorecoverd: Be careful about freeing the list of IP rebalance target nodes
Martin Schwenke [Fri, 6 Sep 2013 01:23:07 +0000 (11:23 +1000)]
recoverd: Be careful about freeing the list of IP rebalance target nodes

It can change during a takeover run.  If it does then don't free it.

There are potentially fancier solutions (e.g. check what PNNs are new
to the list) to this issue but this is the simplest.

Signed-off-by: Martin Schwenke <martin@meltin.net>
10 years agorecoverd: reloadips should rebalance target nodes for new IPs
Martin Schwenke [Fri, 6 Sep 2013 01:21:10 +0000 (11:21 +1000)]
recoverd: reloadips should rebalance target nodes for new IPs

Otherwise, if existing IPs are added to extra nodes (that have,
perhaps, been disconnected) then those IPs will not be rebalanced
across the extra nodes.

Signed-off-by: Martin Schwenke <martin@meltin.net>
10 years agoctdbd: Make ctdb_reloadips_child send controls asynchronously
Martin Schwenke [Thu, 5 Sep 2013 05:56:51 +0000 (15:56 +1000)]
ctdbd: Make ctdb_reloadips_child send controls asynchronously

Deleting IPs can take a while because IPs are released and connections
are killed.  This can take a while so do them in parallel.  In fact,
since the set of IPs being added and deleted will be disjoint, send
all the adds/deletes at the same time and then wait.

Signed-off-by: Martin Schwenke <martin@meltin.net>
10 years agorecoverd: Fix the implementation of CTDB_SRVID_REBALANCE_NODE
Martin Schwenke [Wed, 4 Sep 2013 04:30:04 +0000 (14:30 +1000)]
recoverd: Fix the implementation of CTDB_SRVID_REBALANCE_NODE

The current implementation has a few flaws:

* A takeover run is called unconditionally when the timer goes even if
  the recovery master role has moved.  This means a node other than
  the recovery master can incorrectly do a takeover run.

* The rebalancing target nodes are cleared in the setup for a takeover
  run, regardless of whether the takeover run succeeds.

* The timer to force a rebalance isn't cleared if another takeover run
  occurs before the deadline.  Any forced rebalancing will happen in
  the first takeover run and when the timer expires some time later
  then an unnecessary takeover run will occur.

* If the recovery master role moves then the rebalancing data will
  stay on the original node and affect the next takeover run to occur
  if the recovery master role should come back to the original node.

Instead, store an array of rebalance target nodes in the recovery
master context.  This is passed as an extra argument to
ctdb_takeover_run() each time it is called and is cleared when a
takeover run succeeds.  The timer hangs off the array of rebalance
target nodes, which is cleared if the node isn't the recovery master.

This means that it is possible to lose rebalance data if the recovery
master role moves.  However, that's a difficult problem to solve.  The
best way of approaching it is probably to try to stop the recovery
master role from jumping around unnecesarily when inactive nodes join
the cluster.

The long term solution is to avoid this nonsense completely.  The IP
allocation algorithm needs to cache state between runs so that it
knows which nodes have just become healthy.  This also needs recovery
master stability.

Signed-off-by: Martin Schwenke <martin@meltin.net>
10 years agorecoverd: Remove unused CTDB_SRVID_RELOAD_ALL_IPS and handler
Martin Schwenke [Wed, 28 Aug 2013 05:46:27 +0000 (15:46 +1000)]
recoverd: Remove unused CTDB_SRVID_RELOAD_ALL_IPS and handler

Signed-off-by: Martin Schwenke <martin@meltin.net>
10 years agotools/ctdb: Reimplement reloadips
Martin Schwenke [Wed, 28 Aug 2013 05:38:48 +0000 (15:38 +1000)]
tools/ctdb: Reimplement reloadips

This implementation disables takeover runs on all nodes before trying
to reload IPs.  It also takes "all" or the list of PNNs as an argument
to the command instead of to -n.  -n can still be specified with a
single node indicating that node should be considered the current node
- that might be confusing so could be removed.

This implementation does not use CTDB_SRVID_RELOAD_ALL_IPS, so it can
be removed.

Signed-off-by: Martin Schwenke <martin@meltin.net>
10 years agorecoverd: Defer ipreallocated requests when takeover runs are disabled
Martin Schwenke [Wed, 28 Aug 2013 01:50:23 +0000 (11:50 +1000)]
recoverd: Defer ipreallocated requests when takeover runs are disabled

The takeover run will fail anyway but deferring seems like a cleaner
option.

Signed-off-by: Martin Schwenke <martin@meltin.net>
10 years agorecoverd: Reimplement CTDB_SRVID_DISABLE_IP_CHECK
Martin Schwenke [Wed, 28 Aug 2013 01:32:54 +0000 (11:32 +1000)]
recoverd: Reimplement CTDB_SRVID_DISABLE_IP_CHECK

Use disable_takeover_runs_handler() instead of maintaining duplicate
logic.

Signed-off-by: Martin Schwenke <martin@meltin.net>
10 years agorecoverd: New SRVID message CTDB_SRVID_DISABLE_TAKEOVER_RUNS
Martin Schwenke [Tue, 27 Aug 2013 05:04:40 +0000 (15:04 +1000)]
recoverd: New SRVID message CTDB_SRVID_DISABLE_TAKEOVER_RUNS

This implements a superset of CTDB_SRVID_DISABLE_IP_CHECK.  It stops
the IP checks but also causes any attempted takeover runs to fail and
be rescheduled.

This is meant to completely stop IP movements.

Signed-off-by: Martin Schwenke <martin@meltin.net>
10 years agotools/ctdb: Add a wait_for_all option to srvid_broadcast()
Martin Schwenke [Fri, 16 Aug 2013 08:47:51 +0000 (18:47 +1000)]
tools/ctdb: Add a wait_for_all option to srvid_broadcast()

This will be useful for other SRVIDs.

The error checking in the handler depends on the SRVID responding with
a uint32_t where <0 indicates an error and >=0 is a PNN that
succeeded.

Signed-off-by: Martin Schwenke <martin@meltin.net>
10 years agotools/ctdb: Factor out SRVID broadcast code from ipreallocate()
Martin Schwenke [Fri, 16 Aug 2013 07:06:23 +0000 (17:06 +1000)]
tools/ctdb: Factor out SRVID broadcast code from ipreallocate()

Signed-off-by: Martin Schwenke <martin@meltin.net>
10 years agotools/ctdb: Change ipreallocate() to use a local done flag
Martin Schwenke [Fri, 16 Aug 2013 06:25:28 +0000 (16:25 +1000)]
tools/ctdb: Change ipreallocate() to use a local done flag

Instead of the current global variable.  This is in anticipation of
abstracting the code.

Signed-off-by: Martin Schwenke <martin@meltin.net>
10 years agorecoverd: Factor out the SRVID handling code
Martin Schwenke [Fri, 16 Aug 2013 10:02:34 +0000 (20:02 +1000)]
recoverd: Factor out the SRVID handling code

The code that handles IP reallocate requests can be reused.

This also changes the result back to a SRVID caller to the PNN on
success or a negative error code on failure.  None of the callers
currently look at the result so this is harmless... but it will be
useful later.

Signed-off-by: Martin Schwenke <martin@meltin.net>
10 years agorecoverd: Make the SRVID request structure generic
Martin Schwenke [Fri, 16 Aug 2013 10:10:10 +0000 (20:10 +1000)]
recoverd: Make the SRVID request structure generic

No need for a separate one for each SRVID.

Signed-off-by: Martin Schwenke <martin@meltin.net>
10 years agorecoverd: Move disabling of IP checks into do_takeover_run()
Martin Schwenke [Tue, 3 Sep 2013 01:21:09 +0000 (11:21 +1000)]
recoverd: Move disabling of IP checks into do_takeover_run()

Signed-off-by: Martin Schwenke <martin@meltin.net>
10 years agorecoverd: do_takeover_run() should mark when a takeover run is in progress
Martin Schwenke [Tue, 3 Sep 2013 01:20:01 +0000 (11:20 +1000)]
recoverd: do_takeover_run() should mark when a takeover run is in progress

Nested takeover runs should never happens so they should fail.

Signed-off-by: Martin Schwenke <martin@meltin.net>
10 years agorecoverd: takeover_fail_callback() doesn't need to set rec->need_takeover_run
Martin Schwenke [Tue, 27 Aug 2013 02:19:18 +0000 (12:19 +1000)]
recoverd: takeover_fail_callback() doesn't need to set rec->need_takeover_run

It is set on every failure anyway.

Signed-off-by: Martin Schwenke <martin@meltin.net>
10 years agorecoverd: Fail takeover run if "ipreallocated" fails
Martin Schwenke [Mon, 9 Sep 2013 02:13:11 +0000 (12:13 +1000)]
recoverd: Fail takeover run if "ipreallocated" fails

Previously flagging a failure was probably avoided because of attempts
to run "ipreallocated" events on stopped and banned nodes, which would
fail because they are in recovery.  Given the change to a new control
and that fallback only retries the old method on active nodes, this
should never fail in reasonable circumstances.

Signed-off-by: Martin Schwenke <martin@meltin.net>