Fix sleep

Signed-off-by: Anthony Fieroni <bvbfan@abv.bg>
This commit is contained in:
Anthony Fieroni 2019-11-25 15:08:02 +02:00
parent 17a4ded0ca
commit 1cc1b0fb80

View file

@ -5,8 +5,10 @@
#include <trie.h> #include <trie.h>
#include <algorithm> #include <algorithm>
#include <chrono>
#include <memory> #include <memory>
#include <iomanip> #include <iomanip>
#include <thread>
#include <tuple> #include <tuple>
#include <boost/container/flat_map.hpp> #include <boost/container/flat_map.hpp>
@ -466,20 +468,23 @@ bool CClaimTrieCacheBase::flush()
{ {
if (transacting) { if (transacting) {
getMerkleHash(); getMerkleHash();
RETRY_COMMIT: do {
try { try {
db << "commit"; db << "commit";
} } catch (const sqlite::sqlite_exception& e) {
catch (const sqlite::sqlite_exception& e) { auto code = e.get_code();
logPrint << "ERROR in ClaimTrieCache flush: " << e.what() << Clog::endl; if (code == SQLITE_LOCKED || code == SQLITE_BUSY) {
auto code = e.get_code(); logPrint << "Retrying the commit in one second." << Clog::endl;
if (code == SQLITE_LOCKED || code == SQLITE_BUSY) { using namespace std::chrono_literals;
LogPrintf("Retrying the commit in one second.\n", e.what()); std::this_thread::sleep_for(1s);
MilliSleep(1000); continue;
goto RETRY_COMMIT; } else {
logPrint << "ERROR in ClaimTrieCache::" << __func__ << "(): " << e.what() << Clog::endl;
return false;
}
} }
return false; break;
} } while (true);
transacting = false; transacting = false;
} }
base->nNextHeight = nNextHeight; base->nNextHeight = nNextHeight;