Skip to content

Commit

Permalink
Merge pull request #5223 from halibobo1205/feat/remove_repair_for_lev…
Browse files Browse the repository at this point in the history
…ledb

feat(db): remove auto-repair for corrupted leveldb
  • Loading branch information
halibobo1205 authored May 25, 2023
2 parents ad1a1b3 + 8318708 commit 0803151
Showing 1 changed file with 5 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,22 +142,11 @@ private void openDatabase(Options dbOptions) throws IOException {
if (!Files.isSymbolicLink(dbPath.getParent())) {
Files.createDirectories(dbPath.getParent());
}
try {
database = factory.open(dbPath.toFile(), dbOptions);
if (!this.getDBName().startsWith("checkpoint")) {
logger.info("DB {} open success with writeBufferSize {} M, cacheSize {} M, maxOpenFiles {}.",
this.getDBName(), dbOptions.writeBufferSize() / 1024 / 1024,
dbOptions.cacheSize() / 1024 / 1024, dbOptions.maxOpenFiles());
}
} catch (IOException e) {
if (e.getMessage().contains("Corruption:")) {
logger.warn("DB {} corruption detected, try to repair it.", this.getDBName(), e);
factory.repair(dbPath.toFile(), dbOptions);
logger.warn("DB {} corruption detected, repair done.", this.getDBName());
database = factory.open(dbPath.toFile(), dbOptions);
} else {
throw e;
}
database = factory.open(dbPath.toFile(), dbOptions);
if (!this.getDBName().startsWith("checkpoint")) {
logger.info("DB {} open success with writeBufferSize {} M, cacheSize {} M, maxOpenFiles {}.",
this.getDBName(), dbOptions.writeBufferSize() / 1024 / 1024,
dbOptions.cacheSize() / 1024 / 1024, dbOptions.maxOpenFiles());
}
}

Expand Down

0 comments on commit 0803151

Please sign in to comment.