s3:gencache: don't use transaction non non-persistent gencache_notrans.tdb
authorMichael Adam <obnox@samba.org>
Wed, 2 Jul 2014 05:44:04 +0000 (07:44 +0200)
committerVolker Lendecke <vl@samba.org>
Wed, 26 Nov 2014 15:43:04 +0000 (16:43 +0100)
commit35fd2ca4984b3a1a8bbcb5c1c9e0d724e3c63d80
treefa4bee6b9a420e96f75f8b248b9b432edae354a1
parentd240cf7894f076a2ed2b6bc434f20a93cfbb1ca4
s3:gencache: don't use transaction non non-persistent gencache_notrans.tdb

gencache_notrans.tdb is a non-persistent cache layer above the
persistent gencache.tdb. Despite its name, and despite the
nature of non-persistent tdbs, the current stabilization code
uses a transaction on gencache_notrans.tdb like this:

  transaction_start(cache)
  transaction_start(cache_notrans)
  traverse(cache_notrans, stabilize_fn)
  transaction_commit(cache)
  transaction_commit(cache_notrans)

where stabilze_fn does this on a record:
  1. store it to or delete it from cache
     (depending on the timeout)
  2. delete it from the cache_notrans

This patch changes gencache_notrans.tdb to avoid
transactions by using an all-record lock like this:

  tdb_allrecord_lock(cache_notrans)
  transaction_start(cache)
  traverse(cache_notrans, stabilize_fn_mod)
  transaction_commit(cache)
  traverse(cache_notrans, wipe_fn)
  tdb_wipe_all(cache_notrans)
  tdb_allrecord_unlock(cache_notrans)

with stabilize_fn_mod doing only:
  1. store the record to or delete it from cache
     (depending on the timeout)

and wipe_fn deleting the records from the gencache_notrans db.

This is a step towards making non-persistent-db specific features
like mutex locking usable for gencache_notrans.tdb.

Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Christof Schmitt <cs@samba.org>
source3/lib/gencache.c