Skip to content

Commit

Permalink
cloud_storage: shutdown http client on partition stop
Browse files Browse the repository at this point in the history
This enables cluster::partition::stop to proceed promptly,
rather than being blocked if ntp_archiver has an S3 request
in flight.

Fixes: redpanda-data#8071
  • Loading branch information
jcsp committed Jan 17, 2023
1 parent 074b407 commit ee2f12a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
15 changes: 15 additions & 0 deletions src/v/cloud_storage/remote.cc
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,21 @@ ss::future<upload_result> remote::upload_segment(
co_return upload_result::cancelled;
}

// If the uploading partition wishes to stop while an upload is in
// progress, enable this by forcefully shutting down the HTTP client.
auto as_sub = fib.root_abort_source().subscribe(
// Lifetimes:
// - `lease` is scoped to this function, as is the
// abort source subscription: as will always be deregistered
// before lease is destroyed.
// - `ctxlog` is also function scoped.
[&lease, &ctxlog]() noexcept {
vlog(
ctxlog.debug,
"Cancelling in-flight requests on partition shutdown");
lease.client->shutdown();
});

auto reader_handle = co_await reset_str();
auto path = cloud_storage_clients::object_key(segment_path());
// Segment upload attempt
Expand Down
1 change: 0 additions & 1 deletion src/v/cloud_storage/remote.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ struct lazy_abort_source {
: _predicate{std::move(predicate)} {}

bool abort_requested();

ss::sstring abort_reason() const;

private:
Expand Down

0 comments on commit ee2f12a

Please sign in to comment.