Skip to content

Commit

Permalink
Catch LevelDB errors during flush
Browse files Browse the repository at this point in the history
Rebased-From: e413457
Github-Pull: #5597
  • Loading branch information
sipa authored and laanwj committed Jan 7, 2015
1 parent 008138c commit 867c600
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1805,6 +1805,7 @@ enum FlushStateMode {
bool static FlushStateToDisk(CValidationState &state, FlushStateMode mode) {
LOCK(cs_main);
static int64_t nLastWrite = 0;
try {
if ((mode == FLUSH_STATE_ALWAYS) ||
((mode == FLUSH_STATE_PERIODIC || mode == FLUSH_STATE_IF_NEEDED) && pcoinsTip->GetCacheSize() > nCoinCacheSize) ||
(mode == FLUSH_STATE_PERIODIC && GetTimeMicros() > nLastWrite + DATABASE_WRITE_INTERVAL * 1000000)) {
Expand Down Expand Up @@ -1845,6 +1846,9 @@ bool static FlushStateToDisk(CValidationState &state, FlushStateMode mode) {
}
nLastWrite = GetTimeMicros();
}
} catch (const std::runtime_error& e) {
return state.Abort(std::string("System error while flushing: ") + e.what());
}
return true;
}

Expand Down

0 comments on commit 867c600

Please sign in to comment.