Skip to content

Commit 3ad935b

Browse files
authored
Workaround for s3 issue (#36)
* Workaround for s3 issue rfs can upload/download multiple files in parallel but it seems this s3 client can't handle this correctly so random issues appear during upload this trick is to force the store to do synched read/write but the problem is it hurts pefromance badly. Instead we should find a better client since this issue is too old (2018) https://github.com/awslabs/aws-sdk-rust/tree/main/sdk/s3 * Luckily updating the client to latest RC fixed the issue
1 parent ecccba9 commit 3ad935b

7 files changed

Lines changed: 112 additions & 93 deletions

File tree

Cargo.lock

Lines changed: 76 additions & 65 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ simple_logger = {version = "1.0.1", optional = true}
5151
daemonize = { version = "0.5", optional = true }
5252
tempfile = { version = "3.3.0", optional = true }
5353
workers = { git="https://github.com/threefoldtech/tokio-worker-pool.git" }
54-
rust-s3 = "0.33"
54+
rust-s3 = "0.34.0-rc3"
5555
openssl = { version = "0.10", features = ["vendored"] }
5656
regex = "1.9.6"
5757

src/fungi/meta.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ use std::{
55

66
use sqlx::{sqlite::SqliteRow, FromRow, Row, SqlitePool};
77

8+
use crate::store;
9+
810
const ID_LEN: usize = 32;
911
const KEY_LEN: usize = 32;
1012
const TYPE_MASK: u32 = nix::libc::S_IFMT;
@@ -41,7 +43,7 @@ static SCHEMA: &str = include_str!("../../schema/schema.sql");
4143

4244
#[derive(thiserror::Error, Debug)]
4345
pub enum Error {
44-
#[error("failed to execute query: {0:#}")]
46+
#[error("failed to execute query: {0}")]
4547
SqlError(#[from] sqlx::Error),
4648

4749
#[error("invalid hash length")]
@@ -53,7 +55,10 @@ pub enum Error {
5355
#[error("io error: {0:#}")]
5456
IO(#[from] std::io::Error),
5557

56-
#[error("{0:#}")]
58+
#[error("store error: {0}")]
59+
Store(#[from] store::Error),
60+
61+
#[error("unknown meta error: {0}")]
5762
Anyhow(#[from] anyhow::Error),
5863
}
5964

src/main.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,9 @@ struct PackOptions {
6969
#[clap(short, long, action=ArgAction::Append)]
7070
store: Vec<String>,
7171

72-
/// no_strip_password strips password from store url, otherwise password will be stored in the fl and then shipped.
73-
/// Some stores like ZDB has a public namespace which means writing requires a password
74-
#[clap(long, default_value_t = false)]
72+
/// no_strip_password strips password from store url, otherwise password will be stored in the fl and then shipped.
73+
/// Some stores like ZDB has a public namespace which means writing requires a password
74+
#[clap(long, default_value_t = false)]
7575
no_strip_password: bool,
7676

7777
/// target directory to upload
@@ -168,11 +168,11 @@ fn mount(opts: MountOptions) -> Result<()> {
168168
}
169169

170170
match daemon.execute() {
171-
daemonize::Outcome::Parent(Ok(_)) => {
171+
daemonize::Outcome::Parent(result) => {
172+
result.context("daemonize")?;
172173
wait_child(target, pid_file);
173174
return Ok(());
174175
}
175-
daemonize::Outcome::Parent(Err(err)) => anyhow::bail!("failed to daemonize: {}", err),
176176
_ => {}
177177
}
178178
}
@@ -203,11 +203,11 @@ fn wait_child(target: String, mut pid_file: tempfile::NamedTempFile) {
203203
}
204204
let mut buf = String::new();
205205
if let Err(e) = pid_file.read_to_string(&mut buf) {
206-
error!("failed to read pid_file: {}", e);
206+
error!("failed to read pid_file: {:#}", e);
207207
}
208208
let pid = buf.parse::<i32>();
209209
match pid {
210-
Err(e) => error!("failed to parse pid_file contents {}: {}", buf, e),
210+
Err(e) => error!("failed to parse pid_file contents {}: {:#}", buf, e),
211211
Ok(v) => {
212212
let _ = signal::kill(Pid::from_raw(v), Signal::SIGTERM);
213213
} // probably the child exited on its own

src/pack.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -210,11 +210,7 @@ where
210210
}
211211

212212
// write block to remote store
213-
let block = self
214-
.store
215-
.set(&self.buffer[..size])
216-
.await
217-
.context("failed to store blob")?;
213+
let block = self.store.set(&self.buffer[..size]).await?;
218214

219215
// write block info to meta
220216
self.writer.block(ino, &block.id, &block.key).await?;
@@ -233,6 +229,7 @@ where
233229
type Output = ();
234230

235231
async fn run(&mut self, (ino, path): Self::Input) -> Self::Output {
232+
log::info!("uploading {:?}", path);
236233
if let Err(err) = self.upload(ino, &path).await {
237234
log::error!("failed to upload file ({:?}): {:#}", path, err);
238235
}

0 commit comments

Comments
 (0)