1
0
Fork 0
forked from lthn/blockchain

attempt to fix bug in lmdb backend

This commit is contained in:
cryptozoidberg 2019-06-06 14:34:05 +03:00
parent b504849b0d
commit 19daa91f08
No known key found for this signature in database
GPG key ID: 22DEB97A54C6FDEC

View file

@ -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");