put a limit on the number of retries. I found a case where a recovery
authorAndrew Tridgell <tridge@samba.org>
Thu, 7 Aug 2008 13:26:22 +0000 (23:26 +1000)
committerMichael Adam <obnox@samba.org>
Wed, 13 Aug 2008 09:54:09 +0000 (11:54 +0200)
could lead to it blocking forever
(This used to be commit a633390d3a7cb04a7c4e14cba9c533621793287e)

source3/lib/dbwrap_ctdb.c

index 16c626632de530be76a841528cef216ade91b6be..645b93846babb426e8639b638aaa4d20b86d3994 100644 (file)
@@ -597,6 +597,7 @@ static int db_ctdb_transaction_commit(struct db_context *db)
        NTSTATUS rets;
        int ret;
        int status;
        NTSTATUS rets;
        int ret;
        int status;
+       int retries = 0;
        struct db_ctdb_transaction_handle *h = ctx->transaction;
 
        if (h == NULL) {
        struct db_ctdb_transaction_handle *h = ctx->transaction;
 
        if (h == NULL) {
@@ -648,6 +649,17 @@ again:
                        ctx->transaction = NULL;
                        return -1;
                }
                        ctx->transaction = NULL;
                        return -1;
                }
+               if (retries++ == 10) {
+                       DEBUG(0,(__location__ " Giving up transaction on db 0x%08x after %d retries\n", 
+                                h->ctx->db_id, retries));
+                       ctdbd_control_local(messaging_ctdbd_connection(), CTDB_CONTROL_TRANS2_ERROR,
+                                           h->ctx->db_id, CTDB_CTRL_FLAG_NOREPLY, 
+                                           tdb_null, NULL, NULL, NULL);
+                       h->ctx->transaction = NULL;
+                       talloc_free(h);
+                       ctx->transaction = NULL;
+                       return -1;                      
+               }
                goto again;
        }
 
                goto again;
        }