8000 Add more context error messages (#12108) · RtiWeb/arangodb@b195ff1 · GitHub
[go: up one dir, main page]

Skip to content

Commit b195ff1

Browse files
jsteemannKVS85
andauthored
Add more context error messages (arangodb#12108)
in certain agency failure situations in debug/trace mode. Co-authored-by: Vadim <vadim@arangodb.com>
1 parent 3e5f739 commit b195ff1

File tree

3 files changed

+26
-11
lines changed

3 files changed

+26
-11
lines changed

CHANGELOG

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
v3.6.5 (XXXX-XX-XX)
22
-------------------
33

4+
* Add more context error messages in certain agency failure situations in
5+
debug/trace mode.
6+
47
* Fixed issue OASIS-252: Hotbackup agency locks without clientId.
58

69
* Correct some log entries.

arangod/Agency/AgencyComm.cpp

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -668,22 +668,26 @@ void AgencyCommManager::releaseNonLocking(std::unique_ptr<httpclient::GeneralCli
668668
}
669669

670670
void AgencyCommManager::failed(std::unique_ptr<httpclient::GeneralClientConnection> connection,
671-
std::string const& endpoint) {
671+
std::string const& endpoint, char const* message) {
672+
TRI_ASSERT(message != nullptr);
673+
672674
MUTEX_LOCKER(locker, _lock);
673-
failedNonLocking(std::move(connection), endpoint);
675+
failedNonLocking(std::move(connection), endpoint, message);
674676
}
675677

676678
void AgencyCommManager::failedNonLocking(std::unique_ptr<httpclient::GeneralClientConnection> connection,
677-
std::string const& endpoint) {
679+
std::string const& endpoint, char const* message) {
680+
TRI_ASSERT(message != nullptr);
681+
678682
if (_endpoints.front() == endpoint) {
679683
LOG_TOPIC("1a7b9", TRACE, Logger::AGENCYCOMM)
680684
<< "failed agency connection '" << connection.get()
681-
<< "', active endpoint " << endpoint << "'";
685+
<< "', active endpoint " << endpoint << "': " << message;
682686

683687
} else {
684688
LOG_TOPIC("90592", TRACE, Logger::AGENCYCOMM)
685689
<< "failed agency connection '" << connection.get()
686-
<< "', inactive endpoint " << endpoint << "'";
690+
<< "', inactive endpoint " << endpoint << "': " << message;
687691
}
688692

689693
switchCurrentEndpoint();
@@ -710,7 +714,7 @@ std::string AgencyCommManager::redirect(std::unique_ptr<httpclient::GeneralClien
710714

711715
// invalid 8000 location header
712716
if (delim == std::string::npos) {
713-
failedNonLocking(std::move(connection), endpoint);
717+
failedNonLocking(std::move(connection), endpoint, "invalid location header");
714718
return "";
715719
}
716720

@@ -724,7 +728,7 @@ std::string AgencyCommManager::redirect(std::unique_ptr<httpclient::GeneralClien
724728
if (endpoint == specification) {
725729
LOG_TOPIC("14be3", DEBUG, Logger::AGENCYCOMM)
726730
<< "got an agency redirect back to the old agency '" << endpoint << "'";
727-
failedNonLocking(std::move(connection), endpoint);
731+
failedNonLocking(std::move(connection), endpoint, "cyclic redirect");
728732
return "";
729733
}
730734

@@ -1570,9 +1574,15 @@ AgencyCommResult AgencyComm::sendWithFailover(arangodb::rest::RequestType method
15701574
}
15711575
}
15721576
#endif
1577+
} catch (std::exception const& ex) {
1578+
// Rotate to new agent endpoint:
1579+
AgencyCommManager::MANAGER->failed(std::move(connection), endpoint, ex.what());
1580+
endpoint.clear();
1581+
connection = AgencyCommManager::MANAGER->acquire(endpoint);
1582+
continue;
15731583
} catch (...) {
15741584
// Rotate to new agent endpoint:
1575-
AgencyCommManager::MANAGER->failed(std::move(connection), endpoint);
1585+
AgencyCommManager::MANAGER->failed(std::move(connection), endpoint, "unknown exception");
15761586
endpoint.clear();
15771587
connection = AgencyCommManager::MANAGER->acquire(endpoint);
15781588
continue;
@@ -1682,7 +1692,9 @@ AgencyCommResult AgencyComm::sendWithFailover(arangodb::rest::RequestType method
16821692

16831693
if (result._statusCode == 0 || result._statusCode == static_cast<int>(rest::ResponseCode::SERVICE_UNAVAILABLE)) {
16841694
// Rotate to new agent endpoint:
1685-
AgencyCommManager::MANAGER->failed(std::move(connection), endpoint);
1695+
char const* errorMessage =
1696+
(result._statusCode == 0 ? "status code 0" : "status code 503");
1697+
AgencyCommManager::MANAGER->failed(std::move(connection), endpoint, errorMessage);
16861698
endpoint.clear();
16871699
connection = AgencyCommManager::MANAGER->acquire(endpoint);
16881700
}

arangod/Agency/AgencyComm.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ class AgencyCommManager {
217217
// using the connection and an error occurred. The connection object will
218218
// be destroyed and the current endpoint will be rotated.
219219
void failed(std::unique_ptr<httpclient::GeneralClientConnection>,
220-
std::string const& endpoint);
220+
std::string const& endpoint, char const* message);
221221

222222
// If a request receives a redirect HTTP 307, one should call the following
223223
// method to make the new location the current one. The method returns the
@@ -238,7 +238,7 @@ class AgencyCommManager {
238238
private:
239239
// caller must hold _lock
240240
void failedNonLocking(std::unique_ptr<httpclient::GeneralClientConnection>,
241-
std::string const& endpoint);
241+
std::string const& endpoint, char const* message);
242242

243243
// caller must hold lock
244244
void releaseNonLocking(std::unique_ptr<httpclient::GeneralClientConnection>,

0 commit comments

Comments
 (0)
0