Skip to content

Commit

Permalink
hints: send_one_hint: extend the scope of file_send_gate holder
Browse files Browse the repository at this point in the history
The problem was that the holder in with_gate
call was released too early. This happened
before the possible call to on_hint_send_failure
in then_wrapped. As a result, the effects of
on_hint_send_failure (segment_replay_failed flag)
were not visible in send_one_file after
ctx_ptr->file_send_gate.close(), so we could decide
that the segment was sent in full and delete
it even if sending of some hints led to errors.

Fixes #15110
  • Loading branch information
Petr Gusev committed Aug 22, 2023
1 parent 0b7a90d commit 9fd3df1
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions db/hints/manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,8 @@ future<> manager::end_point_hints_manager::sender::send_one_hint(lw_shared_ptr<s
ctx_ptr->mark_hint_as_in_progress(rp);

// Future is waited on indirectly in `send_one_file()` (via `ctx_ptr->file_send_gate`).
(void)with_gate(ctx_ptr->file_send_gate, [this, secs_since_file_mod, &fname, buf = std::move(buf), rp, ctx_ptr] () mutable {
auto h = ctx_ptr->file_send_gate.hold();
(void)std::invoke([this, secs_since_file_mod, &fname, buf = std::move(buf), rp, ctx_ptr] () mutable {
try {
auto m = this->get_mutation(ctx_ptr, buf);
gc_clock::duration gc_grace_sec = m.s->gc_grace_seconds();
Expand Down Expand Up @@ -904,7 +905,7 @@ future<> manager::end_point_hints_manager::sender::send_one_hint(lw_shared_ptr<s
return make_exception_future<>(std::move(eptr));
}
return make_ready_future<>();
}).then_wrapped([this, units = std::move(units), rp, ctx_ptr] (future<>&& f) {
}).then_wrapped([this, units = std::move(units), rp, ctx_ptr, h = std::move(h)] (future<>&& f) {
// Information about the error was already printed somewhere higher.
// We just need to account in the ctx that sending of this hint has failed.
if (!f.failed()) {
Expand Down

0 comments on commit 9fd3df1

Please sign in to comment.