diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2017-08-29 15:43:32 +0100 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2017-08-29 15:43:32 +0100 |
commit | ce901fcb3174a2795483fba653a1128ce6b15858 (patch) | |
tree | b8955b4e258d3e62799b820dd0b4e6cc6d4b9caf /src/blockchain_db/lmdb/db_lmdb.cpp | |
parent | core: guard against exceptions in handle_incoming_{block,tx} (diff) | |
download | monero-ce901fcb3174a2795483fba653a1128ce6b15858.tar.xz |
Fix blockchain_import wedge on exception in cleanup_handle_incoming_blocks
Diffstat (limited to 'src/blockchain_db/lmdb/db_lmdb.cpp')
-rw-r--r-- | src/blockchain_db/lmdb/db_lmdb.cpp | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/src/blockchain_db/lmdb/db_lmdb.cpp b/src/blockchain_db/lmdb/db_lmdb.cpp index 4100d9cca..b6978bdc4 100644 --- a/src/blockchain_db/lmdb/db_lmdb.cpp +++ b/src/blockchain_db/lmdb/db_lmdb.cpp @@ -2604,6 +2604,16 @@ void BlockchainLMDB::batch_commit() memset(&m_wcursors, 0, sizeof(m_wcursors)); } +void BlockchainLMDB::cleanup_batch() +{ + // for destruction of batch transaction + m_write_txn = nullptr; + delete m_write_batch_txn; + m_write_batch_txn = nullptr; + m_batch_active = false; + memset(&m_wcursors, 0, sizeof(m_wcursors)); +} + void BlockchainLMDB::batch_stop() { LOG_PRINT_L3("BlockchainLMDB::" << __func__); @@ -2618,15 +2628,18 @@ void BlockchainLMDB::batch_stop() check_open(); LOG_PRINT_L3("batch transaction: committing..."); TIME_MEASURE_START(time1); - m_write_txn->commit(); - TIME_MEASURE_FINISH(time1); - time_commit1 += time1; - // for destruction of batch transaction - m_write_txn = nullptr; - delete m_write_batch_txn; - m_write_batch_txn = nullptr; - m_batch_active = false; - memset(&m_wcursors, 0, sizeof(m_wcursors)); + try + { + m_write_txn->commit(); + TIME_MEASURE_FINISH(time1); + time_commit1 += time1; + cleanup_batch(); + } + catch (const std::exception &e) + { + cleanup_batch(); + throw; + } LOG_PRINT_L3("batch transaction: end"); } |