Skip to content

Commit d8e1567

Browse files
xxhdx1985126Matan-B
authored andcommitted
crimson/osd/recovery_backend: set interruption to recovery related
promises, instead of system_error Signed-off-by: Xuehan Xu <[email protected]>
1 parent 80be0ae commit d8e1567

File tree

3 files changed

+42
-33
lines changed

3 files changed

+42
-33
lines changed

src/crimson/osd/osd_operations/background_recovery.cc

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,6 @@ seastar::future<> BackgroundRecoveryT<T>::start()
8787
}, [](std::exception_ptr) {
8888
return seastar::make_ready_future<bool>(false);
8989
}, pg, epoch_started);
90-
}).handle_exception_type([ref, this](const std::system_error& err) {
91-
LOG_PREFIX(BackgroundRecoveryT<T>::start);
92-
if (err.code() == std::make_error_code(std::errc::interrupted)) {
93-
DEBUGDPPI("recovery interruped: {}", *pg, err.what());
94-
return seastar::now();
95-
}
96-
return seastar::make_exception_future<>(err);
9790
});
9891
});
9992
});

src/crimson/osd/recovery_backend.cc

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ void RecoveryBackend::clear_temp_obj(const hobject_t &oid)
4343
}
4444

4545
void RecoveryBackend::clean_up(ceph::os::Transaction& t,
46-
std::string_view why)
46+
interrupt_cause_t why)
4747
{
4848
for (auto& soid : temp_contents) {
4949
t.remove(pg.get_collection_ref()->get_cid(),
@@ -65,6 +65,36 @@ void RecoveryBackend::clean_up(ceph::os::Transaction& t,
6565
recovering.clear();
6666
}
6767

68+
void RecoveryBackend::WaitForObjectRecovery::interrupt(interrupt_cause_t why) {
69+
switch(why) {
70+
case interrupt_cause_t::INTERVAL_CHANGE:
71+
if (readable) {
72+
readable->set_exception(
73+
crimson::common::actingset_changed(pg.is_primary()));
74+
readable.reset();
75+
}
76+
if (recovered) {
77+
recovered->set_exception(
78+
crimson::common::actingset_changed(pg.is_primary()));
79+
recovered.reset();
80+
}
81+
if (pulled) {
82+
pulled->set_exception(
83+
crimson::common::actingset_changed(pg.is_primary()));
84+
pulled.reset();
85+
}
86+
for (auto& [pg_shard, pr] : pushes) {
87+
pr.set_exception(
88+
crimson::common::actingset_changed(pg.is_primary()));
89+
}
90+
pushes.clear();
91+
break;
92+
default:
93+
ceph_abort("impossible");
94+
break;
95+
}
96+
}
97+
6898
void RecoveryBackend::WaitForObjectRecovery::stop() {
6999
if (readable) {
70100
readable->set_exception(

src/crimson/osd/recovery_backend.h

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class RecoveryBackend {
4646
backend{backend} {}
4747
virtual ~RecoveryBackend() {}
4848
std::pair<WaitForObjectRecovery&, bool> add_recovering(const hobject_t& soid) {
49-
auto [it, added] = recovering.emplace(soid, new WaitForObjectRecovery{});
49+
auto [it, added] = recovering.emplace(soid, new WaitForObjectRecovery(pg));
5050
assert(it->second);
5151
return {*(it->second), added};
5252
}
@@ -95,8 +95,12 @@ class RecoveryBackend {
9595
std::int64_t min,
9696
std::int64_t max);
9797

98+
enum interrupt_cause_t : uint8_t {
99+
INTERVAL_CHANGE,
100+
MAX
101+
};
98102
void on_peering_interval_change(ceph::os::Transaction& t) {
99-
clean_up(t, "new peering interval");
103+
clean_up(t, interrupt_cause_t::INTERVAL_CHANGE);
100104
}
101105

102106
seastar::future<> stop() {
@@ -141,11 +145,14 @@ class RecoveryBackend {
141145
public boost::intrusive_ref_counter<
142146
WaitForObjectRecovery, boost::thread_unsafe_counter>,
143147
public crimson::BlockerT<WaitForObjectRecovery> {
148+
crimson::osd::PG &pg;
144149
std::optional<seastar::shared_promise<>> readable, recovered, pulled;
145150
std::map<pg_shard_t, seastar::shared_promise<>> pushes;
146151
public:
147152
static constexpr const char* type_name = "WaitForObjectRecovery";
148153

154+
WaitForObjectRecovery(crimson::osd::PG &pg) : pg(pg) {}
155+
149156
crimson::osd::ObjectContextRef obc;
150157
std::optional<pull_info_t> pull_info;
151158
std::map<pg_shard_t, push_info_t> pushing;
@@ -221,28 +228,7 @@ class RecoveryBackend {
221228
pushes.erase(it);
222229
}
223230
}
224-
void interrupt(std::string_view why) {
225-
if (readable) {
226-
readable->set_exception(std::system_error(
227-
std::make_error_code(std::errc::interrupted), why.data()));
228-
readable.reset();
229-
}
230-
if (recovered) {
231-
recovered->set_exception(std::system_error(
232-
std::make_error_code(std::errc::interrupted), why.data()));
233-
recovered.reset();
234-
}
235-
if (pulled) {
236-
pulled->set_exception(std::system_error(
237-
std::make_error_code(std::errc::interrupted), why.data()));
238-
pulled.reset();
239-
}
240-
for (auto& [pg_shard, pr] : pushes) {
241-
pr.set_exception(std::system_error(
242-
std::make_error_code(std::errc::interrupted), why.data()));
243-
}
244-
pushes.clear();
245-
}
231+
void interrupt(interrupt_cause_t why);
246232
void stop();
247233
void dump_detail(Formatter* f) const {
248234
}
@@ -262,7 +248,7 @@ class RecoveryBackend {
262248
void add_temp_obj(const hobject_t &oid);
263249
void clear_temp_obj(const hobject_t &oid);
264250

265-
void clean_up(ceph::os::Transaction& t, std::string_view why);
251+
void clean_up(ceph::os::Transaction& t, interrupt_cause_t why);
266252
virtual seastar::future<> on_stop() = 0;
267253
private:
268254
void handle_backfill_finish(

0 commit comments

Comments
 (0)