summaryrefslogtreecommitdiffstats
path: root/ctdb/client
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2008-08-08 11:04:21 +1000
committerAndrew Tridgell <tridge@samba.org>2008-08-08 11:04:21 +1000
commitf2fd0d8b59118f856d067b6c48c01c33eb0c447f (patch)
tree397611c811ac618a88d10ed4ff38d90d02d0c873 /ctdb/client
parentdfdb41350b804eb9284d3cfe939c6f29e2734d9c (diff)
downloadsamba-f2fd0d8b59118f856d067b6c48c01c33eb0c447f.tar.gz
samba-f2fd0d8b59118f856d067b6c48c01c33eb0c447f.tar.xz
samba-f2fd0d8b59118f856d067b6c48c01c33eb0c447f.zip
imported failure handling from dbwrap_ctdb.c
(This used to be ctdb commit 7c6b621f7307dc39ffcd7d965ac613642af201b8)
Diffstat (limited to 'ctdb/client')
-rw-r--r--ctdb/client/ctdb_client.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/ctdb/client/ctdb_client.c b/ctdb/client/ctdb_client.c
index 6e1a209a7c2..c0875b0368c 100644
--- a/ctdb/client/ctdb_client.c
+++ b/ctdb/client/ctdb_client.c
@@ -3185,6 +3185,7 @@ int ctdb_transaction_commit(struct ctdb_transaction_handle *h)
int32_t status;
struct ctdb_context *ctdb = h->ctdb_db->ctdb;
struct timeval timeout;
+ enum ctdb_controls failure_control = CTDB_CONTROL_TRANS2_ERROR;
talloc_set_destructor(h, NULL);
@@ -3220,15 +3221,35 @@ again:
if (ret != 0 || status != 0) {
tdb_transaction_cancel(h->ctdb_db->ltdb->tdb);
sleep(1);
+
+ if (ret != 0) {
+ failure_control = CTDB_CONTROL_TRANS2_ERROR;
+ } else {
+ /* work out what error code we will give if we
+ have to fail the operation */
+ switch ((enum ctdb_trans2_commit_error)status) {
+ case CTDB_TRANS2_COMMIT_SUCCESS:
+ case CTDB_TRANS2_COMMIT_SOMEFAIL:
+ case CTDB_TRANS2_COMMIT_TIMEOUT:
+ failure_control = CTDB_CONTROL_TRANS2_ERROR;
+ break;
+ case CTDB_TRANS2_COMMIT_ALLFAIL:
+ failure_control = CTDB_CONTROL_TRANS2_FINISHED;
+ break;
+ }
+ }
+
if (ctdb_replay_transaction(h) != 0) {
DEBUG(DEBUG_ERR,(__location__ " Failed to replay transaction\n"));
ctdb_control(ctdb, CTDB_CURRENT_NODE, h->ctdb_db->db_id,
- CTDB_CONTROL_TRANS2_ERROR, CTDB_CTRL_FLAG_NOREPLY,
+ failure_control, CTDB_CTRL_FLAG_NOREPLY,
tdb_null, NULL, NULL, NULL, NULL, NULL);
talloc_free(h);
return -1;
}
goto again;
+ } else {
+ failure_control = CTDB_CONTROL_TRANS2_ERROR;
}
/* do the real commit locally */
@@ -3236,7 +3257,7 @@ again:
if (ret != 0) {
DEBUG(DEBUG_ERR,(__location__ " Failed to commit transaction\n"));
ctdb_control(ctdb, CTDB_CURRENT_NODE, h->ctdb_db->db_id,
- CTDB_CONTROL_TRANS2_ERROR, CTDB_CTRL_FLAG_NOREPLY,
+ failure_control, CTDB_CTRL_FLAG_NOREPLY,
tdb_null, NULL, NULL, NULL, NULL, NULL);
talloc_free(h);
return ret;