mirror of
https://github.com/scylladb/scylladb.git
synced 2026-05-12 19:02:12 +00:00
Fix multiple cases where the captured `std::exception_ptr` has been re-thrown via simple `throw eptr;`, which results in losing the original exception type and details. Resolved at various places found by clang-tidy: 1. db::schema_applier When applying schema changes, the previous implementation attempted to handle exceptions by catching and rethrowing them, but did so incorrectly: using `throw ex` with a `std::exception_ptr` loses the original exception type and details. However, in this case, explicit exception handling is unnecessary. The only reason for catching was to ensure `ap.destroy()` is called before propagating the exception. This can be more cleanly and safely achieved using Seastar's `.finally()` continuation, which guarantees cleanup regardless of success or failure. 2. directories The `std::exception_ptr()` has been captured for logging and then again re-thrown incorrectly via `throw ex;`. We could use `std::rethrow_exception()` here instead, but it seems to be simpler to just use regular `throw;` to rethrow the original exception, and only use the `std::current_exception()` for logging (which is a pattern used in other places as well). 3. storage_service Here the exception has been re-thrown incorrectly in a coroutine. There it is best to use the `co_await coroutine::return_exception_ptr` to propagate exception more efficiently in a coroutine-friendly manner. Fixes: SCYLLADB-94 Refs: scylladb/scylladb#27501 No backport: This fixes an error logging issue, that isn't a production problem by itself (only found in test), therefore not backporting to older branches. Closes scylladb/scylladb#27613 * https://github.com/scylladb/scylladb: db: schema_applier: improve exception-safe cleanup directories: fix exception rethrowing storage_service: use coroutine-friendly exception propagation in join_node_response_handler