diff options
author | Alex Auvolat <alex@adnab.me> | 2021-02-23 21:27:28 +0100 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2021-02-23 21:27:28 +0100 |
commit | 20e6e9fa2035ac12946bf0dcd5b8049090955bde (patch) | |
tree | 96c9a1a72833b16672b69e588c625248f9b40857 /src/rpc | |
parent | bf25c95fe2fda4ded2e3ca14499e3991e7243532 (diff) | |
download | garage-20e6e9fa2035ac12946bf0dcd5b8049090955bde.tar.gz garage-20e6e9fa2035ac12946bf0dcd5b8049090955bde.zip |
Update sled & try to debug deadlock (but its in sled...)
Diffstat (limited to 'src/rpc')
-rw-r--r-- | src/rpc/rpc_client.rs | 3 | ||||
-rw-r--r-- | src/rpc/rpc_server.rs | 17 |
2 files changed, 18 insertions, 2 deletions
diff --git a/src/rpc/rpc_client.rs b/src/rpc/rpc_client.rs index 5183bb4b..70384391 100644 --- a/src/rpc/rpc_client.rs +++ b/src/rpc/rpc_client.rs @@ -310,7 +310,9 @@ impl RpcHttpClient { ClientMethod::HTTPS(client) => client.request(req).fuse(), }; + trace!("({}) Acquiring request_limiter slot...", path); let slot = self.request_limiter.acquire().await; + trace!("({}) Got slot, doing request to {}...", path, to_addr); let resp = tokio::time::timeout(timeout, resp_fut) .await .map_err(|e| { @@ -330,6 +332,7 @@ impl RpcHttpClient { })?; let status = resp.status(); + trace!("({}) Request returned, got status {}", path, status); let body = hyper::body::to_bytes(resp.into_body()).await?; drop(slot); diff --git a/src/rpc/rpc_server.rs b/src/rpc/rpc_server.rs index 4113f15b..1c6bc8d2 100644 --- a/src/rpc/rpc_server.rs +++ b/src/rpc/rpc_server.rs @@ -48,6 +48,12 @@ where let begin_time = Instant::now(); let whole_body = hyper::body::to_bytes(req.into_body()).await?; let msg = rmp_serde::decode::from_read::<_, M>(whole_body.into_buf())?; + + trace!( + "Request message: {}", + serde_json::to_string(&msg).unwrap_or("<json error>".into()) + ); + match handler(msg, sockaddr).await { Ok(resp) => { let resp_bytes = rmp_to_vec_all_named::<Result<M, String>>(&Ok(resp))?; @@ -112,7 +118,8 @@ impl RpcServer { return Ok(bad_request); } - let path = &req.uri().path()[1..]; + let path = &req.uri().path()[1..].to_string(); + let handler = match self.handlers.get(path) { Some(h) => h, None => { @@ -122,6 +129,8 @@ impl RpcServer { } }; + trace!("({}) Handling request", path); + let resp_waiter = tokio::spawn(handler(req, addr)); match resp_waiter.await { Err(err) => { @@ -131,11 +140,15 @@ impl RpcServer { Ok(ise) } Ok(Err(err)) => { + trace!("({}) Request handler failed: {}", path, err); let mut bad_request = Response::new(Body::from(format!("{}", err))); *bad_request.status_mut() = StatusCode::BAD_REQUEST; Ok(bad_request) } - Ok(Ok(resp)) => Ok(resp), + Ok(Ok(resp)) => { + trace!("({}) Request handler succeeded", path); + Ok(resp) + } } } |