metze/ctdb/wip.git
14 years agoRename the tunable EventScriptBanCount to EventScriptTimeoutCount
Ronnie Sahlberg [Mon, 14 Dec 2009 04:53:23 +0000 (15:53 +1100)]
Rename the tunable EventScriptBanCount to EventScriptTimeoutCount
since we no longer ban nodes when dodgy scripts continue to hang.

We now only mark nodes as unhealthy if monitor events fail or timeout. Never ban.

14 years agocleanup: remove a tunable we no longer use in the eventscripts any more :
Ronnie Sahlberg [Mon, 14 Dec 2009 04:48:47 +0000 (15:48 +1100)]
cleanup:   remove a tunable we no longer use in the eventscripts any more :
EventScriptUnhealthyOnTimeout

14 years agoctdb: don't print OUTPUT: for DISABLED scripts
Rusty Russell [Thu, 10 Dec 2009 10:05:54 +0000 (20:35 +1030)]
ctdb: don't print OUTPUT: for DISABLED scripts

In other news, did you know ctime() returns a \n-terminated string?

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
14 years agoeventscript: fix monitoring when killed by another script command
Rusty Russell [Thu, 10 Dec 2009 09:55:33 +0000 (20:25 +1030)]
eventscript: fix monitoring when killed by another script command

Commit c1ba1392fe "eventscript: get rid of ctdb_control_event_script_finished
altogether" was wrong: there is one case where we want to free the script
without transferring their status to last_status.  This happens because we
always kill an running monitor command when we run any other command.

This still isn't quite right (and never was): the callback will be called
with status value 0, which might flip us to HEALTHY if we were unhealthy.
This is conveniently fixed in my next set of patches :)

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
14 years agoremove the variable "disable when unhealthy"
Ronnie Sahlberg [Mon, 14 Dec 2009 04:40:54 +0000 (15:40 +1100)]
remove the variable "disable when unhealthy"
there is no rational need for a setting where we permanently mark nodes as disabled everytime an eventscript fails

14 years agoFrom: Volker Lendecke <vl@samba.org>
Ronnie Sahlberg [Wed, 9 Dec 2009 21:53:55 +0000 (08:53 +1100)]
From: Volker Lendecke <vl@samba.org>
Date: Wed, 9 Dec 2009 22:45:12 +0100
Subject: [PATCH] Revert an accidential commit

14 years agotests: remove the no_trans mode from ctdb_transaction.
Michael Adam [Wed, 9 Dec 2009 21:04:48 +0000 (22:04 +0100)]
tests: remove the no_trans mode from ctdb_transaction.

Writes without transaction are not possible any more on
persistent databases.

Michael

14 years agotests: remove the persistent_unsafe writes test.
Michael Adam [Thu, 30 Jul 2009 09:59:59 +0000 (11:59 +0200)]
tests: remove the persistent_unsafe writes test.

This is useless now that persistent write operations without
transaction are forbidden.

Michael

14 years agotests: remove persistent_safe write test.
Michael Adam [Thu, 30 Jul 2009 09:59:02 +0000 (11:59 +0200)]
tests: remove persistent_safe write test.

This is useless now that persistent writes without transactions are forbidden.

Michael

14 years agotest: add test 54_ctdb_transaction_recovery.sh
Michael Adam [Wed, 9 Dec 2009 20:38:44 +0000 (21:38 +0100)]
test: add test 54_ctdb_transaction_recovery.sh

This is like the 53_ctdb_transaction test, but it additionally
runs a loop with recoveries while the transactions are running.

When called like this, the transaction loops run for 10 minutes:

CTDB_TEST_TIMELIMIT=600 tests/scripts/run_tests tests/simple/54_ctdb_transaction_recovery.sh

The default timelimit is 30 seconds.

Michael

14 years agotest: get value for --timelimit from environment var CTDB_TEST_TIMELIMIT in transacti...
Michael Adam [Wed, 9 Dec 2009 20:36:42 +0000 (21:36 +0100)]
test: get value for --timelimit from environment var CTDB_TEST_TIMELIMIT in transaction test

Michael

14 years agoclient: lower level of commit retry message WARNING->DEBUG
Michael Adam [Wed, 9 Dec 2009 14:05:20 +0000 (15:05 +0100)]
client: lower level of commit retry message WARNING->DEBUG

This can happen frequently when recoveries intercept transactions.

Michael

14 years agoclient: lower debug level of transaction-active-retry message to DEBUG
Michael Adam [Wed, 9 Dec 2009 12:48:49 +0000 (13:48 +0100)]
client: lower debug level of transaction-active-retry message to DEBUG

This reduces some noise.

Michael

14 years agocall: lower the debug message "refusing migration while transction" to lvl INFO
Michael Adam [Wed, 9 Dec 2009 12:43:38 +0000 (13:43 +0100)]
call: lower the debug message "refusing migration while transction" to lvl INFO

This gets just too noisy on a busy system.
And it is purley informational anyways...

Michael

14 years agoRun only one event for each epoll_wait/select call
Volker Lendecke [Wed, 9 Dec 2009 16:14:16 +0000 (17:14 +0100)]
Run only one event for each epoll_wait/select call

This might be a bit less efficient, but experience in winbind has shown that
event callbacks can trigger changes in the socket state in very hard to
diagnose ways.

14 years agoreduce vacuuming lognoise
Christian Ambach [Tue, 8 Dec 2009 18:23:19 +0000 (19:23 +0100)]
reduce vacuuming lognoise

syslog.h says:

LOG_NOTICE      5    normal but significant condition
LOG_INFO        6    informational

several vacuuming related logs logged at NOTICE level although I don't see
any real significance, these are just informational messages for me

Signed-off-by: Christian Ambach <christian.ambach@de.ibm.com>
14 years agoimprove time jump logging
Christian Ambach [Tue, 8 Dec 2009 18:08:37 +0000 (19:08 +0100)]
improve time jump logging

add the __location__ macro to the logs to get a better idea
in which loop the problem occured

Signed-off-by: Christian Ambach <christian.ambach@de.ibm.com>
14 years agoMerge commit 'rusty/script-report'
Ronnie Sahlberg [Wed, 9 Dec 2009 03:26:42 +0000 (14:26 +1100)]
Merge commit 'rusty/script-report'

14 years agoBond devices can have any name the user configures, so
Ronnie Sahlberg [Wed, 9 Dec 2009 00:33:04 +0000 (11:33 +1100)]
Bond devices can have any name the user configures, so
when checking link status for an interface, first
check if this interface is in fact a bond device
(by the precense of a /proc/net/bonding/IFACE file)
and use that file for checking status.

Othervise assume ib* is an infiniband interface which we donnt know how
to check, or otherwise it is an ethernet interface and ethtool should
hopefully work.

14 years agomake sure to also check that interfaces used for NATGW are ok
Ronnie Sahlberg [Wed, 9 Dec 2009 00:13:29 +0000 (11:13 +1100)]
make sure to also check that interfaces used for NATGW are ok
and have a link.
if not the node should become unhealthy

14 years agoevents/50.samba: only use wbinfo --ping-dc if available
Stefan Metzmacher [Mon, 7 Dec 2009 13:37:21 +0000 (14:37 +0100)]
events/50.samba: only use wbinfo --ping-dc if available

metze

14 years agoctdb: scriptstatus can now query non-monitor events
Rusty Russell [Mon, 7 Dec 2009 15:20:55 +0000 (01:50 +1030)]
ctdb: scriptstatus can now query non-monitor events

We also no longer return an error before scripts have been run; a special
zero-length data means we have never run the scripts.

"ctdb scriptstatus all" returns all event script results.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
14 years agoeventscript: expost call names and enum
Rusty Russell [Mon, 7 Dec 2009 15:17:13 +0000 (01:47 +1030)]
eventscript: expost call names and enum

We're going to need this so ctdb can query non-monitor status.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
14 years agoeventscript: lock logging on timeout.
Rusty Russell [Mon, 7 Dec 2009 15:02:36 +0000 (01:32 +1030)]
eventscript: lock logging on timeout.

Ronnie suggested this; seems like a very good idea.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
14 years agoctdb: support --machinereadable (-Y) for scriptstatus
Rusty Russell [Mon, 7 Dec 2009 15:01:53 +0000 (01:31 +1030)]
ctdb: support --machinereadable (-Y) for scriptstatus

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
14 years agoeventscript: get rid of ctdb_control_event_script_finished altogether
Rusty Russell [Tue, 8 Dec 2009 01:59:10 +0000 (12:29 +1030)]
eventscript: get rid of ctdb_control_event_script_finished altogether

We always have to call it before freeing the state; we should just do
this work in the destructor itself.

Unfortunately, the script state would already be freed by the time
the state destructor is called, so we make the script state a child of
ctdb, and talloc_free() it manually on the one path which doesn't use
the destructor.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
14 years agoeventscript: save state for all script invocations
Rusty Russell [Tue, 8 Dec 2009 01:57:48 +0000 (12:27 +1030)]
eventscript: save state for all script invocations

Rather than only tranferring to last_status for monitor events, do
it for every event (ctdb->last_status is now an array).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
14 years agoeventscript: cleanup finished to take state arg
Rusty Russell [Tue, 8 Dec 2009 01:54:56 +0000 (12:24 +1030)]
eventscript: cleanup finished to take state arg

We only need ctdb->current_monitor so we can kill it when we want to run
something else; we don't need to use it here as we always know what script
we are running.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
14 years agoeventscript: use wire format internally for script status.
Rusty Russell [Tue, 8 Dec 2009 02:18:17 +0000 (12:48 +1030)]
eventscript: use wire format internally for script status.

The only difference between the exposed an internal structure now is
that the name and output fields were pointers.  Switch to using
ctdb_scripts_wire/ctdb_script_wire internally as well so marshalling
is a noop.

We now reject scripts which are too long and truncate logging to the
511 characters we have space for (the entire output will be in the
normal ctdbd log).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
14 years agoeventscript: rename ctdb_monitoring_wire to ctdb_scripts_wire
Rusty Russell [Mon, 7 Dec 2009 14:21:24 +0000 (00:51 +1030)]
eventscript: rename ctdb_monitoring_wire to ctdb_scripts_wire

We're going to allow fetching status of all script runs, so this
name is no longer appropriate.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
14 years agoeventscript: get_current_script() helper
Rusty Russell [Tue, 8 Dec 2009 02:17:24 +0000 (12:47 +1030)]
eventscript: get_current_script() helper

This neatens the code slightly.  We also use the name 'current' in
ctdb_event_script_handler() for uniformity.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
14 years agoeventscript: use an array rather than a linked list of scripts
Rusty Russell [Tue, 8 Dec 2009 02:17:05 +0000 (12:47 +1030)]
eventscript: use an array rather than a linked list of scripts

This brings us closer to the wire format, by using a simple array
and a 'current' iterator.

The downside is that a 'struct ctdb_script' is no longer a talloc
object: the state must be passed to our log fn, and the current
script extracted with &state->scripts->scripts[state->current].

The wackiness of marshalling is simplified, and as a bonus, we can
distinguish between an empty event directory
(state->scripts->num_scripts == 0) and and error (state->scripts ==
NULL).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
14 years agoeventscript: record script status for all events
Rusty Russell [Tue, 8 Dec 2009 02:16:18 +0000 (12:46 +1030)]
eventscript: record script status for all events

This unifies almost everything: the state->current pointer points to
the struct ctdb_script where we record start, finish, status and
output.

We still only marshall up the monitor events; the rest disappear when
the state structure is freed.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
14 years agoeventscript: use scripts array directly, rather than separate list
Rusty Russell [Tue, 8 Dec 2009 02:15:17 +0000 (12:45 +1030)]
eventscript: use scripts array directly, rather than separate list

We rename ctdb_monitor_script_status to ctdb_script, and instead of
allocating them as the scripts are executed, we allocate them up front
and keep a "current" interator.

This slightly simplifies the code, though it means we only marshall up
to the last successfully run script.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
14 years agoeventscript: ctdb_fork_with_logging()
Rusty Russell [Tue, 8 Dec 2009 02:14:30 +0000 (12:44 +1030)]
eventscript: ctdb_fork_with_logging()

A new helper functions which sets up an event attached to the child's
stdout/stderr which gets routed to the logging callback after being
placed in the normal logs.

This is a generalization of the previous code which was hardcoded to
call ctdb_log_event_script_output.

The only subtlety is that we hang the child fds off the output buffer;
the destructor for that will flush, which means it has to be destroyed
before the output buffer is.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
14 years agoeventscript: pass struct ctdb_log_state directly to ctdb_log_handler().
Rusty Russell [Mon, 7 Dec 2009 14:01:29 +0000 (00:31 +1030)]
eventscript: pass struct ctdb_log_state directly to ctdb_log_handler().

The current logging logic assumes that any stdout/stderr belongs to
the currently running monitor script output.  This isn't quite right
anyway, and we'd like to capture stderr output of other script
invocations.

So we move towards multiple struct ctdb_log_state by handing it
directly to ctdb_log_handler to use, rather than having it assume
ctdb->log.  We need a ctdb pointer inside the log struct now though.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
14 years agoeventscript: remove unused ctbd_ctrl_event_script*
Rusty Russell [Mon, 7 Dec 2009 13:57:40 +0000 (00:27 +1030)]
eventscript: remove unused ctbd_ctrl_event_script*

The child no longer uses ctdb_ctrl_event_script_init or
ctdb_ctrl_event_script_finished, and the others are redundant: it
doesn't need to tell us it's starting a script when it only runs one.

We move start and stop calls to the parent, and eliminate the RPC
infrastructure altogether.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
14 years agoeventscript: refactor forking code into fork_child_for_script()
Rusty Russell [Mon, 7 Dec 2009 13:52:55 +0000 (00:22 +1030)]
eventscript: refactor forking code into fork_child_for_script()

We do the same thing in two places: fire off a child from the initial
ctdb_event_script_callback_v() and also from the ctdb_event_script_handler()
when it's done.

Unify this logic into fork_child_for_script().

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
14 years agoeventscript: fork() a child for each script.
Rusty Russell [Mon, 7 Dec 2009 13:51:25 +0000 (00:21 +1030)]
eventscript: fork() a child for each script.

We rename child_run_scripts() to child_run_script(), because it now
runs a single script rather than walking the list.  When it's
finished, we fork the next child from the ctdb_event_script_handler()
callback.

ctdb_control_event_script_init() and ctdb_control_event_script_finished()
are now called directly by the parent process; the child still calls
ctdb_ctrl_event_script_start() and ctdb_ctrl_event_script_stop() before
and after the script.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
14 years agoeventscript: store from_user and script_list inside state structure
Rusty Russell [Mon, 7 Dec 2009 13:45:18 +0000 (00:15 +1030)]
eventscript: store from_user and script_list inside state structure

This means all the state about running the scripts is in that structure,
which helps in the next patch.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
14 years agoeventscript: use direct script state pointer for current monitor
Rusty Russell [Mon, 7 Dec 2009 13:44:01 +0000 (00:14 +1030)]
eventscript: use direct script state pointer for current monitor

We put a "scripts" member in ctdb_event_script_state, rather than using
a special struct for monitor events.  This will fit better as we further
unify the different events, and holds the reports from the child process
running each monitor script.

Rather than making the monitor state a child of current_monitor_status_ctx,
we just point current_monitor directly at it.  This means we need to reset
that pointer in the destructor for ctdb_event_script_state.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
14 years agoeventscript: make current_monitor_status_ctx serve as monitor_event_script_ctx
Rusty Russell [Mon, 7 Dec 2009 13:39:20 +0000 (00:09 +1030)]
eventscript: make current_monitor_status_ctx serve as monitor_event_script_ctx

We have monitor_event_script_ctx and other_event_script_ctx, and
current_monitor_status_ctx in struct ctdb_context.  This seems more
complex than it needs to be.

We use a single "event_script_ctx" as parent for all event script
state structures.  Then we explicitly reparent monitor events under
current_monitor_status_ctx: this is freed every script invocation to
kill off any running scripts anyway.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
14 years agoeventscript: split ctdb_run_event_script into multiple parts
Rusty Russell [Mon, 7 Dec 2009 13:25:03 +0000 (23:55 +1030)]
eventscript: split ctdb_run_event_script into multiple parts

Simple refactoring in preparation for switching to one-child-per-script.
We also call the functions run by the child process "child_".

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
14 years agoeventscript: hoist work out of child process, into parent
Rusty Russell [Mon, 7 Dec 2009 13:23:35 +0000 (23:53 +1030)]
eventscript: hoist work out of child process, into parent

This is the start of a move towards finer-grained reporting, with one
child per script.  Simple code motion to do sanity check and get the
list of scripts before fork().

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
14 years agoeventscript: don't make ourselves healthy if we're under ban_count
Rusty Russell [Mon, 7 Dec 2009 13:22:01 +0000 (23:52 +1030)]
eventscript: don't make ourselves healthy if we're under ban_count

If we've timed out, but we've not timed out more than
ctdb->tunable.script_ban_count, we pretend we haven't.

There's a logic bug in the way this is done: if we were unhealthy before,
this would set us to "healthy" again (status == 0).  I don't think this
would happen in real life, but it's a little surprising.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
14 years agoeventscript: handle banning within the callbacks
Rusty Russell [Mon, 7 Dec 2009 13:18:57 +0000 (23:48 +1030)]
eventscript: handle banning within the callbacks

Currently the timeout handler in eventscript.c does the banning if a
timeout happens.  However, because monitor events are different, it has
to special case them.

As we call the callback anyway in this case, we should make that handle
-ETIME as it sees fit: for everyone but the monitor event, we simply ban
ourselves.  The more complicated monitor event banning logic is now in
ctdb_monitor.c where it belongs.

Note: I wrapped the other bans in "if (status == -ETIME)", though they
should probably ban themselves on any error.  This change should be a
noop.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
14 years agoeventscript: expost ctdb_ban_self()
Rusty Russell [Mon, 7 Dec 2009 12:48:40 +0000 (23:18 +1030)]
eventscript: expost ctdb_ban_self()

eventscript.c uses this now, but our next patch makes others use it.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
14 years agoeventscript: handle v. unlikely timeout race
Rusty Russell [Mon, 7 Dec 2009 12:47:23 +0000 (23:17 +1030)]
eventscript: handle v. unlikely timeout race

If we time out just as the child exits, we currently will report an
uninitialized cb_status field.  Set it to -ETIME as expected.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
14 years agoeventscript: replace other -1 returns with -errno
Rusty Russell [Mon, 7 Dec 2009 12:45:56 +0000 (23:15 +1030)]
eventscript: replace other -1 returns with -errno

This completes our "problem with script" reporting; we never set cb_status
to -1 on error.  Real errnos are used where the failure is a system call
(eg. read, setpgid), otherwise -EIO is used if we couldn't communicate with
the parent.

The latter case is a bit useless, since the parent probably won't see
the error anyway, but it's neater.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
14 years agoeventscript: simplify ctdb_run_event_script loop
Rusty Russell [Mon, 7 Dec 2009 12:43:12 +0000 (23:13 +1030)]
eventscript: simplify ctdb_run_event_script loop

If we break, we avoid cut & paste code inside the loop.  Need to initialize
ret to 0 for the "no scripts" case.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
14 years agoeventscript: handle and report generic stat/execution errors
Rusty Russell [Mon, 7 Dec 2009 12:42:19 +0000 (23:12 +1030)]
eventscript: handle and report generic stat/execution errors

Rather than ignoring deleted event scripts (or pretending that they were "OK"),
and discarding other stat errors, we save the errno and turn it into a negative
status.

This gives us a bit more information if we can't execute a script (eg.
too many symlinks or other weird errors).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
14 years agoeventscript: use -ENOEXEC for disabled status value
Rusty Russell [Mon, 7 Dec 2009 12:41:47 +0000 (23:11 +1030)]
eventscript: use -ENOEXEC for disabled status value

This unifies code paths and simplifies things: we just hand -ENOEXEC to
ctdb_ctrl_event_script_stop().

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
14 years agoeventscript: enhance script delete race check
Rusty Russell [Mon, 7 Dec 2009 12:39:02 +0000 (23:09 +1030)]
eventscript: enhance script delete race check

We currently assume 127 == script removed.  The script can also return 127;
best to re-check the execution status in this case (and for 126, which will
happen if the script is non-executable).

If the script is no longer executable/not present, we ignore it.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
14 years agoeventscript: check_executable() to centralize stat/perm checks
Rusty Russell [Mon, 7 Dec 2009 12:39:39 +0000 (23:09 +1030)]
eventscript: check_executable() to centralize stat/perm checks

This is used later in the "script vanished" check.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
14 years agotalloc: save errno over talloc_free
Rusty Russell [Mon, 7 Dec 2009 12:35:58 +0000 (23:05 +1030)]
talloc: save errno over talloc_free

As we start to use errno more, it's a huge pain if talloc_free() can blatt
it (esp. destructors).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
14 years agoeventscript: use -ETIME for timeout status value
Rusty Russell [Mon, 7 Dec 2009 12:39:42 +0000 (23:09 +1030)]
eventscript: use -ETIME for timeout status value

This starts the move toward more expressive encoding of return values:
positive values mean the script ran, negative means we had a problem with
the script (and the value is the errno).

This does timeout, but changes the ctdb tool to recognize it.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
14 years agoeventscript: marshall onto last_status immediately
Rusty Russell [Mon, 7 Dec 2009 12:39:40 +0000 (23:09 +1030)]
eventscript: marshall onto last_status immediately

This simplifies the code a little: last_status is now read to go
(it's only used by the scriptstatus command at the moment).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
14 years agoversion 1.0.108
Ronnie Sahlberg [Mon, 7 Dec 2009 08:04:41 +0000 (19:04 +1100)]
version 1.0.108

14 years agoUse wbinfo --ping-dc isntead of wbingo -p sicne this is a more reliable way to determ...
Ronnie Sahlberg [Mon, 7 Dec 2009 07:27:46 +0000 (18:27 +1100)]
Use wbinfo --ping-dc isntead of wbingo -p sicne this is a more reliable way to determine if winbindd is in a useful state.

14 years agopackaging: package tests/bin/ctdb_transaction under /usr/share/doc/tests/bin
Michael Adam [Fri, 4 Dec 2009 22:18:12 +0000 (23:18 +0100)]
packaging: package tests/bin/ctdb_transaction under /usr/share/doc/tests/bin

For testing/diagnostic purposes.

Michael

14 years agoclient: improve two error messages in ctdb_transaction_commit().
Michael Adam [Thu, 3 Dec 2009 23:19:44 +0000 (00:19 +0100)]
client: improve two error messages in ctdb_transaction_commit().

Michael

14 years agoserver:trans2_commit: move the check for active recovery down.
Michael Adam [Thu, 3 Dec 2009 23:06:34 +0000 (00:06 +0100)]
server:trans2_commit: move the check for active recovery down.

This needs to be done after the control-dispatcher:
In the TRANS2_COMMIT control, the client->db_id needs
to be set before bailing out, since otherwise the
next TRANS2_COMMIT_RETRY will fail...

Michael

14 years agoclient: increase the number of commit retries 10-->100
Michael Adam [Wed, 2 Dec 2009 23:28:32 +0000 (00:28 +0100)]
client: increase the number of commit retries 10-->100

To cope with timeouts when recoveries and transactions collide.
Maybe 100 is too high.

Michael

14 years agoclient: untangle checks and produce more detailed error messages
Michael Adam [Wed, 2 Dec 2009 23:27:34 +0000 (00:27 +0100)]
client: untangle checks and produce more detailed error messages

in ctdb_transaction_fetch_start

Michael

14 years agoclient: increase the rsn of the __transaction_lock__ when storing
Michael Adam [Wed, 2 Dec 2009 23:26:52 +0000 (00:26 +0100)]
client: increase the rsn of the __transaction_lock__ when storing

So that it is correctly handled by recoveries.
Also explicitly set the dmaster field to the current node's pnn.

Michael

14 years agorecovery: add special pull-logic for persistent databases
Michael Adam [Fri, 4 Dec 2009 10:21:29 +0000 (11:21 +0100)]
recovery: add special pull-logic for persistent databases

The decision mechanism which records of a persistent db
are to be pulled into the recdb during recovery is now
as follows:

* Usually a record with the higher rsn than that already
  stored is taken. (Just as for normal tdbs.)

* If a transaction is running on some node, then those
  nodes copies of all records are taken and are not
  overwritten later by other nodes' copies.

In order to keep track of whether a record's copy was obtained
from a node with a transaction running, the recovery mechanism
misuses the ctdb tdb header field 'lacount' in the recdb.
It is cleared later when pushing out the recdb database to the
other nodes.

This way, an incomplete transaction is not spoiled when
a recovery interrupts and the replay should usually succeed
(possibly after a few retries).

Michael

14 years agomake ctdb_ctrl_transaction_active public.
Michael Adam [Wed, 2 Dec 2009 23:25:16 +0000 (00:25 +0100)]
make ctdb_ctrl_transaction_active public.

Michael

14 years agorecovery: for persistent db's don't set the dmaster to the recmaster node number
Michael Adam [Sun, 29 Nov 2009 10:17:18 +0000 (11:17 +0100)]
recovery: for persistent db's don't set the dmaster to the recmaster node number

It is important to keep track of the dmaster (i.e. the node that last committed
a transaction containing changes to this node).

Michael

14 years agorecovery: pass the persistent flag to recover_database()
Michael Adam [Sun, 29 Nov 2009 10:14:31 +0000 (11:14 +0100)]
recovery: pass the persistent flag to recover_database()

and further down to pull_remote_database(), pull_one_remote_database(),
and push_recdb_database().

This is in preparation of special handling of persistent databases
during recoveries.

Michael

14 years agotests:ctdb_transaction: print an extra counters when a commit fails
Michael Adam [Sun, 29 Nov 2009 10:07:36 +0000 (11:07 +0100)]
tests:ctdb_transaction: print an extra counters when a commit fails

Michael

14 years agoclient: in catdb, print the keyname first, and separate records by a blank line
Michael Adam [Sun, 29 Nov 2009 09:38:33 +0000 (10:38 +0100)]
client: in catdb, print the keyname first, and separate records by a blank line

Michael

14 years agopackaging: remove the lib/popt from the tarball in debian mode
Michael Adam [Tue, 1 Dec 2009 22:54:12 +0000 (23:54 +0100)]
packaging: remove the lib/popt from the tarball in debian mode

Debian CTDB packaging fails when this is included.

Michael

14 years agopackaging: rework maketarball.sh to accept an arbitrary githas to pack
Michael Adam [Tue, 1 Dec 2009 22:51:51 +0000 (23:51 +0100)]
packaging: rework maketarball.sh to accept an arbitrary githas to pack

The githash can be specified through the environment variable "GITHASH"
that can contain a commit hash or a tag name, e.g.

The call syntax is now

[GITHASH=xyz] [USE_GITHASH=yes/no] [DEBIAN_MODE=yes/no] maketarball.sh

Michael

14 years agoctdb: add command "ctdb wipedb" to wipe the contents of an attached tdb
Michael Adam [Sun, 29 Nov 2009 03:05:03 +0000 (04:05 +0100)]
ctdb: add command "ctdb wipedb" to wipe the contents of an attached tdb

Michael

14 years agotests: turn printfs into DEBUG statements in the ctdb_transaction test
Michael Adam [Thu, 29 Oct 2009 21:40:50 +0000 (22:40 +0100)]
tests: turn printfs into DEBUG statements in the ctdb_transaction test

Michael

14 years agoMerge branch 'status-test-2'
Martin Schwenke [Fri, 4 Dec 2009 03:44:46 +0000 (14:44 +1100)]
Merge branch 'status-test-2'

14 years agoDont store debug level DEBUG_DEBUG in the in-memory ringbuffer.
Ronnie Sahlberg [Fri, 4 Dec 2009 00:45:37 +0000 (11:45 +1100)]
Dont store debug level DEBUG_DEBUG in the in-memory ringbuffer.

It is unlikely we will need something this verbose for normal troubleshooting.
This allows us to keep a significantly longer time interval of log messages
in the 500k slots available in the ringbuffer.

14 years agoUse statically allocated ringbuffer to store the last 500k log entries
Ronnie Sahlberg [Fri, 4 Dec 2009 00:36:27 +0000 (11:36 +1100)]
Use statically allocated ringbuffer to store the last 500k log entries
in memory instead of dynamically allocated ones so that we reduce the pressure
on malloc/free.

14 years agoDocument the procedure to remove/change the NATGW configuration at
Ronnie Sahlberg [Thu, 3 Dec 2009 21:33:56 +0000 (08:33 +1100)]
Document the procedure to remove/change the NATGW configuration at
runtime without restarting the ctdb service

14 years agoeventscript: reduce code duplication for ending a script, and fix bug
Rusty Russell [Wed, 2 Dec 2009 05:45:57 +0000 (16:15 +1030)]
eventscript: reduce code duplication for ending a script, and fix bug

Commit 50c2caed57c0 removed a gratuitous talloc_steal from the code in
ctdb_control_event_script_finished(), but not ctdb_event_script_timeout().

Easiest to call ctdb_control_event_script_finished() at the bottom of the
timeout routine.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
14 years agolower the loglevel for the message that a client has attached to a persistent database
Ronnie Sahlberg [Wed, 2 Dec 2009 03:53:21 +0000 (14:53 +1100)]
lower the loglevel for the message that a client has attached to a persistent database

14 years agolower the loglevel for the message that a client has attached through a domian socket
Ronnie Sahlberg [Wed, 2 Dec 2009 03:51:57 +0000 (14:51 +1100)]
lower the loglevel for the message that a client has attached through a domian socket

14 years agoAdd a proper function to process a process-exist control in the daemon.
Ronnie Sahlberg [Wed, 2 Dec 2009 02:58:27 +0000 (13:58 +1100)]
Add a proper function to process a process-exist control in the daemon.

This controls is only used by samba when samba wants to check if a subrecord held by a <node-id>:<smbd-pid> is still valid or if it can be reclaimed.

If the node is banned or stopped, we kill the smbd process and return that the process does not exist to the caller. This allows us to recover subrecords from stopped/banned nodes where smbd is hung waiting for the databases to thaw.

bz58185

14 years agoAdd a double linked list to the ctdb_context to store a mapping between client pids...
Ronnie Sahlberg [Wed, 2 Dec 2009 02:41:04 +0000 (13:41 +1100)]
Add a double linked list to the ctdb_context to store a mapping between client pids and client structures.

Add the mapping to the list everytime we accept() a new client connection
and set it up to remove in the destructor when the client structure is freed.

14 years agoUse the PID we pick up from the domain socket when a client connects
Ronnie Sahlberg [Wed, 2 Dec 2009 02:17:12 +0000 (13:17 +1100)]
Use the PID we pick up from the domain socket when a client connects
and store this in the client structure.

There is no need to rely on the hack that samba sends some special message
handle registrations that encodes the pid in the srvid any more.

This might not work on AIX since I recall some issues to get the pid in
this way on that platform.

14 years agoversion 1.0.107
Ronnie Sahlberg [Wed, 2 Dec 2009 00:28:42 +0000 (11:28 +1100)]
version 1.0.107

14 years agoctdb_io: fix use-after-free on invalid packets
Rusty Russell [Tue, 1 Dec 2009 22:27:42 +0000 (08:57 +1030)]
ctdb_io: fix use-after-free on invalid packets

Wolfgang saw a talloc complaint about using freed memory in ctdb_tcp_read_cb.
His fix was to remove the talloc_free() in that function, which causes
loops when a socket is closed (as it does not get removed from the event
system), eg:
netcat 192.168.1.2 4379 < /dev/null

The real bug is that when we have more than one pending packet in the
queue, we loop calling the callback without any safeguards should that
callback free the queue (as it tends to do on invalid packets).  This
can be reproduced by sending more than one bogus packet at once:
# Length word at start: 4 == empty packet (assumed little endian)
/usr/bin/printf \\4\\0\\0\\0\\4\\0\\0\\0 > /tmp/pkt
netcat 192.168.1.2 4379 < /tmp/pkt

Using a destructor we can check if the callback frees us, and exit
immediately.  Elsewhere, we return after the callback anyway.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
14 years agoversion 1.0.106
Ronnie Sahlberg [Wed, 2 Dec 2009 00:26:51 +0000 (11:26 +1100)]
version 1.0.106

14 years agoEventscripts: Fix syntax error in 00.ctdb.
Martin Schwenke [Tue, 1 Dec 2009 07:08:57 +0000 (18:08 +1100)]
Eventscripts: Fix syntax error in 00.ctdb.

Signed-off-by: Martin Schwenke <martin@meltin.net>
14 years agopackaging:maketarball.sh: add a DEBIAN_MODE to the tarball creation
Michael Adam [Thu, 26 Nov 2009 07:35:20 +0000 (08:35 +0100)]
packaging:maketarball.sh: add a DEBIAN_MODE to the tarball creation

It is triggered by setting DEBIAN_MODE=yes in the environment.
This creates a tarball suitable for use in debian packages.
The differences from the standard tarball are these:

* The tar ball file is called ctdb_VERSION.orig.tar.gz
* The base directory in the tar ball is ctdb-VERSION.orig/

Michael

14 years agoconfigure:maketarball.sh: call autogen.sh and include configure in the tarball
Michael Adam [Thu, 26 Nov 2009 07:34:44 +0000 (08:34 +0100)]
configure:maketarball.sh: call autogen.sh and include configure in the tarball

Michael

14 years agopackaging:maketarball.sh: create the specfile from the ctdb.spec.in
Michael Adam [Thu, 26 Nov 2009 07:32:24 +0000 (08:32 +0100)]
packaging:maketarball.sh: create the specfile from the ctdb.spec.in

Michael

14 years agoEventscripts: Remove executable bit accidently set on some scripts.
Martin Schwenke [Tue, 1 Dec 2009 06:54:45 +0000 (17:54 +1100)]
Eventscripts: Remove executable bit accidently set on some scripts.

Signed-off-by: Martin Schwenke <martin@meltin.net>
14 years agoEventscript argument cleanups and introduction of ctdb_standard_event_handler.
Martin Schwenke [Tue, 1 Dec 2009 06:43:47 +0000 (17:43 +1100)]
Eventscript argument cleanups and introduction of ctdb_standard_event_handler.

The functions file no longer causes a side-effect by doing a shift.
It also doesn't set a convenience variable for $1.

All eventscripts now explicitly use "$1" in their case statement, as
does the initscript.  The absence of a shift means that the
takeip/releaseip events now explicitly reference $2-$4 rather than
$1-$3.

New function ctdb_standard_event_handler handles the status and
setstatus events, and exits for either of those events.  It is called
via a default case in each eventscript, replacing an explicit status
case where applicable.

Signed-off-by: Martin Schwenke <martin@meltin.net>
14 years agowhen we detect a ip-allocation mismatch, just force a new ip reassignment
Ronnie Sahlberg [Tue, 1 Dec 2009 05:06:59 +0000 (16:06 +1100)]
when we detect a ip-allocation mismatch, just force a new ip reassignment
instead of a full blown recovery

14 years agoWhen starting up ctdbd, wait until all initial recoveries have finished
Ronnie Sahlberg [Tue, 1 Dec 2009 02:19:58 +0000 (13:19 +1100)]
When starting up ctdbd, wait until all initial recoveries have finished
and until we have gone through a full re-recovery timeout without triggering
any pending recoveries before we start up the services and start monitoring
the node.

14 years agoMerge commit 'martins/status-test-2'
Ronnie Sahlberg [Mon, 30 Nov 2009 23:53:18 +0000 (10:53 +1100)]
Merge commit 'martins/status-test-2'

Conflicts:

server/eventscript.c

14 years agoEvent scripts: functions file now intercepts status and setstatus.
Martin Schwenke [Fri, 27 Nov 2009 04:57:33 +0000 (15:57 +1100)]
Event scripts: functions file now intercepts status and setstatus.

Signed-off-by: Martin Schwenke <martin@meltin.net>
14 years agoremove a stray ) so we compile
Ronnie Sahlberg [Fri, 27 Nov 2009 02:35:39 +0000 (13:35 +1100)]
remove a stray )   so we compile

14 years agodont use talloc_steal() on a object that is already a child of ctdb.
Ronnie Sahlberg [Fri, 27 Nov 2009 02:28:31 +0000 (13:28 +1100)]
dont use talloc_steal() on a object that is already a child of ctdb.