Skip to content

Commit

Permalink
Merge pull request #24927 from Lazin/pr/fix-logging-on-shutdown
Browse files Browse the repository at this point in the history
archival: Handle nested shutdown errors
  • Loading branch information
Lazin authored Jan 27, 2025
2 parents 1d1aefd + 01ee010 commit a7c9ad7
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/v/cluster/archival/ntp_archiver_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "model/fundamental.h"
#include "model/metadata.h"
#include "model/record.h"
#include "net/connection.h"
#include "raft/fundamental.h"
#include "ssx/future-util.h"
#include "storage/disk_log_impl.h"
Expand Down Expand Up @@ -80,16 +81,25 @@ constexpr auto housekeeping_jit = 5ms;

namespace archival {

/// Return true if the exception is a shutdown error or a network error (e.g.
/// Broken pipe)
static bool is_shutdown_or_disconnect(const std::exception_ptr& e) {
return ssx::is_shutdown_exception(e) || net::is_disconnect_exception(e);
}

static bool is_nested_shutdown_exception(const ss::nested_exception& ex) {
// During shutdown we could potentially get a 'shutdown' exception. If the
// 'finally' continuation is used it will be invoked and if it touches the
// gate or abort source it will also trigger a 'shutdown' exception. The
// 'finally' continuation is invoked even for the exceptional future. In
// this case we will get the nested_exception. If both exceptions are
// actually exceptions we can safely conclude that the shutdown is in
// progress (somewhat safely).
return ssx::is_shutdown_exception(ex.inner)
&& ssx::is_shutdown_exception(ex.outer);
// shutdown exceptions we can safely conclude that the shutdown is in
// progress (somewhat safely). If one of the exceptions is a shutdown
// exception and another is a network disconnect exception we can also
// conclude that the shutdown is in progress.
return (is_shutdown_or_disconnect(ex.inner)
&& is_shutdown_or_disconnect(ex.outer))
&& (ssx::is_shutdown_exception(ex.inner) || ssx::is_shutdown_exception(ex.outer));
}

static bool segment_meta_matches_stats(
Expand Down

0 comments on commit a7c9ad7

Please sign in to comment.