Skip to content

Commit

Permalink
When open fails with XrdCl::errRedirectLimit, delay next active sourc…
Browse files Browse the repository at this point in the history
…e check.
  • Loading branch information
osschar committed Sep 30, 2021
1 parent d57b428 commit 5aa9ad6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
19 changes: 9 additions & 10 deletions Utilities/XrdAdaptor/src/XrdRequestManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class SendMonitoringInfoHandler : public XrdCl::ResponseHandler {

SendMonitoringInfoHandler(const std::string &url) : m_fs(url) {}

XrdCl::FileSystem& fs() { return m_fs; }
XrdCl::FileSystem &fs() { return m_fs; }
};

static void SendMonitoringInfo(XrdCl::File &file) {
Expand Down Expand Up @@ -121,6 +121,7 @@ RequestManager::RequestManager(const std::string &filename, XrdCl::OpenFlags::Fl
: m_serverToAdvertise(nullptr),
m_timeout(XRD_DEFAULT_TIMEOUT),
m_nextInitialSourceToggle(false),
m_redirectLimitDelayScale(1),
m_name(filename),
m_flags(flags),
m_perms(perms),
Expand Down Expand Up @@ -594,6 +595,7 @@ void XrdAdaptor::RequestManager::handleOpen(XrdCl::XRootDStatus &status, std::sh
std::lock_guard<std::recursive_mutex> sentry(m_source_mutex);
if (status.IsOK()) {
edm::LogVerbatim("XrdAdaptorInternal") << "Successfully opened new source: " << source->PrettyID() << std::endl;
m_redirectLimitDelayScale = 1;
for (const auto &s : m_activeSources) {
if (source->ID() == s->ID()) {
edm::LogVerbatim("XrdAdaptorInternal")
Expand Down Expand Up @@ -624,7 +626,12 @@ void XrdAdaptor::RequestManager::handleOpen(XrdCl::XRootDStatus &status, std::sh
}
} else { // File-open failure - wait at least 120s before next attempt.
edm::LogVerbatim("XrdAdaptorInternal") << "Got failure when trying to open a new source" << std::endl;
m_nextActiveSourceCheck.tv_sec += XRD_ADAPTOR_LONG_OPEN_DELAY - XRD_ADAPTOR_SHORT_OPEN_DELAY;
int delayScale = 1;
if (status.status == XrdCl::errRedirectLimit) {
m_redirectLimitDelayScale = std::min(2 * m_redirectLimitDelayScale, 100);
delayScale = m_redirectLimitDelayScale;
}
m_nextActiveSourceCheck.tv_sec += delayScale * XRD_ADAPTOR_LONG_OPEN_DELAY - XRD_ADAPTOR_SHORT_OPEN_DELAY;
}
}

Expand Down Expand Up @@ -1030,14 +1037,6 @@ void XrdAdaptor::RequestManager::OpenHandler::HandleResponseWithHosts(XrdCl::XRo
<< "' (errno=" << status->errNo << ", code=" << status->code << ")";
ex.addContext("In XrdAdaptor::RequestManager::OpenHandler::HandleResponseWithHosts()");
manager->addConnections(ex);

// Brian, should we do something like this:
// if (status.status == XrdCl::errRedirectLimit) {
// // The following method does not exist (yet), would probaly need a multiplier for OPEN_DELAY.
// // Note that with XCache cluster one will never get multiple sources.
// manager->increaseMultiSourceInterval();
// }

m_promise.set_exception(std::make_exception_ptr(ex));
}
}
Expand Down
1 change: 1 addition & 0 deletions Utilities/XrdAdaptor/src/XrdRequestManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ namespace XrdAdaptor {
bool m_nextInitialSourceToggle;
// The time when the next active source check should be performed.
timespec m_nextActiveSourceCheck;
int m_redirectLimitDelayScale;
bool searchMode;

const std::string m_name;
Expand Down

0 comments on commit 5aa9ad6

Please sign in to comment.