[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: (LMDB) read-only transactions and DBI handles



Viacheslav Usov wrote:

I have a question about mdb_dbi_open and the handles it returns. The official
documentation suggests to me that mdb_dbi_open is supposed to be called early
on and then the obtained handle should just be reused by other transactions
without any further calls to mdb_dbi_open and mdb_dbi_close. The code in
sample-mdb.txt does that (ignoring the final close-all sequence).

The sample also uses mdb_txn_abort to end a read-only transaction, which I
take as the recommended way to end read-only transactions.

Transactional databases are very simple:

abort is the way to end *any* transaction whose operations you wish to discard.

commit is the way to end *any* transaction whose operations you wish to persist.

If you open a DBI in a read-only transaction and you want that DBI to persist after ending the transaction, then commit the transaction.

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