Samba4: LDB size limit and memory leak

ronnie sahlberg ronniesahlberg at
Mon Jun 1 05:51:42 GMT 2009

On Thu, May 28, 2009 at 5:43 PM, <tridge at> wrote:

> Hi Marcel,
> The following patch reduces the problem a bit by repacking the
> database whenever it is expanded inside a transaction.
> It still grows far more than it should though. Maybe we need to take a
> fresh look at the ldb indexing approach. The killer is the indexes
> like objectClass, which consists of a record with a key of
> DN=@INDEX:OBJECTCLASS:USER that contains a list of every DN that is a
> user object. That record grows by one entry for each new user, which
> is the worst case for our free space allocation code in tdb. It also
> means that for large N, adding N new users is O(N^2), as for each user
> we need to re-write a record of size proportional to N. That is not
> good.
> Does anyone have any suggestions for a better indexing strategy?
> Cheers, Tridge

Wouldnt a repack be quite expensive for large TDBs?

Why not using a linked list of entries? Where one entry points to the next
in the list. (this would need some new tdb magic to let TDB itself handle
these links).
Yes, it would make reading the entire index-object a lot slower, since it
would only read one entry per tdb_fetch(), but then again the full
tdb_traverse that is needed (twice) for the tdb_repack() is not exactly
cheap either.

I.e.  adding linked list support in tdb.

More information about the samba-technical mailing list