Catch LevelDB errors during flush

Rebased-From: e41345790f
Github-Pull: #5597
This commit is contained in:
Pieter Wuille 2015-01-04 19:11:44 +01:00 committed by Wladimir J. van der Laan
parent 008138c04a
commit 867c600c29
No known key found for this signature in database
GPG Key ID: 74810B012346C9A6

View File

@ -1805,6 +1805,7 @@ enum FlushStateMode {
bool static FlushStateToDisk(CValidationState &state, FlushStateMode mode) { bool static FlushStateToDisk(CValidationState &state, FlushStateMode mode) {
LOCK(cs_main); LOCK(cs_main);
static int64_t nLastWrite = 0; static int64_t nLastWrite = 0;
try {
if ((mode == FLUSH_STATE_ALWAYS) || if ((mode == FLUSH_STATE_ALWAYS) ||
((mode == FLUSH_STATE_PERIODIC || mode == FLUSH_STATE_IF_NEEDED) && pcoinsTip->GetCacheSize() > nCoinCacheSize) || ((mode == FLUSH_STATE_PERIODIC || mode == FLUSH_STATE_IF_NEEDED) && pcoinsTip->GetCacheSize() > nCoinCacheSize) ||
(mode == FLUSH_STATE_PERIODIC && GetTimeMicros() > nLastWrite + DATABASE_WRITE_INTERVAL * 1000000)) { (mode == FLUSH_STATE_PERIODIC && GetTimeMicros() > nLastWrite + DATABASE_WRITE_INTERVAL * 1000000)) {
@ -1845,6 +1846,9 @@ bool static FlushStateToDisk(CValidationState &state, FlushStateMode mode) {
} }
nLastWrite = GetTimeMicros(); nLastWrite = GetTimeMicros();
} }
} catch (const std::runtime_error& e) {
return state.Abort(std::string("System error while flushing: ") + e.what());
}
return true; return true;
} }