Skip to content

Commit

Permalink
Handle rocksdb error during size estimate
Browse files Browse the repository at this point in the history
Signed-off-by: Simon Dudley <[email protected]>
  • Loading branch information
siladu committed Jan 31, 2024
1 parent ec36a1e commit fee97ba
Showing 1 changed file with 17 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -174,19 +174,24 @@ private long estimatedSizeOfTrieLogs() {
.concat(DATABASE_PATH);

AtomicLong estimatedSaving = new AtomicLong(0L);
RocksDbHelper.forEachColumnFamily(
dbPath,
(rocksdb, cfHandle) -> {
try {
if (Arrays.equals(cfHandle.getName(), TRIE_LOG_STORAGE.getId())) {
estimatedSaving.set(
Long.parseLong(
rocksdb.getProperty(cfHandle, "rocksdb.estimate-live-data-size")));
try {
RocksDbHelper.forEachColumnFamily(
dbPath,
(rocksdb, cfHandle) -> {
try {
if (Arrays.equals(cfHandle.getName(), TRIE_LOG_STORAGE.getId())) {
estimatedSaving.set(
Long.parseLong(
rocksdb.getProperty(cfHandle, "rocksdb.estimate-live-data-size")));

Check notice

Code scanning / CodeQL

Missing catch of NumberFormatException Note

Potential uncaught 'java.lang.NumberFormatException'.
}
} catch (RocksDBException e) {
throw new RuntimeException(e);
}
} catch (RocksDBException e) {
throw new RuntimeException(e);
}
});
});
} catch (Exception e) {
LOG.warn("Error while estimating trie log size, returning 0 for estimate", e);
return 0L;
}

return estimatedSaving.get();
}
Expand Down

0 comments on commit fee97ba

Please sign in to comment.