Thanks for the reply.
That's what it says on its own, but the doc also says:
* 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.
That suggests I have to wait for a transaction to finish before I can reuse the same db handle for other transactions.
How would you in practice perform multiple transactions at the same time? I don't see it yet. I'm missing something basic.
Feb 11, 2019, 5:50 AM by hyc@symas.com:
Sam Dave wrote:
Hello,
The doc for mdb_dbi_open 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.
This indicates that each process can only perform one transaction at the same time.
No, it only says you may only call mdb_dbi_open from one transaction at a time.
This makes sense for write transactions, but wasn't LMDB supposed to support multiple read transactions at the same time?
I'm a bit confused now. Can you assist?
Thanks, Sam
-- -- Howard Chu CTO, Symas Corp. > http://www.symas.com http://www.symas.com Director, Highland Sun > http://highlandsun.com/hyc http://highlandsun.com/hyc/ Chief Architect, OpenLDAP > http://www.openldap.org/project http://www.openldap.org/project/
Sam Dave wrote:
Thanks for the reply.
That's what it says on its own, but the doc also says:
- 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.
That suggests I have to wait for a transaction to finish before I can reuse the same db handle for other transactions.
No, that's not at all what it says.
*Opening* a DBI handle can only be done by one transaction. *Using* an open DBI handle can be done by any transactions.
How would you in practice perform multiple transactions at the same time? I don't see it yet. I'm missing something basic.
Feb 11, 2019, 5:50 AM by hyc@symas.com:
Sam Dave wrote: Hello, The doc for mdb_dbi_open 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. This indicates that each process can only perform one transaction at the same time. No, it only says you may only call mdb_dbi_open from one transaction at a time. This makes sense for write transactions, but wasn't LMDB supposed to support multiple read transactions at the same time? I'm a bit confused now. Can you assist? Thanks, Sam -- -- Howard Chu CTO, Symas Corp. http://www.symas.com Director, Highland Sun http://highlandsun.com/hyc <http://highlandsun.com/hyc/> Chief Architect, OpenLDAP http://www.openldap.org/project <http://www.openldap.org/project/>
On 2019/02/11 09:22, Howard Chu wrote:
*Opening* a DBI handle can only be done by one transaction.*Using* an open DBI handle can be done by any transactions.
That still means that the "opening transaction" must complete before the handle becomes public. I guess (I really am applying commonsense, here, so I could be wrong in real terms) that such an opening transaction ought to be restricted to the open and nothing else, unless it is going to be the only one.
Lucio.
PS: Clarifying this rather subtle point may be worth an extra paragraph in the documentation.
On 11.02.2019 08:35, Lucio De Re wrote:
On 2019/02/11 09:22, Howard Chu wrote:
*Opening* a DBI handle can only be done by one transaction.*Using* an open DBI handle can be done by any transactions.
That still means that the "opening transaction" must complete before the handle becomes public.
Yes. I think you two just misunderstand each other a bit.
I guess (I really am applying commonsense, here, so I could be wrong in real terms) that such an opening transaction ought to be restricted to the open and nothing else, unless it is going to be the only one.
No. We could document that as a recommendation for opening existing DBs.
However, creating a database also involves opening it. You might want to use transactions to ensure that if some small database exists, its contents is complete. Similar to how you often do with plain files: You don't want to have to first create an empty file, then fill it in.
On 2019/02/11 16:14, Hallvard Breien Furuseth wrote:
No. We could document that as a recommendation for opening existing DBs.
That just proves my point, I suppose: it usually suffices for documentation to be complete, whereas what is happening here is that OP overlooked something that would be obvious to an experienced user. I understood Howard's point, with some prodding. In other words, there is room in the documentation to be instructive as well as informative and I doubt that there would be any harm in that.
I certainly am walking away understanding more, after following this discussion, than I was hoping to. So, many thanks, everyone.
Lucio.
Lucio De Re wrote:
On 2019/02/11 09:22, Howard Chu wrote:
*Opening* a DBI handle can only be done by one transaction.*Using* an open DBI handle can be done by any transactions.
That still means that the "opening transaction" must complete before the handle becomes public.
Yes, that's exactly what the documentation says:
- After a successful commit the handle will reside in the shared
- environment, and may be used by other transactions.
I guess (I really am applying commonsense, here, so I could be wrong in real terms) that such an opening transaction ought to be restricted to the open and nothing else, unless it is going to be the only one.
There is no such requirement, but obviously if you want to use the handle from other threads and transactions, it would make sense to complete the opening txn as quickly as possible.
Lucio.
PS: Clarifying this rather subtle point may be worth an extra paragraph in the documentation.
There's nothing subtle here, the doc is quite explicit. Wasting additional paragraphs only brings complaints from users that "the docs are too big to read."
On 2019/02/11 16:25, Howard Chu wrote:
There's nothing subtle here, the doc is quite explicit. Wasting additional paragraphs only brings complaints from users that "the docs are too big to read."
For every such complaint, Howard, I am confident that there are dozens of users who are grateful to be so guided. They are just not as strident.
Don't pamper the wrong types, please.
Lucio.
Thank you all for the help. It all makes sense now. I did not realize the first transaction is meant to be used only for (or at least is, in practice, most commonly used only for) specifically grabbing a database handle for use in future transactions. With this common use case in mind, things started to make sense. Thanks, Sam
openldap-technical@openldap.org