You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When rust-s3 is used with tokio and in a concurrent setup, refreshing the credentials will result in a read or write race condition for the corresponding lock.
To Reproduce
Just make some concurrent requests read requests:
// cargo run --example tokio
use awscreds::Credentials;
use s3::error::S3Error;
use s3::{Bucket, Region};
#[tokio::main]
async fn main() -> Result<(), S3Error> {
let bucket = Bucket::new(
"rust-s3-test",
"eu-central-1".parse()?,
// Credentials are collected from environment, config, profile or instance metadata
Credentials::default()?,
)?;
let s3_path = "test.file";
let test = b"I'm going to S3!";
let response_data = bucket.put_object(s3_path, test).await?;
assert_eq!(response_data.status_code(), 200);
for _ in 0..200 {
let b = bucket.clone();
tokio::spawn(async move {
let response_data = b.get_object(s3_path).await;
if let Err(e) = response_data {
eprintln!("{}", e);
}
});
}
Ok(())
}
About 1 % of the requests result in a write error
Could not get Write lock on Credentials
About 0,5 % of the requests result in a read error
a-nickol
changed the title
Write and Read Lock of Credentials does not use tokio api
Bucket - Write and Read Lock for Credentials does not work well with tokioApr 18, 2023
a-nickol
changed the title
Bucket - Write and Read Lock for Credentials does not work well with tokio
Bucket - write and read lock for credentials does not work well with tokioApr 18, 2023
Describe the bug
When
rust-s3
is used withtokio
and in a concurrent setup, refreshing the credentials will result in a read or write race condition for the corresponding lock.The credentials just use the system
RwLock
.To Reproduce
Just make some concurrent requests read requests:
About 1 % of the requests result in a write error
About 0,5 % of the requests result in a read error
Expected behavior
No error should occur.
Environment
Possible Solution
The method should be
async
and bucket should usetokio::sync::RwLock
whentokio
is used.The text was updated successfully, but these errors were encountered: