The branch, master has been updated
       via  a5d90d8ed8b44355c4ffb9c32ded772025fcc174 (commit)
       via  825c506da76d7afd0714b75b8c8727874183a618 (commit)
       via  b95524c08bf12914120cb6c818ecc1c99738fe37 (commit)
       via  9e4902c7d3ad1329c296f4196fcb1396f2a7a6a0 (commit)
      from  c1d8496f9fd5e8046f3d990264258dfb054f3b32 (commit)

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


- Log -----------------------------------------------------------------
commit a5d90d8ed8b44355c4ffb9c32ded772025fcc174
Author: Michael Adam <[email protected]>
Date:   Thu Oct 29 22:53:44 2009 +0100

    client: randomize the transaction_start retry loop:
    
    instead of sleeping 1 second, sleep between 1 and 100 milliseconds
    
    Michael

commit 825c506da76d7afd0714b75b8c8727874183a618
Author: Michael Adam <[email protected]>
Date:   Thu Oct 29 22:40:00 2009 +0100

    Revert "dont exit on a commit failure"
    
    This reverts commit 4e9a3a5dc232bac12ab387ea0cf4f1b279bed5c1.
    
    Transaction commit should not be allowed to fail.
    This is a real error.
    
    Michael

commit b95524c08bf12914120cb6c818ecc1c99738fe37
Author: Michael Adam <[email protected]>
Date:   Thu Oct 29 22:20:38 2009 +0100

    client: fix a race in the local race condition fix in transaction_start
    
    The gap that remained is between checking whether a transaction commit
    is in progress and taking the lock. Now we first take the lock and then
    check whether a transaction commit is in progress. If so, we release the
    lock, wait for one second and retry.
    
    Michael

commit 9e4902c7d3ad1329c296f4196fcb1396f2a7a6a0
Author: Michael Adam <[email protected]>
Date:   Thu Oct 29 22:19:19 2009 +0100

    client: add a debug message when a transaction_commit needs to be retried
    
    Michael

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

Summary of changes:
 client/ctdb_client.c         |   29 ++++++++++++++++++-----------
 tests/src/ctdb_transaction.c |    2 +-
 2 files changed, 19 insertions(+), 12 deletions(-)


Changeset truncated at 500 lines:

diff --git a/client/ctdb_client.c b/client/ctdb_client.c
index 8faa5dd..3e6b833 100644
--- a/client/ctdb_client.c
+++ b/client/ctdb_client.c
@@ -3213,25 +3213,29 @@ static int ctdb_transaction_fetch_start(struct 
ctdb_transaction_handle *h)
        }
 
 again:
+       tmp_ctx = talloc_new(h);
+
+       rh = ctdb_fetch_lock(ctdb_db, tmp_ctx, key, NULL);
+       if (rh == NULL) {
+               DEBUG(DEBUG_ERR,(__location__ " Failed to fetch_lock 
database\n"));
+               talloc_free(tmp_ctx);
+               return -1;
+       }
+
        status = ctdb_ctrl_transaction_active(ctdb_db->ctdb,
                                              CTDB_CURRENT_NODE,
                                              ctdb_db->db_id);
        if (status == 1) {
+               unsigned long int usec = (1000 + random()) % 100000;
                DEBUG(DEBUG_NOTICE, (__location__ " transaction is active "
-                                    "on db_id[0x%08x]. waiting for 1 second\n",
-                                    ctdb_db->db_id));
-               sleep(1);
+                                    "on db_id[0x%08x]. waiting for %lu "
+                                    "microseconds\n",
+                                    ctdb_db->db_id, usec));
+               talloc_free(tmp_ctx);
+               usleep(usec);
                goto again;
        }
 
-       tmp_ctx = talloc_new(h);
-
-       rh = ctdb_fetch_lock(ctdb_db, tmp_ctx, key, NULL);
-       if (rh == NULL) {
-               DEBUG(DEBUG_ERR,(__location__ " Failed to fetch_lock 
database\n"));             
-               talloc_free(tmp_ctx);
-               return -1;
-       }
        /*
         * store the pid in the database:
         * it is not enough that the node is dmaster...
@@ -3497,6 +3501,9 @@ again:
                           &timeout, NULL);
        if (ret != 0 || status != 0) {
                tdb_transaction_cancel(h->ctdb_db->ltdb->tdb);
+               DEBUG(DEBUG_WARNING, (__location__ " transaction commit%s 
failed"
+                                     ", retrying after 1 second...\n",
+                                     (retries==0)?"":"retry "));
                sleep(1);
 
                if (ret != 0) {
diff --git a/tests/src/ctdb_transaction.c b/tests/src/ctdb_transaction.c
index fdd2e89..c747e1a 100644
--- a/tests/src/ctdb_transaction.c
+++ b/tests/src/ctdb_transaction.c
@@ -197,7 +197,7 @@ static void test_store_records(struct ctdb_context *ctdb, 
struct event_context *
                        ret = ctdb_transaction_commit(h);
                        if (ret != 0) {
                                DEBUG(DEBUG_ERR,("Failed to commit 
transaction\n"));
-                               //exit(1);
+                               exit(1);
                        }
                        if (verbose) printf("transaction committed\n");
                } else {


-- 
CTDB repository

Reply via email to