Skip to content

Commit

Permalink
Add failing proptest
Browse files Browse the repository at this point in the history
Adds a failing proptest, which occured as we did not remove inflight writes to a file, if it was overriden by a PutObject. Fixes this by invalidating such writes.
Signed-off-by: Christian Hagemeier <[email protected]>
  • Loading branch information
c-hagem committed Jan 15, 2025
1 parent 456c7de commit fc69723
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion mountpoint-s3/tests/reftests/harness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ impl InflightWrites {
let index = self.index(index).unwrap();
self.writes.remove(index)
}

fn invalidate(&mut self, path: PathBuf) {
self.writes.retain(|write| write.path != path);
}
}

#[derive(Debug)]
Expand Down Expand Up @@ -576,7 +580,11 @@ impl Harness {
self.client.add_object(&key, object.clone());
self.reference.add_remote_key(&key, object);
// Any local directories along the path are made remote by adding this object
self.reference.remove_local_parents(key_as_path);
self.reference.remove_local_parents(key_as_path.clone());
// If we overwrite a file that is currently part of an inflight write
// we have to remove that inflight write, as otherwise we fail when opening the
// ino to continue writing.
self.inflight_writes.invalidate(key_as_path);
}

/// Perform a DeleteObject on the bucket, to simulate concurrent access to the bucket by a
Expand Down Expand Up @@ -1330,4 +1338,25 @@ mod mutations {
0,
)
}

#[test]
fn regression_stale_ino() {
run_test(
TreeNode::Directory(BTreeMap::from([])),
vec![
Op::CreateFile(
ValidName("a".into()),
DirectoryIndex(0),
FileContent(0, FileSize::Small(0)),
),
Op::PutObject(
DirectoryIndex(0),
Name("a/a".into()),
FileContent(0, FileSize::Small(0)),
),
Op::FinishWrite(InflightWriteIndex(0)),
],
0,
);
}
}

0 comments on commit fc69723

Please sign in to comment.