Harden RocksDB snapshot error handling.#9770
Conversation
| } catch (IOException | RocksDBException exception) { | ||
| // TODO: [SNAPSHOT] Fail gracefully. | ||
| throw new RuntimeException(exception); | ||
| throw SnapshotStorageException.fromRocksDB("append list entry", toRocks(exception)); |
There was a problem hiding this comment.
nit: 'append' -> 'Append' to be consistent with other messages.
| } catch (IOException | RocksDBException exception) { | ||
| // TODO: [SNAPSHOT] Fail gracefully. | ||
| throw new RuntimeException(exception); | ||
| throw SnapshotStorageException.fromRocksDB("read list entry", toRocks(exception)); |
| } catch (IOException exception) { | ||
| // TODO: [SNAPSHOT] Fail gracefully. | ||
| throw new RuntimeException(exception); | ||
| throw SnapshotStorageException.fromIO("deserialize list entry", exception); |
There was a problem hiding this comment.
nit: 'deserialize' -> 'Failed to deserialize'
| } catch (IOException | RocksDBException exception) { | ||
| // TODO: [SNAPSHOT] Fail gracefully. | ||
| throw new RuntimeException(exception); | ||
| throw SnapshotStorageException.fromRocksDB("read map entry", toRocks(exception)); |
| } catch (IOException | RocksDBException exception) { | ||
| // TODO: [SNAPSHOT] Fail gracefully. | ||
| throw new RuntimeException(exception); | ||
| throw SnapshotStorageException.fromRocksDB("write map entry", toRocks(exception)); |
| } catch (IOException | RocksDBException exception) { | ||
| // TODO: [SNAPSHOT] Fail gracefully. | ||
| throw new RuntimeException(exception); | ||
| throw SnapshotStorageException.fromRocksDB("delete map entry", toRocks(exception)); |
There was a problem hiding this comment.
nit: 'delete' -> 'Failed to delete'
| throw new RuntimeException(exception); | ||
| } | ||
| } catch (IOException exception) { | ||
| throw SnapshotStorageException.fromIO("deserialize map entry", exception); |
There was a problem hiding this comment.
'deserialize' -> 'Failed to deserialize'
| }; | ||
| } | ||
|
|
||
| private RocksDBException toRocks(Exception e) { |
There was a problem hiding this comment.
code duplication, should be moved to the Utility class.
| } catch (IOException | RocksDBException exception) { | ||
| // TODO: [SNAPSHOT] Fail gracefully. | ||
| throw new RuntimeException(exception); | ||
| throw SnapshotStorageException.fromRocksDB("add set entry", toRocks(exception)); |
| } catch (IOException exception) { | ||
| // TODO: [SNAPSHOT] Fail gracefully. | ||
| throw new RuntimeException(exception); | ||
| throw SnapshotStorageException.fromIO("deserialize set entry", exception); |
There was a problem hiding this comment.
'deserialize' -> 'Failed to deserialize'
| }; | ||
| } | ||
|
|
||
| private RocksDBException toRocks(Exception e) { |
There was a problem hiding this comment.
duplicated code, should be moved to the utility class
|
|
||
| public static SnapshotStorageException fromRocksDB(String op, | ||
| RocksDBException e) { | ||
| return new SnapshotStorageException("Failed to " + op, |
There was a problem hiding this comment.
adding prefix to the message inside ctor would prevent developers from grepping the message in code.
|
|
||
| public static SnapshotStorageException fromIO(String op, | ||
| java.io.IOException e) { | ||
| return new SnapshotStorageException("Failed to " + op, |
There was a problem hiding this comment.
adding prefix to the message inside ctor would prevent developers from grepping the message in code.
Summary
Testing