[Date Prev][Date Next]
[Chronological]
[Thread]
[Top]
Re: mdb_dbi_open and threads
On 21. mai 2017 21:43, Muhammed Muneer wrote:
Howard Chu wrote
"Just follow the recommendation to open all handles at the beginning of the
program."
But what if I have lots of named databases like maybe 10000 or more. Wouldn't
this be expensive.
Yes. From ldmb.h:
"Currently a moderate number of slots are cheap but a huge number gets
expensive: 7-120 words per transaction, and every #mdb_dbi_open()
does a linear search of the opened slots."
So in a multi threaded environment, if the name of a named dbi is generated
from within a write
transaction (thread1) and proceeds to mdb_dbi_open it only to find that
another read transaction
(thread 2) just opened the same named dbi after the write-txn of thread 1
started, the prospect of
mdb_dbi_open the same named dbi for thread 1 is lost forever.
With threads 1 and 2 coexisting? When thread 2 called mdb_dbi_open(),
thread 1's prospect of using mdb_dbi_open() at all was lost.
--
Hallvard