Sam Dave wrote:
> Hello,
> 
> 1. I create a read-only transaction on an environment with mdb_txn_begin().
> 2.Then I get a database handle on the same environment (using mdb_dbi_open() 
> within a separate transaction).
> 3. Finally I try to create and use a cursor using the database in 2. and 
> transaction in 1. but I get various runtime errors ("Segmentation fault" or 
> "double
> free or corruption").
> 
> However, if I switch 1. and 2., everything works.
> 
> Must a database really be created before a transaction? If so, curious to 
> learn if this is mentioned anywhere in the docs (I didn't see it)

The docs are quite explicit:

http://www.lmdb.tech/doc/group__mdb.html#gac08cad5b096925642ca359a6d6f0562a

####
The database handle will be private to the current transaction until the 
transaction is
successfully committed.

After a successful commit the handle will reside in the shared environment, and 
may be
used by other transactions.
####

-- 
  -- Howard Chu
  CTO, Symas Corp.           http://www.symas.com
  Director, Highland Sun     http://highlandsun.com/hyc/
  Chief Architect, OpenLDAP  http://www.openldap.org/project/

Reply via email to