SERVER-113711 : Rate Limit Log unable to establish remote cursors (#44775)
Co-authored-by: kmznam <97981975+kmznam@users.noreply.github.com> Co-authored-by: kmznam <97981975+kmznam@users.noreply.github.com> GitOrigin-RevId: b24c927e7b3b6d1e24dc4ae3e92ecf30b9088ba6
This commit is contained in:
parent
48f10211e3
commit
c87b7b2632
@ -50,6 +50,7 @@
|
||||
#include "mongo/executor/task_executor.h"
|
||||
#include "mongo/logv2/attribute_storage.h"
|
||||
#include "mongo/logv2/log.h"
|
||||
#include "mongo/logv2/log_severity_suppressor.h"
|
||||
#include "mongo/s/async_requests_sender.h"
|
||||
#include "mongo/s/client/shard_registry.h"
|
||||
#include "mongo/s/grid.h"
|
||||
@ -175,8 +176,12 @@ private:
|
||||
std::vector<RemoteCursor> _remoteCursors;
|
||||
std::vector<HostAndPort> _remotesToClean;
|
||||
AsyncRequestsSender::ShardHostMap _designatedHostsMap;
|
||||
static logv2::SeveritySuppressor _logSeveritySuppressor;
|
||||
};
|
||||
|
||||
logv2::SeveritySuppressor CursorEstablisher::_logSeveritySuppressor{
|
||||
Seconds{1}, logv2::LogSeverity::Info(), logv2::LogSeverity::Debug(2)};
|
||||
|
||||
void CursorEstablisher::sendRequests(const ReadPreferenceSetting& readPref,
|
||||
const std::vector<AsyncRequestsSender::Request>& remotes,
|
||||
Shard::RetryPolicy retryPolicy) {
|
||||
@ -326,10 +331,14 @@ void CursorEstablisher::checkForFailedRequests() {
|
||||
}
|
||||
|
||||
if (!(_maybeFailure->code() == ErrorCodes::CommandOnShardedViewNotSupportedOnMongod)) {
|
||||
LOGV2(4625501,
|
||||
"Unable to establish remote cursors",
|
||||
"error"_attr = *_maybeFailure,
|
||||
"nRemotes"_attr = _remotesToClean.size());
|
||||
// LOGV2_DEBUG sets the log severity level based on the value defined by
|
||||
// _logSeveritySuppressor().toInt(). This severity level is not restricted to DEBUG and can
|
||||
// be any defined level.
|
||||
LOGV2_DEBUG(4625501,
|
||||
_logSeveritySuppressor().toInt(),
|
||||
"Unable to establish remote cursors",
|
||||
"error"_attr = *_maybeFailure,
|
||||
"nRemotes"_attr = _remotesToClean.size());
|
||||
} else {
|
||||
// If this is a shard acting as a sub-router, clear the pending participant.
|
||||
auto txnRouter = TransactionRouter::get(_opCtx);
|
||||
|
||||
@ -32,25 +32,22 @@
|
||||
// IWYU pragma: no_include "cxxabi.h"
|
||||
// IWYU pragma: no_include "ext/alloc_traits.h"
|
||||
#include "mongo/base/error_codes.h"
|
||||
#include "mongo/base/status.h"
|
||||
#include "mongo/base/string_data.h"
|
||||
#include "mongo/bson/bsonelement.h"
|
||||
#include "mongo/bson/bsonmisc.h"
|
||||
#include "mongo/bson/bsonobjbuilder.h"
|
||||
#include "mongo/bson/json.h"
|
||||
#include "mongo/client/connection_string.h"
|
||||
#include "mongo/client/remote_command_targeter_factory_mock.h"
|
||||
#include "mongo/client/remote_command_targeter_mock.h"
|
||||
#include "mongo/db/client.h"
|
||||
#include "mongo/db/query/client_cursor/cursor_id.h"
|
||||
#include "mongo/db/query/client_cursor/cursor_response.h"
|
||||
#include "mongo/executor/network_test_env.h"
|
||||
#include "mongo/executor/remote_command_request.h"
|
||||
#include "mongo/s/catalog/type_shard.h"
|
||||
#include "mongo/s/query/exec/establish_cursors.h"
|
||||
#include "mongo/s/resource_yielders.h"
|
||||
#include "mongo/s/sharding_mongos_test_fixture.h"
|
||||
#include "mongo/unittest/barrier.h"
|
||||
#include "mongo/unittest/framework.h"
|
||||
#include "mongo/unittest/unittest.h"
|
||||
#include "mongo/util/assert_util.h"
|
||||
#include "mongo/util/fail_point.h"
|
||||
@ -1249,6 +1246,73 @@ TEST_F(EstablishCursorsTest, MultipleRemotesMultipleDifferentErrors) {
|
||||
future.default_timed_get();
|
||||
}
|
||||
|
||||
TEST_F(EstablishCursorsTest, LogsUnableToEstablishRemoteCursorsOnTimeout) {
|
||||
auto& settings = logv2::LogManager::global().getGlobalSettings();
|
||||
auto originalSeverity = settings.getMinimumLogSeverity(logv2::LogComponent::kQuery);
|
||||
startCapturingLogMessages();
|
||||
|
||||
BSONObj cmdObj = fromjson("{find: 'testcoll'}");
|
||||
std::vector<AsyncRequestsSender::Request> remotes{{kTestShardIds[0], cmdObj}};
|
||||
|
||||
int iterations = 3;
|
||||
|
||||
// Set the log level to debug and count the number of log lines
|
||||
settings.setMinimumLoggedSeverity(logv2::LogComponent::kQuery, logv2::LogSeverity::Debug(5));
|
||||
|
||||
// Wait for 1 second for the timer to reset.
|
||||
sleepmillis(1000);
|
||||
for (int i = 0; i < iterations; i++) {
|
||||
auto future = launchAsync([&] {
|
||||
ASSERT_THROWS(establishCursors(operationContext(),
|
||||
executor(),
|
||||
_nss,
|
||||
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
|
||||
remotes,
|
||||
false),
|
||||
ExceptionFor<ErrorCodes::FailedToParse>);
|
||||
});
|
||||
|
||||
// Remote responds with non-retriable error.
|
||||
onCommand([this](const RemoteCommandRequest& request) {
|
||||
ASSERT_EQ(_nss.coll(), request.cmdObj.firstElement().valueStringData());
|
||||
return createErrorCursorResponse(Status(ErrorCodes::FailedToParse, "failed to parse"));
|
||||
});
|
||||
future.default_timed_get();
|
||||
}
|
||||
|
||||
ASSERT_EQUALS(countBSONFormatLogLinesIsSubset(BSON("id" << 4625501)), iterations);
|
||||
|
||||
// Set the log level to info and count the additional number of log lines.
|
||||
settings.setMinimumLoggedSeverity(logv2::LogComponent::kQuery, logv2::LogSeverity::Info());
|
||||
|
||||
// Wait for 1 second for the timer to reset.
|
||||
sleepmillis(1000);
|
||||
for (int i = 0; i < iterations; i++) {
|
||||
auto future = launchAsync([&] {
|
||||
ASSERT_THROWS(establishCursors(operationContext(),
|
||||
executor(),
|
||||
_nss,
|
||||
ReadPreferenceSetting{ReadPreference::PrimaryOnly},
|
||||
remotes,
|
||||
false),
|
||||
ExceptionFor<ErrorCodes::FailedToParse>);
|
||||
});
|
||||
|
||||
// Remote responds with non-retriable error.
|
||||
onCommand([this](const RemoteCommandRequest& request) {
|
||||
ASSERT_EQ(_nss.coll(), request.cmdObj.firstElement().valueStringData());
|
||||
return createErrorCursorResponse(Status(ErrorCodes::FailedToParse, "failed to parse"));
|
||||
});
|
||||
future.default_timed_get();
|
||||
}
|
||||
|
||||
stopCapturingLogMessages();
|
||||
|
||||
ASSERT_EQUALS(countBSONFormatLogLinesIsSubset(BSON("id" << 4625501)), 1 + iterations);
|
||||
|
||||
settings.setMinimumLoggedSeverity(logv2::LogComponent::kQuery, originalSeverity);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
} // namespace mongo
|
||||
|
||||
Loading…
Reference in New Issue
Block a user