forked from lthn/blockchain
attempt to fix bug in lmdb backend
This commit is contained in:
parent
b504849b0d
commit
19daa91f08
1 changed files with 9 additions and 0 deletions
|
|
@ -108,8 +108,12 @@ namespace tools
|
|||
transactions_list& rtxlist = m_txs[std::this_thread::get_id()];
|
||||
MDB_txn* pparent_tx = nullptr;
|
||||
MDB_txn* p_new_tx = nullptr;
|
||||
bool parent_read_only = false;
|
||||
if (rtxlist.size())
|
||||
{
|
||||
pparent_tx = rtxlist.back().ptx;
|
||||
parent_read_only = rtxlist.back().read_only;
|
||||
}
|
||||
|
||||
|
||||
if (pparent_tx && read_only)
|
||||
|
|
@ -123,6 +127,11 @@ namespace tools
|
|||
if (read_only)
|
||||
flags += MDB_RDONLY;
|
||||
|
||||
//don't use parent tx in write transactions if parent tx was read-only (restriction in lmdb)
|
||||
//see "Nested transactions: Max 1 child, write txns only, no writemap"
|
||||
if (pparent_tx && parent_read_only)
|
||||
pparent_tx = nullptr;
|
||||
|
||||
CHECK_AND_ASSERT_THROW_MES(m_penv, "m_penv==null, db closed");
|
||||
res = mdb_txn_begin(m_penv, pparent_tx, flags, &p_new_tx);
|
||||
CHECK_AND_ASSERT_MESS_LMDB_DB(res, false, "Unable to mdb_txn_begin");
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue