[SCM] CTDB repository - branch master updated -
ctdb-1.0.68-9-g7ee6db0
Ronnie Sahlberg
sahlberg at samba.org
Wed Dec 17 02:36:07 GMT 2008
The branch, master has been updated
via 7ee6db06162ad5a554058bb6160ad37b24fe42e0 (commit)
via fc4e8b5a5d3699221620a8d76701c8589f2b4ff1 (commit)
from 023d6c2e3017d323b5a70f987f3b4e0b8b8f0f7b (commit)
http://gitweb.samba.org/?p=sahlberg/ctdb.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 7ee6db06162ad5a554058bb6160ad37b24fe42e0
Author: root <root at test1n1.VSOFS1.COM>
Date: Wed Dec 17 14:26:01 2008 +1100
add better errorchecking that nodes we try to talk to using the "ctdb" tool actually exist and that it is connected.
two new dedicated ctdb error codes
21: node does not exist
22: node is disconnected
commit fc4e8b5a5d3699221620a8d76701c8589f2b4ff1
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date: Wed Dec 17 12:01:40 2008 +1100
dont call ctdb_fatal() just because we are asked to restart a connection
to a remote node and ctdb->methods is NULL.
This can happen when we are in the middle of a normal shutdown of the
daemon and we have already shut down the transport layer (thus setting
ctdb->methods == NULL in the transport layer destructor)
band there is some unprocessed data related to a remote node.
This prevents an ugly race condition where ctdb might sometimes (rare)
cause a core dump during "ctdb shutdown".
-----------------------------------------------------------------------
Summary of changes:
server/ctdb_server.c | 4 +-
tools/ctdb.c | 71 +++++++++++++++++++++++++++++++------------------
2 files changed, 47 insertions(+), 28 deletions(-)
Changeset truncated at 500 lines:
diff --git a/server/ctdb_server.c b/server/ctdb_server.c
index b41101d..d9a3234 100644
--- a/server/ctdb_server.c
+++ b/server/ctdb_server.c
@@ -359,8 +359,8 @@ void ctdb_node_dead(struct ctdb_node *node)
ctdb_daemon_cancel_controls(node->ctdb, node);
if (node->ctdb->methods == NULL) {
- DEBUG(DEBUG_ALERT,(__location__ " Can not restart transport. ctdb->methods==NULL\n"));
- ctdb_fatal(node->ctdb, "can not restart transport.");
+ DEBUG(DEBUG_ERR,(__location__ " Can not restart transport while shutting down daemon.\n"));
+ return;
}
node->ctdb->methods->restart(node);
diff --git a/tools/ctdb.c b/tools/ctdb.c
index 458331f..4ba351c 100644
--- a/tools/ctdb.c
+++ b/tools/ctdb.c
@@ -31,7 +31,10 @@
#include "../common/rb_tree.h"
#include "db_wrap.h"
-#define ERR_TIMEOUT 20
+
+#define ERR_TIMEOUT 20 /* timed out trying to reach node */
+#define ERR_NONODE 21 /* node does not exist */
+#define ERR_DISNODE 22 /* node is disconnected */
static void usage(void);
@@ -56,6 +59,43 @@ static int control_version(struct ctdb_context *ctdb, int argc, const char **arg
/*
+ verify that a node exists and is reachable
+ */
+static void verify_node(struct ctdb_context *ctdb)
+{
+ int ret;
+ struct ctdb_node_map *nodemap=NULL;
+
+ if (options.pnn == CTDB_CURRENT_NODE) {
+ return;
+ }
+ if (options.pnn == CTDB_BROADCAST_ALL) {
+ return;
+ }
+
+ /* verify the node exists */
+ if (ctdb_ctrl_getnodemap(ctdb, TIMELIMIT(), CTDB_CURRENT_NODE, ctdb, &nodemap) != 0) {
+ DEBUG(DEBUG_ERR, ("Unable to get nodemap from local node\n"));
+ exit(10);
+ }
+ if (options.pnn >= nodemap->num) {
+ DEBUG(DEBUG_ERR, ("Node %u does not exist\n", options.pnn));
+ exit(ERR_NONODE);
+ }
+ if (nodemap->nodes[options.pnn].flags & NODE_FLAGS_DISCONNECTED) {
+ DEBUG(DEBUG_ERR, ("Node %u is DISCONNECTED\n", options.pnn));
+ exit(ERR_DISNODE);
+ }
+
+ /* verify we can access the node */
+ ret = ctdb_ctrl_getpnn(ctdb, TIMELIMIT(), options.pnn);
+ if (ret == -1) {
+ DEBUG(DEBUG_ERR,("Can not ban node. Node is not operational.\n"));
+ exit(10);
+ }
+}
+
+/*
check if a database exists
*/
static int db_exists(struct ctdb_context *ctdb, const char *db_name)
@@ -262,15 +302,9 @@ static int control_statistics_reset(struct ctdb_context *ctdb, int argc, const c
static int control_uptime(struct ctdb_context *ctdb, int argc, const char **argv)
{
int ret;
- int mypnn;
struct ctdb_uptime *uptime = NULL;
int tmp, days, hours, minutes, seconds;
- mypnn = ctdb_ctrl_getpnn(ctdb, TIMELIMIT(), options.pnn);
- if (mypnn == -1) {
- return -1;
- }
-
ret = ctdb_ctrl_uptime(ctdb, ctdb, TIMELIMIT(), options.pnn, &uptime);
if (ret != 0) {
DEBUG(DEBUG_ERR, ("Unable to get uptime from node %u\n", options.pnn));
@@ -325,7 +359,7 @@ static int control_pnn(struct ctdb_context *ctdb, int argc, const char **argv)
{
int mypnn;
- mypnn = ctdb_ctrl_getpnn(ctdb, TIMELIMIT(), CTDB_CURRENT_NODE);
+ mypnn = ctdb_ctrl_getpnn(ctdb, TIMELIMIT(), options.pnn);
if (mypnn == -1) {
DEBUG(DEBUG_ERR, ("Unable to get pnn from local node."));
return -1;
@@ -1326,17 +1360,6 @@ static int control_ban(struct ctdb_context *ctdb, int argc, const char **argv)
DEBUG(DEBUG_ERR, ("Unable to get nodemap from local node\n"));
return ret;
}
- if (options.pnn >= nodemap->num) {
- DEBUG(DEBUG_ERR, ("Node %u does not exist\n", options.pnn));
- return ret;
- }
-
- /* verify we can access the node */
- ret = ctdb_ctrl_getpnn(ctdb, TIMELIMIT(), options.pnn);
- if (ret == -1) {
- DEBUG(DEBUG_ERR,("Can not ban node. Node is not operational.\n"));
- return -1;
- }
if (nodemap->nodes[options.pnn].flags & NODE_FLAGS_BANNED) {
DEBUG(DEBUG_ERR,("Node %u is already banned.\n", options.pnn));
@@ -1382,13 +1405,6 @@ static int control_unban(struct ctdb_context *ctdb, int argc, const char **argv)
/* record the current generation number */
generation = get_generation(ctdb);
- /* verify we can access the node */
- ret = ctdb_ctrl_getpnn(ctdb, TIMELIMIT(), options.pnn);
- if (ret == -1) {
- DEBUG(DEBUG_ERR,("Can not unban node. Node is not operational.\n"));
- return -1;
- }
-
data.dptr = (uint8_t *)&options.pnn;
data.dsize = sizeof(uint32_t);
@@ -2747,6 +2763,9 @@ int main(int argc, const char *argv[])
exit(1);
}
+ /* verify the node exists */
+ verify_node(ctdb);
+
for (i=0;i<ARRAY_SIZE(ctdb_commands);i++) {
if (strcmp(control, ctdb_commands[i].name) == 0) {
int j;
--
CTDB repository
More information about the samba-cvs
mailing list