mirror of
https://github.com/narrrl/proton-drive-linux.git
synced 2026-11-03 16:41:26 +01:00
fix(fuse): changes that failed on a short outage go out once the link is back (B189)
This commit is contained in:
1 parent
b47620651f
commit
f0a43fb923
5 files changed
+73
-4
No files matched your search
@@ -432,6 +432,13 @@ impl Core {
|
||||
{
|
||||
debug!(uid = %op.uid, error = %e, "waking the ops waiting for a name failed");
|
||||
}
|
||||
// A drain that cannot reach Drive has lost the link as surely as
|
||||
// a syscall that cannot. Unmarked, a short outage only the drain
|
||||
// met had no probe to see the link return, and the op sat out
|
||||
// its backoff long after (`docs/BUGS.md` B189).
|
||||
if let Some(proton) = proton_error(e.as_ref()) {
|
||||
self.lost_link(proton, "drain");
|
||||
}
|
||||
// A failure to reach Drive says nothing about an earlier refusal,
|
||||
// so it keeps the issue that refusal recorded.
|
||||
if let Some(issue) = refusal(e.as_ref()) {
|
||||
@@ -2654,12 +2661,16 @@ fn moved_elsewhere(meta: &RenameMeta, node: &Node, parent: &NodeUid, name: &str)
|
||||
!at(&meta.original_parent_uid, original_name) && !at(&parent.to_string(), name)
|
||||
}
|
||||
|
||||
/// The answer from Drive somewhere in `e`'s chain, if it got that far.
|
||||
fn proton_error<'e>(e: &'e (dyn std::error::Error + 'static)) -> Option<&'e ProtonError> {
|
||||
std::iter::successors(Some(e), |e| e.source()).find_map(|e| e.downcast_ref::<ProtonError>())
|
||||
}
|
||||
|
||||
/// What a failed attempt says about its op's sync issue: `None` when Drive
|
||||
/// could not be reached, which says nothing; otherwise the issue Drive's answer
|
||||
/// is, or `Some(None)` for a failure that is not a refusal.
|
||||
fn refusal(e: &(dyn std::error::Error + 'static)) -> Option<Option<SyncIssue>> {
|
||||
let proton = std::iter::successors(Some(e), |e| e.source())
|
||||
.find_map(|e| e.downcast_ref::<ProtonError>())?;
|
||||
let proton = proton_error(e)?;
|
||||
if is_network_error(proton) {
|
||||
return None;
|
||||
}
|
||||
|
||||
@@ -476,6 +476,42 @@ mod tests {
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "mounts FUSE: run with `cargo test -p pdfs-fuse sim:: -- --ignored`"]
|
||||
fn a_write_that_failed_on_a_short_outage_goes_out_soon_after_the_link_returns() {
|
||||
// Only the drain met the outage, and it never took the mount offline:
|
||||
// no probe saw the link come back, and the write sat out its backoff
|
||||
// (B189).
|
||||
let drive = FakeDrive::new();
|
||||
let dir = scratch("short-outage");
|
||||
let daemon = Daemon::start(&dir, drive.client(1, Faults::lan())).unwrap();
|
||||
std::fs::write(daemon.mountpoint.join("g.txt"), b"g").unwrap();
|
||||
assert!(wait_until(Duration::from_secs(30), || {
|
||||
daemon.pending().is_ok_and(|items| items.is_empty()) && drive.tree().len() == 1
|
||||
}));
|
||||
|
||||
daemon.client.set_online(false);
|
||||
std::fs::write(daemon.mountpoint.join("f.txt"), b"0123456789").unwrap();
|
||||
assert!(wait_until(Duration::from_secs(30), || {
|
||||
daemon
|
||||
.pending()
|
||||
.is_ok_and(|items| items.iter().any(|item| item.attempts > 0))
|
||||
}));
|
||||
daemon.client.set_online(true);
|
||||
assert!(
|
||||
wait_until(Duration::from_secs(3), || {
|
||||
daemon.pending().is_ok_and(|items| items.is_empty())
|
||||
&& drive.tree().get("f.txt")
|
||||
== Some(&Entry::File(Arc::new(b"0123456789".to_vec())))
|
||||
}),
|
||||
"{:?}",
|
||||
daemon.pending()
|
||||
);
|
||||
|
||||
assert!(matches!(daemon.stop(), Ok(MountOutcome::Shutdown)));
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "mounts FUSE: run with `cargo test -p pdfs-fuse sim:: -- --ignored`"]
|
||||
fn a_restart_does_not_bring_back_the_write_of_a_file_deleted_while_open() {
|
||||
|
||||
Reference in new issue
Block a user