diff options
author | Andrew Tridgell <tridge@samba.org> | 2005-09-22 13:12:46 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:38:44 -0500 |
commit | bd310b792509f7305d7dc029eb4bec109322a4bf (patch) | |
tree | 7621c4474ccae12b9126e09c25bd6ff70fbc998e /source4/lib/tdb/tools | |
parent | 05bd880626255c6547922204d7ba012aa9bc6d50 (diff) | |
download | samba-bd310b792509f7305d7dc029eb4bec109322a4bf.tar.gz samba-bd310b792509f7305d7dc029eb4bec109322a4bf.tar.bz2 samba-bd310b792509f7305d7dc029eb4bec109322a4bf.zip |
r10421: following on discussions with simo, I have worked out a way of
allowing searches to proceed while another process is in a
transaction, then only upgrading the transaction lock to a write lock
on commit.
The solution is:
- split tdb_traverse() into two calls, called tdb_traverse() and
tdb_traverse_read(). The _read() version only gets read locks, and
will fail any write operations made in the callback from the
traverse.
- the normal tdb_traverse() call allows for read or write operations
in the callback, but gets the transaction lock, preventing
transastions from starting inside the traverse
In addition we enforce the following rule that you may not start a
transaction within a traverse callback, although you can start a
traverse within a transaction
With these rules in place I believe all the deadlock possibilities are
removed, and we can now allow for searches to happen in parallel with
transactions
(This used to be commit 7dd31288a701d772e45b1960ac4ce4cc1be782ed)
Diffstat (limited to 'source4/lib/tdb/tools')
-rw-r--r-- | source4/lib/tdb/tools/tdbtorture.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/source4/lib/tdb/tools/tdbtorture.c b/source4/lib/tdb/tools/tdbtorture.c index b0a2e7484f..c0076a92d4 100644 --- a/source4/lib/tdb/tools/tdbtorture.c +++ b/source4/lib/tdb/tools/tdbtorture.c @@ -39,6 +39,7 @@ #define TRANSACTION_PROB 10 #define LOCKSTORE_PROB 5 #define TRAVERSE_PROB 20 +#define TRAVERSE_READ_PROB 20 #define CULL_PROB 100 #define KEYLEN 3 #define DATALEN 100 @@ -192,6 +193,13 @@ static void addrec_db(void) } #endif +#if TRAVERSE_READ_PROB + if (random() % TRAVERSE_READ_PROB == 0) { + tdb_traverse_read(db, NULL, NULL); + goto next; + } +#endif + data = tdb_fetch(db, key); if (data.dptr) free(data.dptr); @@ -273,7 +281,7 @@ static void usage(void) addrec_db(); } - tdb_traverse(db, NULL, NULL); + tdb_traverse_read(db, NULL, NULL); tdb_traverse(db, traverse_fn, NULL); tdb_traverse(db, traverse_fn, NULL); |