Skip to content

Commit 3f96a23

Browse files
authored
Merge pull request ceph#62770 from adamemerson/wip-70882
rgw/admin: Fix assert on datalog list of invalid shard Reviewed-by: Casey Bodley <[email protected]>
2 parents 259ada5 + bb93aa3 commit 3f96a23

File tree

19 files changed

+1187
-685
lines changed

19 files changed

+1187
-685
lines changed

src/common/async/blocked_completion.h

Lines changed: 249 additions & 119 deletions
Large diffs are not rendered by default.

src/common/async/co_waiter.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
#include <exception>
1616
#include <optional>
17+
#include <boost/asio/associated_cancellation_slot.hpp>
1718
#include <boost/asio/append.hpp>
1819
#include <boost/asio/async_result.hpp>
1920
#include <boost/asio/dispatch.hpp>

src/common/async/concepts.h

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2+
// vim: ts=8 sw=2 smarttab ft=cpp
3+
4+
/*
5+
* Ceph - scalable distributed file system
6+
*
7+
* Copyright contributors to the Ceph project
8+
*
9+
* This is free software; you can redistribute it and/or
10+
* modify it under the terms of the GNU Lesser General Public
11+
* License version 2.1, as published by the Free Software
12+
* Foundation. See file COPYING.
13+
*
14+
*/
15+
16+
#pragma once
17+
18+
#include <type_traits>
19+
20+
#include <boost/asio/execution/executor.hpp>
21+
22+
#include <boost/asio/disposition.hpp>
23+
#include <boost/asio/execution_context.hpp>
24+
25+
/// \file common/async/concepts
26+
///
27+
/// \brief Because Asio needs to implement more concepts
28+
29+
namespace ceph::async {
30+
31+
/// The constraint from functions taking an ExecutionContext packed
32+
/// into a concept.
33+
template<typename ExecutionContext>
34+
concept execution_context =
35+
std::is_convertible_v<ExecutionContext&,
36+
boost::asio::execution_context&>;
37+
/// A concept for Asio 'disposition's, a generalization of error
38+
/// codes/exception pointers, etc.
39+
template<typename T>
40+
concept disposition =
41+
boost::asio::is_disposition_v<T>;
42+
}

src/common/async/forward_handler.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
#ifndef CEPH_ASYNC_FORWARD_HANDLER_H
1616
#define CEPH_ASYNC_FORWARD_HANDLER_H
1717

18+
#include <utility>
19+
1820
#include <boost/asio/associator.hpp>
1921

2022
namespace ceph::async {

src/common/async/librados_completion.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ struct librados_handler {
9797
}
9898

9999
void operator ()(std::exception_ptr e) {
100-
(*this)(ceph::from_exception(e));
100+
std::string what;
101+
(*this)(ceph::from_exception(e, &what));
101102
}
102103
};
103104
} // namespace detail

src/common/error_code.h

Lines changed: 65 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -94,33 +94,57 @@ inline boost::system::error_condition make_error_condition(errc e) noexcept {
9494
#pragma GCC diagnostic pop
9595
#pragma clang diagnostic pop
9696

97-
inline int from_exception(std::exception_ptr eptr) {
97+
[[nodiscard]]
98+
inline int from_exception(std::exception_ptr eptr, std::string* what = nullptr)
99+
{
98100
if (!eptr) [[likely]] {
99101
return 0;
100102
}
101103
try {
102104
std::rethrow_exception(eptr);
103105
} catch (const boost::system::system_error& e) {
106+
if (what)
107+
*what = e.what();
104108
return from_error_code(e.code());
105109
} catch (const std::system_error& e) {
110+
if (what)
111+
*what = e.what();
106112
return from_error_code(e.code());
107-
} catch (const std::invalid_argument&) {
113+
} catch (const std::invalid_argument& e) {
114+
if (what)
115+
*what = e.what();
108116
return -EINVAL;
109-
} catch (const std::domain_error&) {
117+
} catch (const std::domain_error& e) {
118+
if (what)
119+
*what = e.what();
110120
return -EDOM;
111-
} catch (const std::length_error&) {
121+
} catch (const std::length_error& e) {
122+
if (what)
123+
*what = e.what();
112124
return -ERANGE;
113-
} catch (const std::out_of_range&) {
125+
} catch (const std::out_of_range& e) {
126+
if (what)
127+
*what = e.what();
114128
return -ERANGE;
115-
} catch (const std::range_error&) {
129+
} catch (const std::range_error& e) {
130+
if (what)
131+
*what = e.what();
116132
return -ERANGE;
117-
} catch (const std::overflow_error&) {
133+
} catch (const std::overflow_error& e) {
134+
if (what)
135+
*what = e.what();
118136
return -EOVERFLOW;
119-
} catch (const std::underflow_error&) {
137+
} catch (const std::underflow_error& e) {
138+
if (what)
139+
*what = e.what();
120140
return -EOVERFLOW;
121-
} catch (const std::bad_alloc&) {
141+
} catch (const std::bad_alloc& e) {
142+
if (what)
143+
*what = e.what();
122144
return -ENOMEM;
123145
} catch (const std::regex_error& e) {
146+
if (what)
147+
*what = e.what();
124148
using namespace std::regex_constants;
125149
switch (e.code()) {
126150
case error_space:
@@ -134,28 +158,53 @@ inline int from_exception(std::exception_ptr eptr) {
134158
#ifdef __has_include
135159
# if __has_include(<format>)
136160
} catch (const std::format_error& e) {
161+
if (what)
162+
*what = e.what();
137163
return -EINVAL;
138164
# endif
139165
#endif
140166
} catch (const fmt::format_error& e) {
167+
if (what)
168+
*what = e.what();
141169
return -EINVAL;
142-
} catch (const std::bad_typeid&) {
170+
} catch (const std::bad_typeid& e) {
171+
if (what)
172+
*what = e.what();
143173
return -EFAULT;
144-
} catch (const std::bad_cast&) {
174+
} catch (const std::bad_cast& e) {
175+
if (what)
176+
*what = e.what();
145177
return -EFAULT;
146-
} catch (const std::bad_optional_access&) {
178+
} catch (const std::bad_optional_access& e) {
179+
if (what)
180+
*what = e.what();
147181
return -EFAULT;
148-
} catch (const std::bad_weak_ptr&) {
182+
} catch (const std::bad_weak_ptr& e) {
183+
if (what)
184+
*what = e.what();
149185
return -EFAULT;
150-
} catch (const std::bad_function_call&) {
186+
} catch (const std::bad_function_call& e) {
187+
if (what)
188+
*what = e.what();
151189
return -EFAULT;
152-
} catch (const std::bad_exception&) {
190+
} catch (const std::bad_exception& e) {
191+
if (what)
192+
*what = e.what();
153193
return -EFAULT;
154-
} catch (const std::bad_variant_access&) {
194+
} catch (const std::bad_variant_access& e) {
195+
if (what)
196+
*what = e.what();
155197
return -EFAULT;
198+
} catch (const std::exception& e) {
199+
if (what)
200+
*what = e.what();
201+
return -EIO;
156202
} catch (...) {
203+
if (what)
204+
*what = "Unknown exception";
157205
return -EIO;
158206
}
207+
return -EIO;
159208
}
160209
}
161210

src/mon/MonClient.cc

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
#undef dout_prefix
6363
#define dout_prefix *_dout << "monclient" << (_hunting() ? "(hunting)":"") << ": "
6464

65+
namespace asio = boost::asio;
6566
namespace bs = boost::system;
6667
using std::string;
6768
using namespace std::literals;
@@ -534,8 +535,9 @@ void MonClient::shutdown()
534535
monc_lock.lock();
535536
stopping = true;
536537
while (!version_requests.empty()) {
537-
ceph::async::post(std::move(version_requests.begin()->second),
538-
monc_errc::shutting_down, 0, 0);
538+
asio::dispatch(
539+
asio::append(std::move(version_requests.begin()->second),
540+
make_error_code(monc_errc::shutting_down), 0, 0));
539541
ldout(cct, 20) << __func__ << " canceling and discarding version request "
540542
<< version_requests.begin()->first << dendl;
541543
version_requests.erase(version_requests.begin());
@@ -710,7 +712,7 @@ void MonClient::_finish_auth(int auth_err)
710712
ceph_assert(auth);
711713
_check_auth_tickets();
712714
} else if (auth_err == -EAGAIN && !active_con) {
713-
ldout(cct,10) << __func__
715+
ldout(cct,10) << __func__
714716
<< " auth returned EAGAIN, reopening the session to try again"
715717
<< dendl;
716718
_reopen_session();
@@ -767,8 +769,9 @@ void MonClient::_reopen_session(int rank)
767769

768770
// throw out version check requests
769771
while (!version_requests.empty()) {
770-
ceph::async::post(std::move(version_requests.begin()->second),
771-
monc_errc::session_reset, 0, 0);
772+
asio::dispatch(asio::append(std::move(version_requests.begin()->second),
773+
make_error_code(monc_errc::session_reset),
774+
0, 0));
772775
version_requests.erase(version_requests.begin());
773776
}
774777

@@ -1168,7 +1171,8 @@ void MonClient::_send_command(MonCommand *r)
11681171
if (r->is_tell()) {
11691172
++r->send_attempts;
11701173
if (r->send_attempts > cct->_conf->mon_client_directed_command_retry) {
1171-
_finish_command(r, monc_errc::mon_unavailable, "mon unavailable", {});
1174+
_finish_command(r, make_error_code(monc_errc::mon_unavailable),
1175+
"mon unavailable", {});
11721176
return;
11731177
}
11741178
// tell-style command
@@ -1180,7 +1184,8 @@ void MonClient::_send_command(MonCommand *r)
11801184
if (r->target_rank >= (int)monmap.size()) {
11811185
ldout(cct, 10) << " target " << r->target_rank
11821186
<< " >= max mon " << monmap.size() << dendl;
1183-
_finish_command(r, monc_errc::rank_dne, "mon rank dne"sv, {});
1187+
_finish_command(r, make_error_code(monc_errc::rank_dne),
1188+
"mon rank dne"sv, {});
11841189
return;
11851190
}
11861191
r->target_con = messenger->connect_to_mon(
@@ -1189,7 +1194,8 @@ void MonClient::_send_command(MonCommand *r)
11891194
if (!monmap.contains(r->target_name)) {
11901195
ldout(cct, 10) << " target " << r->target_name
11911196
<< " not present in monmap" << dendl;
1192-
_finish_command(r, monc_errc::mon_dne, "mon dne"sv, {});
1197+
_finish_command(r, make_error_code(monc_errc::mon_dne),
1198+
"mon dne"sv, {});
11931199
return;
11941200
}
11951201
r->target_con = messenger->connect_to_mon(
@@ -1224,7 +1230,8 @@ void MonClient::_send_command(MonCommand *r)
12241230
if (r->target_rank >= (int)monmap.size()) {
12251231
ldout(cct, 10) << " target " << r->target_rank
12261232
<< " >= max mon " << monmap.size() << dendl;
1227-
_finish_command(r, monc_errc::rank_dne, "mon rank dne"sv, {});
1233+
_finish_command(r, make_error_code(monc_errc::rank_dne),
1234+
"mon rank dne"sv, {});
12281235
return;
12291236
}
12301237
_reopen_session(r->target_rank);
@@ -1239,7 +1246,8 @@ void MonClient::_send_command(MonCommand *r)
12391246
if (!monmap.contains(r->target_name)) {
12401247
ldout(cct, 10) << " target " << r->target_name
12411248
<< " not present in monmap" << dendl;
1242-
_finish_command(r, monc_errc::mon_dne, "mon dne"sv, {});
1249+
_finish_command(r, make_error_code(monc_errc::mon_dne),
1250+
"mon dne"sv, {});
12431251
return;
12441252
}
12451253
_reopen_session(monmap.get_rank(r->target_name));
@@ -1377,7 +1385,8 @@ int MonClient::_cancel_mon_command(uint64_t tid)
13771385
ldout(cct, 10) << __func__ << " tid " << tid << dendl;
13781386

13791387
MonCommand *cmd = it->second;
1380-
_finish_command(cmd, monc_errc::timed_out, "timed out"sv, {});
1388+
_finish_command(cmd, make_error_code(monc_errc::timed_out),
1389+
"timed out"sv, {});
13811390
return 0;
13821391
}
13831392

@@ -1386,8 +1395,9 @@ void MonClient::_finish_command(MonCommand *r, bs::error_code ret,
13861395
{
13871396
ldout(cct, 10) << __func__ << " " << r->tid << " = " << ret << " " << rs
13881397
<< dendl;
1389-
ceph::async::post(std::move(r->onfinish), ret, std::string(rs),
1390-
std::move(bl));
1398+
asio::post(service.get_executor(),
1399+
asio::append(std::move(r->onfinish), ret, std::string(rs),
1400+
std::move(bl)));
13911401
if (r->target_con) {
13921402
r->target_con->mark_down();
13931403
}
@@ -1409,8 +1419,9 @@ void MonClient::handle_get_version_reply(MMonGetVersionReply* m)
14091419
ldout(cct, 10) << __func__ << " finishing " << iter->first << " version "
14101420
<< m->version << dendl;
14111421
version_requests.erase(iter);
1412-
ceph::async::post(std::move(req), bs::error_code(),
1413-
m->version, m->oldest_version);
1422+
asio::post(service.get_executor(),
1423+
asio::append(std::move(req), bs::error_code(),
1424+
m->version, m->oldest_version));
14141425
}
14151426
m->put();
14161427
}

0 commit comments

Comments
 (0)