Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-35985

sessions_test and sharding_catalog_manager_test don't destroy all Clients before destroying the ServiceContext

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.0.3, 4.1.1
    • Affects Version/s: None
    • Component/s: Internal Code
    • None
    • Fully Compatible
    • ALL
    • TIG 2018-07-16
    • 46

      session_catalog_test.cpp and sharding_catalog_manager_add_shard_test.cpp use Client::initThreadIfNotAlready() in async code but are missing a corresponding ON_BLOCK_EXIT([&] { Client::destroy(); }) which became required as part of SERVER-34798. For reasons that I don't quite understand the _clients.empty() invariant is only triggered on Windows.

          stdx::async(stdx::launch::async, [&] {
              Client::initThreadIfNotAlready();
              auto sideOpCtx = Client::getCurrent()->makeOperationContext();
              auto scopedSession =
                  SessionCatalog::get(sideOpCtx.get())->getOrCreateSession(sideOpCtx.get(), lsid);
      
              ASSERT(scopedSession.get());
              ASSERT_EQ(lsid, scopedSession->getSessionId());
          }).get();
      
          ocs.reset();
      
          stdx::async(stdx::launch::async, [&] {
              Client::initThreadIfNotAlready();
              auto sideOpCtx = Client::getCurrent()->makeOperationContext();
              auto scopedSession =
                  SessionCatalog::get(sideOpCtx.get())->getOrCreateSession(sideOpCtx.get(), lsid);
      
              ASSERT(scopedSession.get());
              ASSERT_EQ(lsid, scopedSession->getSessionId());
          }).get();
      

      https://github.com/mongodb/mongo/blob/a6e2c10af2dcfa862c6afa0fb1504a5d2b092d09/src/mongo/db/session_catalog_test.cpp#L122-L142
      https://github.com/mongodb/mongo/blob/a6e2c10af2dcfa862c6afa0fb1504a5d2b092d09/src/mongo/db/s/config/sharding_catalog_manager_add_shard_test.cpp#L407

            Assignee:
            max.hirschhorn@mongodb.com Max Hirschhorn
            Reporter:
            max.hirschhorn@mongodb.com Max Hirschhorn
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: