fix(usability): Improve the cache dir and database startup panics - #9441
Conversation
|
I did not fully validate the PR, but we should validate if the |
The |
I think its purpose was to ensure that those tests are never run unintentionally, but I agree it would make a bunch of things easier to drop it and we may want to do that. |
Co-authored-by: Arya <aryasolhi@gmail.com>
This #9481 (comment) is a good motivation to drop the variables. |
|
Also, the description in PR #9323. |
Motivation
Currently, Zebra will panic any time it can’t create or open its state database. For example, if the cache directory is invalid, the disk is full, permissions are wrong, or the RocksDB instance is already in use. The default panic messages are ugly and make it hard for end users to diagnose the real cause.
Close #8617
Solution
We now split these failures into two categories:
OS‑level errors (
std::io::ErrorKind) related to the cache directory:RocksDB errors (
rocksdb::ErrorKind) at the database-opening stage:In
DiskDB::new:Initialize the cache directory
Attempt to create or open the cache directory first, and convert any
std::io::ErrorKindinto a descriptive panic.Open the RocksDB database
Once the directory is validated, build the full DB path and open RocksDB, catching any
rocksdb::ErrorKindand panicking.This separation makes sure that each panic points more directly to its root cause and suggests an actionable hint.
Tests
PR Checklist
C-exclude-from-changeloglabel.