mirror of
https://github.com/Dasemu/Synapse.git
synced 2026-11-27 15:56:43 +00:00
fix(history): make restore_page and restore_graph atomic
Both run inside Graph::transaction so a failure halfway rolls every change back. Adds a fault-injection hook and a regression test. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3266ddda3a
commit
2b52144311
3 files changed
+145
-51
No files matched your search
@@ -79,6 +79,7 @@ pub struct History {
|
||||
opts: HistoryOptions,
|
||||
/// `(last seen graph seq, time we saw it change)` for idle detection.
|
||||
observed: Option<(i64, i64)>,
|
||||
pub(crate) fault: std::cell::Cell<Option<usize>>,
|
||||
}
|
||||
|
||||
impl History {
|
||||
@@ -95,9 +96,16 @@ impl History {
|
||||
dir,
|
||||
opts,
|
||||
observed: None,
|
||||
fault: Default::default(),
|
||||
})
|
||||
}
|
||||
|
||||
/// Test hook: make the next restore fail after `n` block writes/deletes.
|
||||
#[doc(hidden)]
|
||||
pub fn inject_restore_fault(&self, n: Option<usize>) {
|
||||
self.fault.set(n);
|
||||
}
|
||||
|
||||
pub fn dir(&self) -> &Path {
|
||||
&self.dir
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user