diff --git a/src/common/db_backend_lmdb.cpp b/src/common/db_backend_lmdb.cpp index ac0907a6..4bac3eb7 100644 --- a/src/common/db_backend_lmdb.cpp +++ b/src/common/db_backend_lmdb.cpp @@ -11,6 +11,8 @@ #define BUF_SIZE 1024 #define CHECK_AND_ASSERT_MESS_LMDB_DB(rc, ret, mess) CHECK_AND_ASSERT_MES(res == MDB_SUCCESS, ret, "[DB ERROR]:(" << rc << ")" << mdb_strerror(rc) << ", [message]: " << mess); +#define CHECK_AND_ASSERT_THROW_MESS_LMDB_DB(rc, mess) CHECK_AND_ASSERT_THROW_MES(res == MDB_SUCCESS, "[DB ERROR]:(" << rc << ")" << mdb_strerror(rc) << ", [message]: " << mess); +#define ASSERT_MES_AND_THROW_LMDB(rc, mess) ASSERT_MES_AND_THROW("[DB ERROR]:(" << rc << ")" << mdb_strerror(rc) << ", [message]: " << mess); #undef LOG_DEFAULT_CHANNEL #define LOG_DEFAULT_CHANNEL "lmdb" @@ -134,7 +136,13 @@ namespace tools 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"); + if(res != MDB_SUCCESS) + { + //Important: if mdb_txn_begin is failed need to unlock previously locked mutex + CRITICAL_SECTION_UNLOCK(m_write_exclusive_lock); + //throw exception to avoid regular code execution + ASSERT_MES_AND_THROW_LMDB(res, "Unable to mdb_txn_begin"); + } rtxlist.push_back(tx_entry()); rtxlist.back().count = read_only ? 1 : 0; diff --git a/src/gui/qt-daemon/application/daemon_backend.cpp b/src/gui/qt-daemon/application/daemon_backend.cpp index 07a3b5a4..ba7aee2a 100644 --- a/src/gui/qt-daemon/application/daemon_backend.cpp +++ b/src/gui/qt-daemon/application/daemon_backend.cpp @@ -1565,18 +1565,18 @@ void daemon_backend::wallet_vs_options::worker_func() catch (const std::exception& e) { - LOG_PRINT_L0(w->get()->get_log_prefix() + "Failed to refresh wallet: " << e.what()); + LOG_ERROR(w->get()->get_log_prefix() + " Exception in wallet handler: " << e.what()); wallet_state = wsi.wallet_state = view::wallet_status_info::wallet_state_error; pview->update_wallet_status(wsi); - return; + continue; } catch (...) { - LOG_PRINT_L0(w->get()->get_log_prefix() + "Failed to refresh wallet, unknownk exception"); + LOG_ERROR(w->get()->get_log_prefix() + " Exception in wallet handler: unknownk exception"); wallet_state = wsi.wallet_state = view::wallet_status_info::wallet_state_error; pview->update_wallet_status(wsi); - return; + continue; } boost::this_thread::sleep_for(boost::chrono::milliseconds(100)); }