summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ctdb/lib/tdb/common/transaction.c18
-rw-r--r--ctdb/lib/tdb/include/tdb.h1
2 files changed, 15 insertions, 4 deletions
diff --git a/ctdb/lib/tdb/common/transaction.c b/ctdb/lib/tdb/common/transaction.c
index 4e2127be64..6a34c45269 100644
--- a/ctdb/lib/tdb/common/transaction.c
+++ b/ctdb/lib/tdb/common/transaction.c
@@ -85,6 +85,11 @@
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.
+
*/
@@ -409,10 +414,15 @@ int tdb_transaction_start(struct tdb_context *tdb)
/* cope with nested tdb_transaction_start() calls */
if (tdb->transaction != NULL) {
- tdb->transaction->nesting++;
- TDB_LOG((tdb, TDB_DEBUG_TRACE, "tdb_transaction_start: nesting %d\n",
- tdb->transaction->nesting));
- return 0;
+ 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->num_locks != 0 || tdb->global_lock.count) {
diff --git a/ctdb/lib/tdb/include/tdb.h b/ctdb/lib/tdb/include/tdb.h
index 0008085de5..628118172e 100644
--- a/ctdb/lib/tdb/include/tdb.h
+++ b/ctdb/lib/tdb/include/tdb.h
@@ -47,6 +47,7 @@ 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_ERRCODE(code, ret) ((tdb->ecode = (code)), ret)