-
Type:
Bug
-
Resolution: Unresolved
-
Priority:
Minor - P4
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
Summary
If multiple switches is provided in the connection string, 'Couldn't send "endSessions" 'warnings will be logged during exit.
Connection string with a single switch is unaffected.
Environment
mongo-cxx driver v3.10.2
mongo-c-driver v1.28.0
Ubuntu22.04
GCC 11.2.1
Build using vcpkg
MongoDB server v4.4.25-24
How to Reproduce
#include <mongocxx/instance.hpp>
#include <mongocxx/client.hpp>
#include <mongocxx/pool.hpp>
#include <mongocxx/uri.hpp>
#include <mongocxx/logger.hpp>
#include <iostream>
#include <memory>
#include <optional>
class custom_logger final : public mongocxx::logger {
public:
void operator()(
mongocxx::log_level level,
bsoncxx::stdx::string_view domain,
bsoncxx::stdx::string_view message
) noexcept override {
const char* level_str;
switch (level)
std::cerr << "MONGO [" << level_str << "@" << domain << "] " << message << std::endl;
}
};
class MongoTest
{ private: mongocxx::instance instance_; std::optional<mongocxx::pool> pool_; public: MongoTest(const std::string& uri) : instance_\{std::make_unique<custom_logger>()}, pool_(std::in_place, mongocxx::uri{uri})
{ std::cout << "MongoTest initialized with URI: " << uri << std::endl; }
void list_databases() {
try {
auto client = pool_->acquire();
auto cursor = client->list_databases();
std::cout << "Databases:" << std::endl;
for (auto&& doc : cursor)
} catch (const std::exception& e)
{ std::cerr << "Error listing databases: " << e.what() << std::endl; } }
~MongoTest()
};
int main(int argc, char* argv[]) {
std::string connection_string = argv[1];
return 0;
}
Additional Background
It happens during pool destruction:
...
MongoTest destructor called - destroying pool...
MONGO [WARNING@client] Couldn't send "endSessions": Could not find node xxx
Pool destroyed
...