From 48af7599a72c886880f5c8cb1d979c479f190cb5 Mon Sep 17 00:00:00 2001 From: Dzmitry Kalabuk Date: Tue, 19 May 2026 17:22:20 +0200 Subject: [PATCH] Log the details of unexpected errors --- Cargo.lock | 24 ++++++++---------------- crates/hotblocks/src/api.rs | 24 +++++++++++++++++------- crates/storage/Cargo.toml | 2 +- 3 files changed, 26 insertions(+), 24 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fbbe11f..e3fb312 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -889,16 +889,14 @@ checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" [[package]] name = "bindgen" -version = "0.69.5" +version = "0.72.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "271383c67ccabffb7381723dea0672a673f292304fcb45c01cc648c7a8d58088" +checksum = "993776b509cfb49c750f11b8f07a46fa23e0a1386ffc01fb1e7d343efc387895" dependencies = [ "bitflags 2.8.0", "cexpr", "clang-sys", "itertools 0.12.1", - "lazy_static", - "lazycell", "proc-macro2", "quote", "regex", @@ -2600,12 +2598,6 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" -[[package]] -name = "lazycell" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" - [[package]] name = "lexical-core" version = "1.0.5" @@ -2694,9 +2686,9 @@ checksum = "8355be11b20d696c8f18f6cc018c4e372165b1fa8126cef092399c9951984ffa" [[package]] name = "librocksdb-sys" -version = "0.17.1+9.9.3" +version = "0.17.3+10.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b7869a512ae9982f4d46ba482c2a304f1efd80c6412a3d4bf57bb79a619679f" +checksum = "cef2a00ee60fe526157c9023edab23943fae1ce2ab6f4abb2a807c1746835de9" dependencies = [ "bindgen", "bzip2-sys", @@ -4214,9 +4206,9 @@ dependencies = [ [[package]] name = "rocksdb" -version = "0.23.0" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26ec73b20525cb235bad420f911473b69f9fe27cc856c5461bccd7e4af037f43" +checksum = "ddb7af00d2b17dbd07d82c0063e25411959748ff03e8d4f96134c2ff41fce34f" dependencies = [ "libc", "librocksdb-sys", @@ -4260,9 +4252,9 @@ checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" [[package]] name = "rustc-hash" -version = "1.1.0" +version = "2.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" +checksum = "94300abf3f1ae2e2b8ffb7b58043de3d399c73fa6f4b73826402a5c457614dbe" [[package]] name = "rustc_version" diff --git a/crates/hotblocks/src/api.rs b/crates/hotblocks/src/api.rs index 5d40942..a0f9626 100644 --- a/crates/hotblocks/src/api.rs +++ b/crates/hotblocks/src/api.rs @@ -186,9 +186,9 @@ async fn stream( Extension(app): Extension, Extension(client_id): Extension, Path(dataset_id): Path, - Json(query): Json, + body: Bytes, ) -> impl IntoResponse { - let response = stream_internal(app, dataset_id, query, false, client_id.clone()).await; + let response = stream_internal(app, dataset_id, body, false, client_id.clone()).await; ResponseWithMetadata::new() .with_client_id(&client_id) .with_dataset_id(dataset_id) @@ -200,9 +200,9 @@ async fn finalized_stream( Extension(app): Extension, Extension(client_id): Extension, Path(dataset_id): Path, - Json(query): Json, + body: Bytes, ) -> impl IntoResponse { - let response = stream_internal(app, dataset_id, query, true, client_id.clone()).await; + let response = stream_internal(app, dataset_id, body, true, client_id.clone()).await; ResponseWithMetadata::new() .with_client_id(&client_id) .with_dataset_id(dataset_id) @@ -213,12 +213,17 @@ async fn finalized_stream( async fn stream_internal( app: AppRef, dataset_id: DatasetId, - query: Query, + body: Bytes, finalized: bool, client_id: ClientId, ) -> Response { let dataset = get_dataset!(app, dataset_id); + let query: Query = match Json::::from_bytes(&body) { + Ok(Json(q)) => q, + Err(rejection) => return rejection.into_response(), + }; + if let Err(err) = query.validate() { return text!(StatusCode::BAD_REQUEST, "{}", err); } @@ -258,7 +263,7 @@ async fn stream_internal( res.body(body).unwrap() } - Err(err) => error_to_response(err), + Err(err) => error_to_response(err, &body), } } @@ -285,7 +290,7 @@ fn stream_query_response( } } -fn error_to_response(err: anyhow::Error) -> Response { +fn error_to_response(err: anyhow::Error, body: &Bytes) -> Response { if let Some(above_the_head) = err.downcast_ref::() { let mut res = Response::builder().status(204); if let Some(head) = above_the_head.finalized_head.as_ref() { @@ -316,6 +321,11 @@ fn error_to_response(err: anyhow::Error) -> Response { } else if err.is::() { StatusCode::SERVICE_UNAVAILABLE } else { + error!( + err = ?err, + query = %String::from_utf8_lossy(body), + "unhandled error, returning 500" + ); StatusCode::INTERNAL_SERVER_ERROR }; diff --git a/crates/storage/Cargo.toml b/crates/storage/Cargo.toml index 4e87652..f2f6f74 100644 --- a/crates/storage/Cargo.toml +++ b/crates/storage/Cargo.toml @@ -10,7 +10,7 @@ arrow-buffer = { workspace = true } borsh = { workspace = true } parking_lot = { workspace = true } rayon = { workspace = true } -rocksdb = { version = "0.23.0", features = ["jemalloc"] } +rocksdb = { version = "0.24.0", features = ["jemalloc"] } uuid = { workspace = true, features = ["v7", "borsh"] } sqd-array = { path = "../array" } sqd-primitives = { path = "../primitives", features = ["borsh", "sid", "range"] }