@@ -668,22 +668,26 @@ void AgencyCommManager::releaseNonLocking(std::unique_ptr<httpclient::GeneralCli
668
668
}
669
669
670
670
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
+
672
674
MUTEX_LOCKER (locker, _lock);
673
- failedNonLocking (std::move (connection), endpoint);
675
+ failedNonLocking (std::move (connection), endpoint, message );
674
676
}
675
677
676
678
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
+
678
682
if (_endpoints.front () == endpoint) {
679
683
LOG_TOPIC (" 1a7b9" , TRACE, Logger::AGENCYCOMM)
680
684
<< " failed agency connection '" << connection.get ()
681
- << " ', active endpoint " << endpoint << " '" ;
685
+ << " ', active endpoint " << endpoint << " ': " << message ;
682
686
683
687
} else {
684
688
LOG_TOPIC (" 90592" , TRACE, Logger::AGENCYCOMM)
685
689
<< " failed agency connection '" << connection.get ()
686
- << " ', inactive endpoint " << endpoint << " '" ;
690
+ << " ', inactive endpoint " << endpoint << " ': " << message ;
687
691
}
688
692
689
693
switchCurrentEndpoint ();
@@ -710,7 +714,7 @@ std::string AgencyCommManager::redirect(std::unique_ptr<httpclient::GeneralClien
710
714
711
715
// invalid
8000
location header
712
716
if (delim == std::string::npos) {
713
- failedNonLocking (std::move (connection), endpoint);
717
+ failedNonLocking (std::move (connection), endpoint, " invalid location header " );
714
718
return " " ;
715
719
}
716
720
@@ -724,7 +728,7 @@ std::string AgencyCommManager::redirect(std::unique_ptr<httpclient::GeneralClien
724
728
if (endpoint == specification) {
725
729
LOG_TOPIC (" 14be3" , DEBUG, Logger::AGENCYCOMM)
726
730
<< " got an agency redirect back to the old agency '" << endpoint << " '" ;
727
- failedNonLocking (std::move (connection), endpoint);
731
+ failedNonLocking (std::move (connection), endpoint, " cyclic redirect " );
728
732
return " " ;
729
733
}
730
734
@@ -1570,9 +1574,15 @@ AgencyCommResult AgencyComm::sendWithFailover(arangodb::rest::RequestType method
1570
1574
}
1571
1575
}
1572
1576
#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 ;
1573
1583
} catch (...) {
1574
1584
// Rotate to new agent endpoint:
1575
- AgencyCommManager::MANAGER->failed (std::move (connection), endpoint);
1585
+ AgencyCommManager::MANAGER->failed (std::move (connection), endpoint, " unknown exception " );
1576
1586
endpoint.clear ();
1577
1587
connection = AgencyCommManager::MANAGER->acquire (endpoint);
1578
1588
continue ;
@@ -1682,7 +1692,9 @@ AgencyCommResult AgencyComm::sendWithFailover(arangodb::rest::RequestType method
1682
1692
1683
1693
if (result._statusCode == 0 || result._statusCode == static_cast <int >(rest::ResponseCode::SERVICE_UNAVAILABLE)) {
1684
1694
// 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);
1686
1698
endpoint.clear ();
1687
1699
connection = AgencyCommManager::MANAGER->acquire (endpoint);
1688
1700
}
0 commit comments