NTDB: Redesigning The Trivial DataBase
Rusty Russell, IBM Corporation
19 June 2012
Abstract
The Trivial DataBase on-disk format is 32 bits; with usage cases head-
ing towards the 4G limit, that must change. This required breakage pro-
vides an opportunity to revisit TDB's other design decisions and reassess
them.
1 Introduction
The Trivial DataBase was originally written by Andrew Tridgell as a simple
key/data pair storage system with the same API as dbm, but allowing multiple
readers and writers while being small enough (< 1000 lines of C) to include in
SAMBA. The simple design created in 1999 has proven surprisingly robust and
performant, used in Samba versions 3 and 4 as well as numerous other projects.
Its useful life was greatly increased by the (backwards-compatible!) addition of
transaction support in 2005.
The wider variety and greater demands of TDB-using code has lead to some
organic growth of the API, as well as some compromises on the implementation.
None of these, by themselves, are seen as show-stoppers, but the cumulative
eect is to a loss of elegance over the initial, simple TDB implementation. Here
is a table of the approximate number of lines of implementation code and number
of API functions at the end of each year:
Year End API Functions Lines of C Code Implementation
1999 13 1195
2000 24 1725
2001 32 2228
2002 35 2481
2003 35 2552
2004 40 2584
2005 38 2647
2006 52 3754
2007 66 4398
2008 71 4768
2009 73 5715
1