Skip to content

Commit

Permalink
fix(iroh): do not shut down node on internal rpc error (#2158)
Browse files Browse the repository at this point in the history
## Description

fix(iroh): do not shut down node on internal rpc error

Internal rpc errors can happen, e.g. when the client side gets dropped.
No reason to shut down the entire node. We already have a cancellation
token, so it's not like we rely on this for shutdown.

Fixes #2157, #2143

## Notes & open questions

Note: I also sneaked in a fix for #2143. Basically when we are unable to
notify the db that a new gc epoch has started, we just shot down the gc
loop, since clearly the store is not well (probably shut down).

## Change checklist

- [x] Self-review.
- [x] Documentation updates if relevant.
- [x] Tests if relevant.
  • Loading branch information
rklaehn authored Apr 8, 2024
1 parent fb4703a commit fcdc299
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
5 changes: 4 additions & 1 deletion iroh-bytes/src/store/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,10 @@ pub trait Store: ReadableStore + MapMut {
/// Create a temporary pin for this store
fn temp_tag(&self, value: HashAndFormat) -> TempTag;

/// Notify the store that a new gc phase is about to start
/// Notify the store that a new gc phase is about to start.
///
/// This should not fail unless the store is shut down or otherwise in a
/// bad state. The gc task will shut itself down if this fails.
fn gc_start(&self) -> impl Future<Output = io::Result<()>> + Send;

/// Traverse all roots recursively and mark them as live.
Expand Down
11 changes: 6 additions & 5 deletions iroh/src/node/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -484,9 +484,8 @@ where
Ok((msg, chan)) => {
handler.handle_rpc_request(msg, chan);
}
Err(_) => {
info!("last controller dropped, shutting down");
break;
Err(e) => {
info!("internal rpc request error: {:?}", e);
}
}
},
Expand Down Expand Up @@ -537,8 +536,10 @@ where
tracing::debug!("GC loop starting {:?}", gc_period);
'outer: loop {
if let Err(cause) = db.gc_start().await {
tracing::error!("Error {} starting GC, skipping GC to be safe", cause);
continue 'outer;
tracing::debug!(
"unable to notify the db of GC start: {cause}. Shutting down GC loop."
);
break;
}
// do delay before the two phases of GC
tokio::time::sleep(gc_period).await;
Expand Down

0 comments on commit fcdc299

Please sign in to comment.