[SCM] CTDB repository - branch master updated - ctdb-1.0.82-25-g3e49e41

Ronnie Sahlberg sahlberg at samba.org
Mon May 25 06:57:08 GMT 2009


The branch, master has been updated
       via  3e49e41c21eb8c53084aa8cc7fd3557bdd8eb7b6 (commit)
       via  87292029cb444ffab130ff7dae47a629c2d15787 (commit)
       via  9762a3408f10409b629637d237ec513a825a6059 (commit)
       via  f1c6f7dd47bb1081781c0a0d567a92bbbc0aa5d5 (commit)
      from  dca41ec04788922ce5f4c52d346872b3e35f8cbb (commit)

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


- Log -----------------------------------------------------------------
commit 3e49e41c21eb8c53084aa8cc7fd3557bdd8eb7b6
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Mon May 25 17:04:42 2009 +1000

    New attempt at TDB transaction nesting allow/disallow.
    
    Make the default be that transaction is not allowed and any attempt to create a nested transaction will fail with TDB_ERR_NESTING.
    
    If an application can cope with transaction nesting and the implicit
    semantics of tdb_transaction_commit(), it can enable transaction nesting
    by using the TDB_ALLOW_NESTING flag.

commit 87292029cb444ffab130ff7dae47a629c2d15787
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Mon May 25 16:55:27 2009 +1000

    Revert "we only need to have transaction nesting disabled when we start the new transaction for the recovery"
    
    This reverts commit bf8dae63d10498e6b6179bbacdd72f1ff0fc60be.

commit 9762a3408f10409b629637d237ec513a825a6059
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Mon May 25 16:55:02 2009 +1000

    Revert "set the TDB_NO_NESTING flag for the tdb before we start a transaction from within recovery"
    
    This reverts commit 1b2029dbb055ff07367ebc1f307f5241320227b2.

commit f1c6f7dd47bb1081781c0a0d567a92bbbc0aa5d5
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Mon May 25 16:54:25 2009 +1000

    Revert "add TDB_NO_NESTING. When this flag is set tdb will not allow any nested transactions and tdb_transaction_start() will implicitely _cancel() any pending transactions before starting any new ones."
    
    This reverts commit 459e4ee135bd1cd24c15e5325906eb4ecfd550ec.

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

Summary of changes:
 lib/tdb/common/transaction.c |   25 +++++++++++++------------
 lib/tdb/include/tdb.h        |    5 +++--
 server/ctdb_freeze.c         |    2 --
 3 files changed, 16 insertions(+), 16 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/tdb/common/transaction.c b/lib/tdb/common/transaction.c
index 6a34c45..98e8eff 100644
--- a/lib/tdb/common/transaction.c
+++ b/lib/tdb/common/transaction.c
@@ -85,11 +85,13 @@
     still available, but no transaction recovery area is used and no
     fsync/msync calls are made.
 
-  - if TDB_NO_NESTING is passed to flags in tdb open then transaction
-    nesting is disabled. tdb_transaction_start() will then implicitely
-    cancel any pending transactions and always start a new transaction
-    context instead of nesting.
+  - if TDB_ALLOW_NESTING is passed to flags in tdb open, or added using
+    tdb_add_flags() transaction is enabled.
+    The default is that transaction nesting is not allowed and an attempt
+    to create a nested transaction will fail with TDB_ERR_NESTING.
 
+    Beware. when transactions are nested a transaction successfully
+    completed with tdb_transaction_commit() can be silently unrolled later.
 */
 
 
@@ -414,15 +416,14 @@ int tdb_transaction_start(struct tdb_context *tdb)
 
 	/* cope with nested tdb_transaction_start() calls */
 	if (tdb->transaction != NULL) {
-		if (!tdb->flags & TDB_NO_NESTING) {
-			tdb->transaction->nesting++;
-			TDB_LOG((tdb, TDB_DEBUG_TRACE, "tdb_transaction_start: nesting %d\n", 
-				 tdb->transaction->nesting));
-			return 0;
-		} else {
-			tdb_transaction_cancel(tdb);
-			TDB_LOG((tdb, TDB_DEBUG_TRACE, "tdb_transaction_start: cancelling previous transaction\n"));
+		if (!(tdb->flags & TDB_ALLOW_NESTING)) {
+			tdb->ecode = TDB_ERR_NESTING;
+			return -1;
 		}
+		tdb->transaction->nesting++;
+		TDB_LOG((tdb, TDB_DEBUG_TRACE, "tdb_transaction_start: nesting %d\n", 
+			 tdb->transaction->nesting));
+		return 0;
 	}
 
 	if (tdb->num_locks != 0 || tdb->global_lock.count) {
diff --git a/lib/tdb/include/tdb.h b/lib/tdb/include/tdb.h
index 6281181..e678a7f 100644
--- a/lib/tdb/include/tdb.h
+++ b/lib/tdb/include/tdb.h
@@ -47,14 +47,15 @@ extern "C" {
 #define TDB_NOSYNC   64 /* don't use synchronous transactions */
 #define TDB_SEQNUM   128 /* maintain a sequence number */
 #define TDB_VOLATILE   256 /* Activate the per-hashchain freelist, default 5 */
-#define TDB_NO_NESTING 512 /* Dont allow transaction nesting */
+#define TDB_ALLOW_NESTING 512 /* Allow transactions to nest */
 
 #define TDB_ERRCODE(code, ret) ((tdb->ecode = (code)), ret)
 
 /* error codes */
 enum TDB_ERROR {TDB_SUCCESS=0, TDB_ERR_CORRUPT, TDB_ERR_IO, TDB_ERR_LOCK, 
 		TDB_ERR_OOM, TDB_ERR_EXISTS, TDB_ERR_NOLOCK, TDB_ERR_LOCK_TIMEOUT,
-		TDB_ERR_NOEXIST, TDB_ERR_EINVAL, TDB_ERR_RDONLY};
+		TDB_ERR_NOEXIST, TDB_ERR_EINVAL, TDB_ERR_RDONLY,
+		TDB_ERR_NESTING};
 
 /* debugging uses one of the following levels */
 enum tdb_debug_level {TDB_DEBUG_FATAL = 0, TDB_DEBUG_ERROR, 
diff --git a/server/ctdb_freeze.c b/server/ctdb_freeze.c
index 6f99f8b..e39332e 100644
--- a/server/ctdb_freeze.c
+++ b/server/ctdb_freeze.c
@@ -345,9 +345,7 @@ int32_t ctdb_control_transaction_start(struct ctdb_context *ctdb, uint32_t id)
 			}
 		}
 
-		tdb_add_flags(ctdb_db->ltdb->tdb, TDB_NO_NESTING);
 		ret = tdb_transaction_start(ctdb_db->ltdb->tdb);
-		tdb_remove_flags(ctdb_db->ltdb->tdb, TDB_NO_NESTING);
 
 		tdb_remove_flags(ctdb_db->ltdb->tdb, TDB_NOLOCK);
 


-- 
CTDB repository


More information about the samba-cvs mailing list