'Couldn't send "endSessions" 'warnings during exit

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • C Drivers
    • None
    • None
    • None
    • None
    • 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)

      {             case mongocxx::log_level::k_error:                 level_str = "ERROR";                 break;             case mongocxx::log_level::k_critical:                 level_str = "CRITICAL";                 break;             case mongocxx::log_level::k_warning:                 level_str = "WARNING";                 break;             case mongocxx::log_level::k_message:                 level_str = "MESSAGE";                 break;             case mongocxx::log_level::k_info:                 level_str = "INFO";                 break;             case mongocxx::log_level::k_debug:                 level_str = "DEBUG";                 break;             case mongocxx::log_level::k_trace:                 level_str = "TRACE";                 break;             default:                 level_str = "UNKNOWN";                 break;         }

             
              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)

      {                 std::cout << "  - " << doc["name"].get_string().value << std::endl;             }

              } catch (const std::exception& e)

      {             std::cerr << "Error listing databases: " << e.what() << std::endl;         }

          }
         
          ~MongoTest()

      {         std::cout << "MongoTest destructor called - destroying pool..." << std::endl;         pool_.reset();         std::cout << "Pool destroyed" << std::endl;     }

      };

      int main(int argc, char* argv[]) {
         
          std::string connection_string = argv[1];
         
         

      {         MongoTest test(connection_string);         test.list_databases();     }

         
          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

      ...

            Assignee:
            Unassigned
            Reporter:
            P M
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: