1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00
samba-mirror/lib/tdb
Volker Lendecke 500a729a55 tdb: Make record deletion circular-chain safe
Before this patch we had 3 loops walking a hash chain to delete
records:

tdb_do_delete() to find the predecessor of the record that was to be
deleted. tdb_count_dead(), the name says it all and tdb_purge_dead()
to give back all dead records from a chain to the freelist.

This patch introduces tdb_trim_dead that walks a hash chain just
once. While it does so it counts the number of dead records, and all
records beyond tdb->max_dead_records are moved to the freelist.

Normal record deletion now works by always marking a record as dead in
step 1 and then calling tdb_trim_dead. This is made safe against
circular chains by doing the slow chain walk only in the case when we
did not delete a dead record during our walk.

It changes our dynamics a bit:

When deleting a record with non-zero max_dead_records, now we always
leave that number of records around when deleting, doing a blocking
lock on the freelist when we found too many dead records.

Previously when exceeding max_dead_records we wiped all dead records
to start accumulating them from scratch, assuming we could lock the
freelist in a nonblocking fashion.

The net effect for an uncontended freelist is the same: In
tdb_allocate() we still completely hand over all dead records to the
freelist when we could lock it, it just happens later than without
this patch.

This means for a lightly loaded system we will potentially leave more
dead records around in databases like locking.tdb. However, on a
heavily loaded system we become more predictable: If the freelist is
so heavily contended that across many deletes we can't get hold of it,
previously we accumulated more dead records than max_dead_records
would allow. This is a really lowlevel tradeoff that is likely hard to
measure, but to me becoming more deterministic without sacrificing too
much parallelism (we keep more dead records around) is worth trying.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>

Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Tue Oct 30 02:48:38 CET 2018 on sn-devel-144
2018-10-30 02:48:38 +01:00
..
ABI tdb: version 1.3.16 2018-07-12 04:32:09 +02:00
common tdb: Make record deletion circular-chain safe 2018-10-30 02:48:38 +01:00
docs Fix various spelling errors 2015-11-06 13:43:45 +01:00
include tdb: Add new function tdb_transaction_active() 2017-07-02 17:35:19 +02:00
man tdbtool: Add "storehex" command 2017-04-22 09:16:16 +02:00
python python: bulk replace dict.iteritems to items for py3 2018-04-13 07:27:12 +02:00
test tdb: Basic test for circular freelist fix 2018-10-08 22:17:11 +02:00
tools tdbtorture: Align integer types 2018-10-25 17:58:24 +02:00
web Update tdb and talloc web pages 2009-05-05 19:04:39 -04:00
_tdb_text.py tdb/test/_tdbtext: remove unused imports 2018-10-25 21:45:55 +02:00
configure tdb: Remove autotools support. 2010-12-24 01:15:05 +01:00
doxy.config doc: Remove build/ from doxygen config or it will not work in brew. 2012-08-04 16:31:22 +02:00
Makefile tdb: import unit tests from CCAN into tdb/test/ 2012-02-14 04:05:43 +10:30
pytdb.c tdb python binding: raise KeyError(key) when the key doesn't exist 2015-07-21 19:04:15 +02:00
tdb.pc.in s4-pkgconfig: add @LIB_RPATH@ to our link flags 2010-12-08 12:46:00 +01:00
wscript tdb: Basic test for circular freelist fix 2018-10-08 22:17:11 +02:00