From afc616b67b9f0cd6b535cb12d20f4752e7c4ade9 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 22 Oct 2018 17:18:43 +0200 Subject: [PATCH] tdbtorture: No transaction with mutexes Right now we don't do transactions with mutexed tdbs. tdbtorture -m locks up. I haven't really investigated why that is the case. The lockup confused me quite a bit until I figured out it works fine as long as it does not do transactions, which is all we need right now. Signed-off-by: Volker Lendecke Reviewed-by: Andreas Schneider --- lib/tdb/tools/tdbtorture.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/lib/tdb/tools/tdbtorture.c b/lib/tdb/tools/tdbtorture.c index 3640dc7ed6c..1655c28dfc8 100644 --- a/lib/tdb/tools/tdbtorture.c +++ b/lib/tdb/tools/tdbtorture.c @@ -93,6 +93,19 @@ static int cull_traverse(struct tdb_context *tdb, TDB_DATA key, TDB_DATA dbuf, return 0; } +static bool do_transaction(void) +{ +#if TRANSACTION_PROB + if (mutex) { + return false; + } + if (random() % TRANSACTION_PROB == 0) { + return true; + } +#endif + return false; +} + static void addrec_db(void) { int klen, dlen; @@ -118,16 +131,15 @@ static void addrec_db(void) } #endif -#if TRANSACTION_PROB if (in_transaction == 0 && - (always_transaction || random() % TRANSACTION_PROB == 0)) { + (always_transaction || do_transaction())) { if (tdb_transaction_start(db) != 0) { fatal("tdb_transaction_start failed"); } in_transaction++; goto next; } - if (in_transaction && random() % TRANSACTION_PROB == 0) { + if (in_transaction && do_transaction()) { if (random() % TRANSACTION_PREPARE_PROB == 0) { if (tdb_transaction_prepare_commit(db) != 0) { fatal("tdb_transaction_prepare_commit failed"); @@ -139,14 +151,13 @@ static void addrec_db(void) in_transaction--; goto next; } - if (in_transaction && random() % TRANSACTION_PROB == 0) { + if (in_transaction && do_transaction()) { if (tdb_transaction_cancel(db) != 0) { fatal("tdb_transaction_cancel failed"); } in_transaction--; goto next; } -#endif #if DELETE_PROB if (random() % DELETE_PROB == 0) {