Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/signer-db-open-error.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The signer now exits with an error naming the problem when it cannot open its database, for example one written by a newer release, instead of panicking.
10 changes: 10 additions & 0 deletions stacks-signer/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ use stacks_signer::cli::{
};
use stacks_signer::config::GlobalConfig;
use stacks_signer::monitor_signers::SignerMonitor;
use stacks_signer::signerdb::SignerDb;
use stacks_signer::utils::stackerdb_session;
use stacks_signer::v0::SpawnedSigner;
use tracing_subscriber::prelude::*;
Expand Down Expand Up @@ -115,6 +116,15 @@ fn handle_put_chunk(args: PutChunkArgs) {
fn handle_run(args: RunSignerArgs) {
debug!("Running signer...");
let config = GlobalConfig::try_from(&args.config).unwrap();
// Open (and migrate) the signer db before starting, so a db this release cannot use stops
// the signer with an error instead of a panic, possibly in a signer thread.
if let Err(e) = SignerDb::new(&config.db_path) {
error!(
"Failed to open the signer db at {}: {e}",
config.db_path.display()
);
std::process::exit(1);
}
let spawned_signer = SpawnedSigner::new(config);
println!("Signer spawned successfully. Waiting for messages to process...");
// Wait for the spawned signer to stop (will only occur if an error occurs)
Expand Down
2 changes: 1 addition & 1 deletion stacks-signer/src/signerdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1840,7 +1840,7 @@ impl SignerDb {
std::cmp::Ordering::Greater => {
sql_tx.rollback()?;
return Err(DBError::Other(format!(
"Database schema is newer than SCHEMA_VERSION. SCHEMA_VERSION = {}, Current version = {}. Did you forget to update SCHEMA_VERSION?",
"Database schema is newer than SCHEMA_VERSION. SCHEMA_VERSION = {}, Current version = {}. The database was likely written by a newer signer release; downgrading is not supported. Run a newer release or use a different db_path.",
Self::SCHEMA_VERSION, current_db_version
)));
}
Expand Down
Loading