The branch, master has been updated
       via  b3b9707dd8244758ff1080401a9e03e74766e1ab (commit)
       via  7f29c50ccbc7789bfbc20bcb4b65758af9ebe6c5 (commit)
      from  7c6b621f7307dc39ffcd7d965ac613642af201b8 (commit)

http://gitweb.samba.org/?p=tridge/ctdb.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit b3b9707dd8244758ff1080401a9e03e74766e1ab
Author: Andrew Tridgell <[EMAIL PROTECTED]>
Date:   Fri Aug 8 13:11:41 2008 +1000

    added retry handling in client

commit 7f29c50ccbc7789bfbc20bcb4b65758af9ebe6c5
Author: Andrew Tridgell <[EMAIL PROTECTED]>
Date:   Fri Aug 8 13:11:28 2008 +1000

    added a new control CTDB_CONTROL_TRANS2_COMMIT_RETRY so we can tell
    the difference between a initial commit attempt and a retry, which
    allows us to get the persistent updates counter right for retries

-----------------------------------------------------------------------

Summary of changes:
 client/ctdb_client.c     |   14 ++++++++++++--
 include/ctdb_private.h   |    1 +
 server/ctdb_control.c    |    1 +
 server/ctdb_persistent.c |   12 +++++++++---
 4 files changed, 23 insertions(+), 5 deletions(-)


Changeset truncated at 500 lines:

diff --git a/client/ctdb_client.c b/client/ctdb_client.c
index c0875b0..0d85374 100644
--- a/client/ctdb_client.c
+++ b/client/ctdb_client.c
@@ -3181,7 +3181,7 @@ failed:
  */
 int ctdb_transaction_commit(struct ctdb_transaction_handle *h)
 {
-       int ret;
+       int ret, retries=0;
        int32_t status;
        struct ctdb_context *ctdb = h->ctdb_db->ctdb;
        struct timeval timeout;
@@ -3215,7 +3215,7 @@ again:
        /* tell ctdbd to commit to the other nodes */
        timeout = timeval_current_ofs(1, 0);
        ret = ctdb_control(ctdb, CTDB_CURRENT_NODE, h->ctdb_db->db_id, 
-                          CTDB_CONTROL_TRANS2_COMMIT, 0, 
+                          
retries==0?CTDB_CONTROL_TRANS2_COMMIT:CTDB_CONTROL_TRANS2_COMMIT_RETRY, 0, 
                           ctdb_marshall_finish(h->m_write), NULL, NULL, 
&status, 
                           &timeout, NULL);
        if (ret != 0 || status != 0) {
@@ -3239,6 +3239,16 @@ again:
                        }
                }
 
+               if (++retries == 10) {
+                       DEBUG(DEBUG_ERR,(__location__ " Giving up transaction 
on db 0x%08x after %d retries failure_control=%u\n", 
+                                        h->ctdb_db->db_id, retries, 
(unsigned)failure_control));
+                       ctdb_control(ctdb, CTDB_CURRENT_NODE, 
h->ctdb_db->db_id, 
+                                    failure_control, CTDB_CTRL_FLAG_NOREPLY, 
+                                    tdb_null, NULL, NULL, NULL, NULL, NULL);   
        
+                       talloc_free(h);
+                       return -1;
+               }               
+
                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, 
diff --git a/include/ctdb_private.h b/include/ctdb_private.h
index 6cc1dc9..f44a940 100644
--- a/include/ctdb_private.h
+++ b/include/ctdb_private.h
@@ -549,6 +549,7 @@ enum ctdb_controls {CTDB_CONTROL_PROCESS_EXISTS          = 
0,
                    CTDB_CONTROL_TRANS2_COMMIT           = 83,
                    CTDB_CONTROL_TRANS2_FINISHED         = 84,
                    CTDB_CONTROL_TRANS2_ERROR            = 85,
+                   CTDB_CONTROL_TRANS2_COMMIT_RETRY     = 86,
 };     
 
 /*
diff --git a/server/ctdb_control.c b/server/ctdb_control.c
index 59b0657..edfe344 100644
--- a/server/ctdb_control.c
+++ b/server/ctdb_control.c
@@ -397,6 +397,7 @@ static int32_t ctdb_control_dispatch(struct ctdb_context 
*ctdb,
                return ctdb_control_cancel_persistent_update(ctdb, c, indata);
 
        case CTDB_CONTROL_TRANS2_COMMIT:
+       case CTDB_CONTROL_TRANS2_COMMIT_RETRY:
                return ctdb_control_trans2_commit(ctdb, c, indata, async_reply);
 
        case CTDB_CONTROL_TRANS2_ERROR:
diff --git a/server/ctdb_persistent.c b/server/ctdb_persistent.c
index faa6e83..42b148c 100644
--- a/server/ctdb_persistent.c
+++ b/server/ctdb_persistent.c
@@ -121,12 +121,18 @@ int32_t ctdb_control_trans2_commit(struct ctdb_context 
*ctdb,
                then have it decremented in ctdb_control_trans2_error
                or ctdb_control_trans2_finished
        */
-       if (c->opcode == CTDB_CONTROL_PERSISTENT_STORE) {
+       switch (c->opcode) {
+       case CTDB_CONTROL_PERSISTENT_STORE:
                if (client->num_persistent_updates > 0) {
                        client->num_persistent_updates--;
-               }               
-       } else {
+               }
+               break;
+       case CTDB_CONTROL_TRANS2_COMMIT:
                client->num_persistent_updates++;
+               break;
+       case CTDB_CONTROL_TRANS2_COMMIT_RETRY:
+               /* already updated from the first commit */
+               break;
        }
 
        state = talloc_zero(ctdb, struct ctdb_persistent_state);


-- 
CTDB repository

Reply via email to