Fix inconsistent SE state due to incorrect propagation

next
Sayan Nandan 10 months ago
parent 4ba7b97ac7
commit 3e49971efc
No known key found for this signature in database
GPG Key ID: 42EEDF4AE9D96B54

@ -125,13 +125,16 @@ impl<Fs: RawFSInterface> DataBatchPersistDriver<Fs> {
};
match exec() {
Ok(()) => Ok(()),
Err(_) => {
Err(e) => {
// republish changes since we failed to commit
restore_list.into_iter().for_each(|delta| {
model.delta_state().append_new_data_delta(delta, &g);
});
// now attempt to fix the file
return self.attempt_fix_data_batchfile();
self.attempt_fix_data_batchfile()?;
// IMPORTANT: return an error because even though we recovered the journal we still didn't succeed in
// writing the batch
return Err(e);
}
}
}

@ -142,8 +142,8 @@ pub struct GenericDictSpec;
/// generic dict entry metadata
pub struct GenericDictEntryMD {
pub(crate) dscr: u8,
pub(crate) klen: usize,
pub(crate) dscr: u8,
}
impl GenericDictEntryMD {

@ -402,7 +402,11 @@ impl<Fs: RawFSInterface, TA: JournalAdapter> JournalWriter<Fs, TA> {
debug_assert!(TA::RECOVERY_PLUGIN);
match self.append_event(event) {
Ok(()) => Ok(()),
Err(_) => compiler::cold_call(|| return self.appendrec_journal_reverse_entry()),
Err(e) => compiler::cold_call(move || {
// IMPORTANT: we still need to return an error so that the caller can retry if deemed appropriate
self.appendrec_journal_reverse_entry()?;
Err(e)
}),
}
}
}

@ -47,7 +47,7 @@ pub const fn unlikely(b: bool) -> bool {
#[cold]
#[inline(never)]
pub fn cold_call<U>(mut v: impl FnMut() -> U) -> U {
pub fn cold_call<U>(v: impl FnOnce() -> U) -> U {
v()
}

Loading…
Cancel
Save