El Mar Jul 15 23:16:14 2014,
https://launchpad.net/~hyc escribió:
Show quoted text> It looks to me like the lifetime of a DB handle is bounded by the
> lifetime of a transaction. Which means a typical app that just grabs a
> DB handle once is performing all of its operations inside a single
> transaction. Or alternatively, if an app explicitly commits a txn, it
> must obtain a new DB handle when it obtains a new txn. I may have
> misunderstood the code, but that is definitely not how it should work.
You understood the code well, maybe I misuderstood something.
lmdb.h states that
"All database operations require a transaction handle."
and in mdb_dbi_open
* The database handle will be private to the current transaction until
* the transaction is successfully committed. If the transaction is
* aborted the handle will be closed automatically.
* After a successful commit the
* handle will reside in the shared environment, and may be used
* by other transactions.
So I assumed that a DB handle without a transaction is useless and if needed inside another transaction
is safer (and cheaper) to explicitly open it.
Show quoted text> DB handles are meant to be long-lived - once the txn in which a DB
> handle is created has committed, the DB handle is valid for the
> lifetime of that environment. (It may be explicitly closed sooner,
> using mdb_dbi_close, but generally there is no good reason to do so.)
When a transaction terminates the Perl level "LMDB_File" object is
invalidated, but the low level DBI remains alive in the environment.
(Unless implicitly closed if the transaction was aborted)
Show quoted text> Currently as I read it, you return [db,txn] pairs and the put/get ops
> will fail in _chkalive if the txn isn't currently valid. I see no way
> to associate a new txn to an existing DBI.
At the Perl level I don't want to expose a "naked" DBI, so to associate
it with a new transaction, the user must "open" it again, a fast operation
because, if already opened, mdb_dbi_open only (re)validates it.
Show quoted text> Also, it appears that you support only a single txn at a time, while
> LMDB itself supports 1 write txn and arbtirarily many read txns
> concurrently. Is that right?
Yes, right now and per thread, the high level Perl API support only one
transaction at a time. I don't feel the need for more than one read transaction.
Can you show me an user case?
Regards.