Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: get_ranges is not spawned in io-runtime #1426

Merged
merged 2 commits into from
Jan 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 66 additions & 6 deletions components/object_store/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,16 @@ impl ObjectStore for StoreWithMetrics {
OBJECT_STORE_THROUGHPUT_HISTOGRAM
.put
.observe(bytes.len() as f64);
self.store.put(location, bytes).await

let loc = location.clone();
let store = self.store.clone();
self.runtime
.spawn(async move { store.put(&loc, bytes).await })
.await
.map_err(|source| StoreError::Generic {
store: METRICS,
source: Box::new(source),
})?
}

async fn put_multipart(
Expand Down Expand Up @@ -228,11 +237,22 @@ impl ObjectStore for StoreWithMetrics {

async fn get_ranges(&self, location: &Path, ranges: &[Range<usize>]) -> Result<Vec<Bytes>> {
let _timer = OBJECT_STORE_DURATION_HISTOGRAM.get_ranges.start_timer();
let result = self.store.get_ranges(location, ranges).await?;
let store = self.store.clone();
let loc = location.clone();
let ranges = ranges.to_vec();
let result = self
.runtime
.spawn(async move { store.get_ranges(&loc, &ranges).await })
ShiKaiWi marked this conversation as resolved.
Show resolved Hide resolved
.await
.map_err(|e| StoreError::Generic {
store: METRICS,
source: Box::new(e),
})??;
let len: usize = result.iter().map(|v| v.len()).sum();
OBJECT_STORE_THROUGHPUT_HISTOGRAM
.get_ranges
.observe(len as f64);

Ok(result)
}

Expand Down Expand Up @@ -286,25 +306,65 @@ impl ObjectStore for StoreWithMetrics {

async fn copy(&self, from: &Path, to: &Path) -> Result<()> {
let _timer = OBJECT_STORE_DURATION_HISTOGRAM.copy.start_timer();
self.store.copy(from, to).await

let store = self.store.clone();
let from = from.clone();
let to = to.clone();
self.runtime
.spawn(async move { store.copy(&from, &to).await })
.await
.map_err(|source| StoreError::Generic {
store: METRICS,
source: Box::new(source),
})?
}

async fn rename(&self, from: &Path, to: &Path) -> Result<()> {
let _timer = OBJECT_STORE_DURATION_HISTOGRAM.rename.start_timer();
self.store.rename(from, to).await

let store = self.store.clone();
let from = from.clone();
let to = to.clone();
self.runtime
.spawn(async move { store.rename(&from, &to).await })
.await
.map_err(|source| StoreError::Generic {
store: METRICS,
source: Box::new(source),
})?
}

async fn copy_if_not_exists(&self, from: &Path, to: &Path) -> Result<()> {
let _timer = OBJECT_STORE_DURATION_HISTOGRAM
.copy_if_not_exists
.start_timer();
self.store.copy_if_not_exists(from, to).await

let store = self.store.clone();
let from = from.clone();
let to = to.clone();
self.runtime
.spawn(async move { store.copy_if_not_exists(&from, &to).await })
.await
.map_err(|source| StoreError::Generic {
store: METRICS,
source: Box::new(source),
})?
}

async fn rename_if_not_exists(&self, from: &Path, to: &Path) -> Result<()> {
let _timer = OBJECT_STORE_DURATION_HISTOGRAM
.rename_if_not_exists
.start_timer();
self.store.rename_if_not_exists(from, to).await

let store = self.store.clone();
let from = from.clone();
let to = to.clone();
self.runtime
.spawn(async move { store.rename_if_not_exists(&from, &to).await })
.await
.map_err(|source| StoreError::Generic {
store: METRICS,
source: Box::new(source),
})?
}
}
Loading