Hi, I have been using LMDB for over a year now. It has been a wonderful experience. A great thank you for the wonderful work that you guys have done.
Till now I have used it on the main thread. And for the info, I only make use of LMDB named dbi.
I was trying to make it work in threads. Reading the docs on mdb_dbi_open got me confused. The doc says
" * The database handle will be private to the current transaction until * the transaction is successfully committed. " and
" * 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. "
I use MDB_NOTLS. Does the doc mean I can't simultaneously read the same named dbi from multiple threads because I have to wait for readers in other threads to commit before starting a read of the same named dbi?
On 20/05/17 02:14, Muhammed Muneer wrote:
Does the doc mean I can't simultaneously read the same named dbi from multiple threads because I have to wait for readers in other threads to commit before starting a read of the same named dbi?
No, only that you cannot _open_ DBIs in simultaneous threads. Begin a transaction, open DBI(s) in it, and commit. Commit makes the new database snapshot and newly opened DBIs visible to transactions which begin _after_ the commit. Those later transactions can use the DBI simultaneously, since they do not need mdb_dbi_open().
Hallvard
So when the doc says
* The database handle will be private to the current transaction until * the transaction is successfully committed.
"the handle being private" only refers to the first mdb_dbi_open. Once this transaction is committed, one doesn't have to call this again in subsequent concurrent transactions and can use this handle. And then this handle won't be private at all.
Did I get it right?
On Sat, May 20, 2017 at 6:44 AM, Hallvard Breien Furuseth < h.b.furuseth@usit.uio.no> wrote:
On 20/05/17 02:14, Muhammed Muneer wrote:
Does the doc mean I can't simultaneously read the same named dbi from multiple threads because I have to wait for readers in other threads to commit before starting a read of the same named dbi?
No, only that you cannot _open_ DBIs in simultaneous threads. Begin a transaction, open DBI(s) in it, and commit. Commit makes the new database snapshot and newly opened DBIs visible to transactions which begin _after_ the commit. Those later transactions can use the DBI simultaneously, since they do not need mdb_dbi_open().
Hallvard
On 5/20/17 2:02 PM, Muhammed Muneer wrote:
So when the doc says
* The database handle will be private to the current transaction until * the transaction is successfully committed.
"the handle being private" only refers to the first mdb_dbi_open. Once this transaction is committed, one doesn't have to call this again in subsequent concurrent transactions and can use this handle. And then this handle won't be private at all.
Did I get it right?
Yes. I do this exactly that way as part of my initial setup of my application. Once the transaction is committed, I use the returned handles setup from whatever thread that needs to access the respective database. I never call mdb_dbi_open again after the setup.
Regards,
Klaus
Thanks.
On Sat, May 20, 2017 at 6:29 PM, Klaus Malorny Klaus.Malorny@knipp.de wrote:
On 5/20/17 2:02 PM, Muhammed Muneer wrote:
So when the doc says
* The database handle will be private to the current transaction
until * the transaction is successfully committed.
"the handle being private" only refers to the first mdb_dbi_open. Once this transaction is committed, one doesn't have to call this again in subsequent concurrent transactions and can use this handle. And then this handle won't be private at all.
Did I get it right?
Yes. I do this exactly that way as part of my initial setup of my application. Once the transaction is committed, I use the returned handles setup from whatever thread that needs to access the respective database. I never call mdb_dbi_open again after the setup.
Regards,
Klaus
Is the following valid.
1) Read transaction 1 is started 2) Read transaction 2 is started and calls mdb_dbi_open and commits 3) Read transaction 1 uses the handle from (2)
On Sat, May 20, 2017 at 6:46 PM, Muhammed Muneer elendilm@gmail.com wrote:
Thanks.
On Sat, May 20, 2017 at 6:29 PM, Klaus Malorny Klaus.Malorny@knipp.de wrote:
On 5/20/17 2:02 PM, Muhammed Muneer wrote:
So when the doc says
* The database handle will be private to the current transaction
until * the transaction is successfully committed.
"the handle being private" only refers to the first mdb_dbi_open. Once this transaction is committed, one doesn't have to call this again in subsequent concurrent transactions and can use this handle. And then this handle won't be private at all.
Did I get it right?
Yes. I do this exactly that way as part of my initial setup of my application. Once the transaction is committed, I use the returned handles setup from whatever thread that needs to access the respective database. I never call mdb_dbi_open again after the setup.
Regards,
Klaus
openldap-technical@openldap.org