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

[791] Avoid Pearl Storage clone #792

Merged
merged 19 commits into from
May 15, 2023
Merged
Show file tree
Hide file tree
Changes from 16 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Bob versions changelog
- Build release binaries and docker images with `release-lto` profile (#714)
- Use read lock instead of write on hierarchical filters update to improve performance (#596)
- Abort on panic in any of the threads (#782)
- Avoid Pearl Storage clone (#791)

#### Fixed
- Fix incorrect exist result due to variables sharing between keys (#762)
Expand Down
12 changes: 3 additions & 9 deletions bob-backend/src/pearl/disk_controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -574,16 +574,10 @@ impl DiskController {
let holders = group.holders();
let holders = holders.read().await;
for holder in holders.iter() {
let storage = holder.storage().read().await;
let storage = storage.storage().clone();
let id = holder.get_id();
let holder = holder.clone();
futures.push(async move {
match storage.close().await {
Ok(_) => debug!("holder {} closed", id),
Err(e) => {
error!("error closing holder{}: {} (disk: {:?})", id, e, self.disk)
}
}
holder.close_storage().await;
debug!("holder {} closed", holder.get_id());
});
}
}
Expand Down
28 changes: 18 additions & 10 deletions bob-backend/src/pearl/group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ impl Group {

pub async fn remount(&self, pp: impl Hooks) -> AnyResult<()> {
let _reinit_lock = self.reinit_lock.write().await;
self.holders.write().await.clear();
let cleared = self.holders.write().await.clear_and_get_values();
close_holders(cleared.iter()).await; // Close old holders
std::mem::drop(cleared); // This is to guarantee, that all resources will be released
self.run_under_reinit_lock(pp).await
}

Expand Down Expand Up @@ -223,9 +225,11 @@ impl Group {
// holder but instead try to restart the whole disk
if !e.is_possible_disk_disconnection() && !e.is_duplicate() && !e.is_not_ready() {
error!("pearl holder will restart: {:?}", e);
holder.try_reinit().await?;
holder.prepare_storage().await?;
debug!("backend pearl group put common storage prepared");
if let Err(err) = holder.try_reinit().await {
warn!("Pearl backend holder reinit ended with error: {:?}", err);
} else {
debug!("Pearl backend holder reinited");
}
}
Err(e)
} else {
Expand Down Expand Up @@ -288,9 +292,11 @@ impl Group {
let result = holder.read(key).await;
if let Err(e) = &result {
if !e.is_key_not_found() && !e.is_not_ready() {
holder.try_reinit().await?;
holder.prepare_storage().await?;
debug!("backend pearl group get common storage prepared");
if let Err(err) = holder.try_reinit().await {
warn!("Pearl backend holder reinit ended with error: {:?}", err);
} else {
debug!("Pearl backend holder reinited");
}
}
}
result
Expand Down Expand Up @@ -400,9 +406,11 @@ impl Group {
// holder but instead try to restart the whole disk
if !e.is_possible_disk_disconnection() && !e.is_duplicate() && !e.is_not_ready() {
error!("pearl holder will restart: {:?}", e);
holder.try_reinit().await?;
holder.prepare_storage().await?;
debug!("backend::pearl::group::delete_common storage prepared");
if let Err(err) = holder.try_reinit().await {
warn!("Pearl backend holder reinit ended with error: {:?}", err);
} else {
debug!("Pearl backend holder reinited");
}
}
Err(e)
} else {
Expand Down
Loading