tdb questions

Volker Lendecke Volker.Lendecke at SerNet.DE
Fri May 24 06:11:08 MDT 2013


On Thu, May 23, 2013 at 10:03:41PM +0200, Daniele wrote:
> Which is the difference between using or not mmap? Is it
> suggested the use of mmap and if not available there is
> the fallback or are there other things to take in account
> when making the choice?

The default is mmap, and should be used where possible. A
few operating systems like HP/UX and OpenBSD (not sure about
current OpenBSD) do not support coherent mmap and
read/write. On a sane OS mmap should be no problem.

> From what I know, tdb is a persistent db. The application

Yes, it is file-backed, but with default operation we can
lose data when the machine just crashes. Samba uses the
TDB_CLEAR_IF_FIRST flag for the databases that don't need to
persist across restarts.

> I'working on would work on a system which can loose power
> so which would be the best practices to avoid corruptions?

Use tdb_transaction_start/cancel/commit to be safe. It will
slow down write operations significantly, mainly due to
msync/fsync calls, but the database will remain intact even
under crashes (assuming the file system below does not
cheat). Make sure you have write barriers (barrier=1)
activated in the file system mount and also make sure your
storage stack (LVM around?) properly supports these
barriers.

Volker

-- 
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de, mailto:kontakt at sernet.de


More information about the samba-technical mailing list