mirror of
https://github.com/openai/codex.git
synced 2026-11-08 00:36:31 +00:00
fix: Auto-recover from corrupted sqlite databases (#26859)
Further investigation of the sqlite incidents showed that the problems are due to corruption from the older version of SQLite that we recently upgraded, and that the data is truly corrupted in the root database -- recovery of all data is not possible. Given that the data is reconstructable from the rollouts on disk, we should just auto-backup the database and let codex rebuild the rollout info from the disk rollouts. The new behavior is that appserver auto-backs-up and rebuilds (with logs reflecting that behavior). The CLI now pops a message letting you know this happened and the paths of the backed-up corrupt db and the new database. There is also context added so that the desktop app can read the rebuild info from it and inform the user with it.
This commit is contained in:
1 parent
a19d43a40a
commit
3691fe5b76
13 files changed
+693
-139
No files matched your search
@@ -3,24 +3,28 @@ use std::path::PathBuf;
|
||||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
#[error(
|
||||
"failed to initialize sqlite state db at {}: {detail}",
|
||||
state_db_path.display()
|
||||
"failed to initialize sqlite local db at {}: {detail}",
|
||||
database_path.display()
|
||||
)]
|
||||
pub struct LocalStateDbStartupError {
|
||||
state_db_path: PathBuf,
|
||||
database_path: PathBuf,
|
||||
detail: String,
|
||||
}
|
||||
|
||||
impl LocalStateDbStartupError {
|
||||
pub fn new(state_db_path: PathBuf, detail: String) -> Self {
|
||||
pub fn new(database_path: PathBuf, detail: String) -> Self {
|
||||
Self {
|
||||
state_db_path,
|
||||
database_path,
|
||||
detail,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn database_path(&self) -> &Path {
|
||||
self.database_path.as_path()
|
||||
}
|
||||
|
||||
pub fn state_db_path(&self) -> &Path {
|
||||
self.state_db_path.as_path()
|
||||
self.database_path()
|
||||
}
|
||||
|
||||
pub fn detail(&self) -> &str {
|
||||
|
||||
Reference in new issue
Block a user