summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2008-08-08 09:58:49 +1000
committerAndrew Tridgell <tridge@samba.org>2008-08-08 09:58:49 +1000
commit5a0249d34cbca77b6ce0ea7e1b8fdc91d336ec2f (patch)
tree0956e8d39a13efe2c6abed01b790aeadad4fa401
parent66d154ef5f4379e0ac250639993e027f1123a2ad (diff)
downloadsamba-5a0249d34cbca77b6ce0ea7e1b8fdc91d336ec2f.tar.gz
samba-5a0249d34cbca77b6ce0ea7e1b8fdc91d336ec2f.tar.xz
samba-5a0249d34cbca77b6ce0ea7e1b8fdc91d336ec2f.zip
return a more detailed error code from a trans2 commit error
(This used to be ctdb commit 6915661a460cd589b441ac7cd8695f35c4e83113)
-rw-r--r--ctdb/include/ctdb_private.h10
-rw-r--r--ctdb/server/ctdb_persistent.c23
2 files changed, 31 insertions, 2 deletions
diff --git a/ctdb/include/ctdb_private.h b/ctdb/include/ctdb_private.h
index ff4d271794..6cc1dc9f9c 100644
--- a/ctdb/include/ctdb_private.h
+++ b/ctdb/include/ctdb_private.h
@@ -789,6 +789,16 @@ struct ctdb_req_keepalive {
struct ctdb_req_header hdr;
};
+
+/* types of failures possible from TRANS2_COMMIT */
+enum ctdb_trans2_commit_error {
+ CTDB_TRANS2_COMMIT_SUCCESS=0, /* all nodes committed successfully */
+ CTDB_TRANS2_COMMIT_TIMEOUT=1, /* at least one node timed out */
+ CTDB_TRANS2_COMMIT_ALLFAIL=2, /* all nodes failed the commit */
+ CTDB_TRANS2_COMMIT_SOMEFAIL=3 /* some nodes failed the commit, some allowed it */
+};
+
+
/* internal prototypes */
void ctdb_set_error(struct ctdb_context *ctdb, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3);
void ctdb_fatal(struct ctdb_context *ctdb, const char *msg);
diff --git a/ctdb/server/ctdb_persistent.c b/ctdb/server/ctdb_persistent.c
index 5b88b4bbed..faa6e83029 100644
--- a/ctdb/server/ctdb_persistent.c
+++ b/ctdb/server/ctdb_persistent.c
@@ -32,9 +32,17 @@ struct ctdb_persistent_state {
const char *errormsg;
uint32_t num_pending;
int32_t status;
+ uint32_t num_failed, num_sent;
};
/*
+ 1) all nodes fail, and all nodes reply
+ 2) some nodes fail, all nodes reply
+ 3) some nodes timeout
+ 4) all nodes succeed
+ */
+
+/*
called when a node has acknowledged a ctdb_control_update_record call
*/
static void ctdb_persistent_callback(struct ctdb_context *ctdb,
@@ -50,10 +58,19 @@ static void ctdb_persistent_callback(struct ctdb_context *ctdb,
status, errormsg));
state->status = status;
state->errormsg = errormsg;
+ state->num_failed++;
}
state->num_pending--;
if (state->num_pending == 0) {
- ctdb_request_control_reply(state->ctdb, state->c, NULL, state->status, state->errormsg);
+ enum ctdb_trans2_commit_error etype;
+ if (state->num_failed == state->num_sent) {
+ etype = CTDB_TRANS2_COMMIT_ALLFAIL;
+ } else if (state->num_failed != 0) {
+ etype = CTDB_TRANS2_COMMIT_SOMEFAIL;
+ } else {
+ etype = CTDB_TRANS2_COMMIT_SUCCESS;
+ }
+ ctdb_request_control_reply(state->ctdb, state->c, NULL, etype, state->errormsg);
talloc_free(state);
}
}
@@ -66,7 +83,8 @@ static void ctdb_persistent_store_timeout(struct event_context *ev, struct timed
{
struct ctdb_persistent_state *state = talloc_get_type(private_data, struct ctdb_persistent_state);
- ctdb_request_control_reply(state->ctdb, state->c, NULL, -1, "timeout in ctdb_persistent_state");
+ ctdb_request_control_reply(state->ctdb, state->c, NULL, CTDB_TRANS2_COMMIT_TIMEOUT,
+ "timeout in ctdb_persistent_state");
talloc_free(state);
}
@@ -141,6 +159,7 @@ int32_t ctdb_control_trans2_commit(struct ctdb_context *ctdb,
}
state->num_pending++;
+ state->num_sent++;
}
if (state->num_pending == 0) {