bert hubert wrote:
First, thank you for developing openldap & lmdb, both are appreciated. I ran
openldap 'way back in the day' to power one of the first cable internet
providers in The Netherlands, and once we shook out the bugs, it was great!
Within PowerDNS, we have an LMDB backend for the highest performance, and we
also want to use it for Metronome (https://github.com/ahupowerdns/metronome
, a sort of mini-graphite).
In order to do so, I'm documenting LMDB semantics. The LMDB documentation
has most of this, but I'd like to get the semantics in one place.
some great help from Howard already)
A few questions:
* - Do not have open an MDB database twice in the same process at
* the same time. Not even from a plain open() call - close()ing it
* breaks flock() advisory locking.
I see this note, but I also see a lot about TLS locking. Is this remark
still true? It is quite difficult for many applications to effectively
serialize LMDB access this way, which would be required because:
Threads are not processes. You are misreading this note.
* - A thread can only use one transaction at a time, plus any
* transactions. Each transaction belongs to one thread. See below.
* The #MDB_NOTLS flag changes this for read-only transactions.
I note that the source does not actually use flock() but fcntl()-based
locking, which does have the problem described above.
Yes, the comment should probably say fcntl instead of flock.
So my question, if there is one process with many threads that need
and update an lmdb, what is the recommended way to do that, short of
single threading the access to lmdb?
There is no problem with accessing LMDB from multiple threads.
-- Howard Chu
CTO, Symas Corp. http://www.symas.com
Director, Highland Sun http://highlandsun.com/hyc/
Chief Architect, OpenLDAP http://www.openldap.org/project/