diff options
author | Blake Oler <blake.oler@mongodb.com> | 2023-03-16 14:42:22 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2023-03-16 15:48:17 +0000 |
commit | 31fc2aeddb58282655c27291a04a53dfed88935c (patch) | |
tree | 7e9e96eff5044a4c2155de3b27a9be6e486cf65e /src | |
parent | 757102d8184507a82a1bc83b6bbd844ff8e10ab6 (diff) | |
download | mongo-31fc2aeddb58282655c27291a04a53dfed88935c.tar.gz |
SERVER-73819 Allow internal errors to escape DBDirectClient
Diffstat (limited to 'src')
-rw-r--r-- | src/mongo/db/dbdirectclient_test.cpp | 15 | ||||
-rw-r--r-- | src/mongo/db/service_entry_point_common.cpp | 7 |
2 files changed, 21 insertions, 1 deletions
diff --git a/src/mongo/db/dbdirectclient_test.cpp b/src/mongo/db/dbdirectclient_test.cpp index 51a9cb78697..84c5c080840 100644 --- a/src/mongo/db/dbdirectclient_test.cpp +++ b/src/mongo/db/dbdirectclient_test.cpp @@ -177,5 +177,20 @@ TEST_F(DBDirectClientTest, ExhaustQuery) { ASSERT_EQ(cursor->itcount(), numDocs); } +TEST_F(DBDirectClientTest, InternalErrorAllowedToEscapeDBDirectClient) { + DBDirectClient client(_opCtx); + FindCommandRequest findCmd{kNs}; + + FailPointEnableBlock failPoint("failCommand", + BSON("errorCode" << ErrorCodes::TransactionAPIMustRetryCommit + << "failCommands" << BSON_ARRAY("find") + << "failInternalCommands" << true + << "failLocalClients" << true)); + + ASSERT_THROWS_CODE(client.find(std::move(findCmd), ReadPreferenceSetting{}, ExhaustMode::kOff), + DBException, + ErrorCodes::TransactionAPIMustRetryCommit); +} + } // namespace } // namespace mongo diff --git a/src/mongo/db/service_entry_point_common.cpp b/src/mongo/db/service_entry_point_common.cpp index 839d9860a7d..17833f6be84 100644 --- a/src/mongo/db/service_entry_point_common.cpp +++ b/src/mongo/db/service_entry_point_common.cpp @@ -204,8 +204,13 @@ struct HandleRequest { } } + /** + * Note that DBDirectClient is treated as an internal client in relation to letting + * internal errors escape. + */ bool isInternalClient() const { - return session() && (session()->getTags() & transport::Session::kInternalClient); + return (client().isInDirectClient()) || + (session() && (session()->getTags() & transport::Session::kInternalClient)); } std::unique_ptr<const ServiceEntryPointCommon::Hooks> behaviors; |