[Date Prev][Date Next]
[Chronological]
[Thread]
[Top]
Re: [lmdb] MDB_BAD_DBI error upon mdb_txn_commit (newbie question)
- To: hlaw <hhclaw.eb@gmail.com>, openldap-technical@openldap.org
- Subject: Re: [lmdb] MDB_BAD_DBI error upon mdb_txn_commit (newbie question)
- From: Howard Chu <hyc@symas.com>
- Date: Thu, 2 Apr 2015 19:54:59 +0100
- In-reply-to: <CAP8ySv1fbHpXXR=JcB3vEKXOkLc1+Q76+4Q4TgO7-FMJ-1y28Q@mail.gmail.com>
- References: <55144663.3030706@gmail.com> <551938EF.5010609@usit.uio.no> <CAP8ySv1fbHpXXR=JcB3vEKXOkLc1+Q76+4Q4TgO7-FMJ-1y28Q@mail.gmail.com>
- User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Firefox/38.0 SeaMonkey/2.35a1
hlaw wrote:
Thank you!
It appears that mdb_dbi_open() must be called before any read / write
access to a database in a transaction,
True.
and all read / write have to be
done in a transaction?
True.
If this is the case, is it correct that due to
the concurrency restriction above, there is essentially no concurrent
access (including read and write) to the same database in a
multi-threaded process,
False.
since a database is available to one transaction
in a time?
False. Reread the mdb_dbi_open doc. http://symas.com/mdb/doc/group__mdb.html#gac08cad5b096925642ca359a6d6f0562a
2015-03-30 19:52 GMT+08:00 Hallvard Breien Furuseth
<h.b.furuseth@usit.uio.no <mailto:h.b.furuseth@usit.uio.no>>:
You're abusing mdb_dbi_open(). Its doc says:
"This function must not be called from multiple concurrent
transactions in the same process. A transaction that uses this
function must finish (either commit or abort) before any other
transaction in the process may use this function."
That text could have stood out a bit better in the doc:-(
The error is simple for lmdb to try to catch, though without
locking it cannot guarantee to catch it. Try this patch:
<http://folk.uio.no/hbf/__OpenLDAP/mdb.serial-open.diff
<http://folk.uio.no/hbf/OpenLDAP/mdb.serial-open.diff>>
(Howard, this is branch "mdb/serial-open" in my UiO repo.)
Not sure if it should do more than this. E.g. attack mdb_drop
too. Maybe set MDB_TXN_ERROR since a program with broken
threading can break the DB.
--
Hallvard
--
-- Howard Chu
CTO, Symas Corp. http://www.symas.com
Director, Highland Sun http://highlandsun.com/hyc/
Chief Architect, OpenLDAP http://www.openldap.org/project/