fix race in AbstractOplogFetcherTest::OplogFetcherReturnsOperationFailedIfExecutorFailsToScheduleFind

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Major - P3
    • 3.5.12
    • Affects Version/s: None
    • Component/s: Replication
    • None
    • Fully Compatible
    • ALL
    • Repl 2017-08-21
    • 0
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      In this test case, it is racy to check OplogFetcher::isActive() immediately after calling startup() because OplogFetcher schedules the remote command on a different thread from the caller of startup().

      https://github.com/mongodb/mongo/blob/6d9d554e24b134e9cadad7e9377c5e4634c3a6af/src/mongo/db/repl/abstract_oplog_fetcher_test.cpp?utf8=✓#L148

      abstract_oplog_fetcher_test.cpp
      TEST_F(AbstractOplogFetcherTest, OplogFetcherReturnsOperationFailedIfExecutorFailsToScheduleFind) {
          ShutdownState shutdownState;
      
          TaskExecutorMock taskExecutorMock(&getExecutor());
          taskExecutorMock.shouldFailScheduleRemoteCommandRequest =
              [](const executor::RemoteCommandRequest&) { return true; };
      
          MockOplogFetcher oplogFetcher(
              &taskExecutorMock, lastFetched, source, nss, 0, stdx::ref(shutdownState));
      
          ASSERT_FALSE(oplogFetcher.isActive());
          ASSERT_OK(oplogFetcher.startup());
          ASSERT_TRUE(oplogFetcher.isActive());
      
          oplogFetcher.join();
      
          ASSERT_EQUALS(ErrorCodes::OperationFailed, shutdownState.getStatus());
      }
      

              Assignee:
              Benety Goh
              Reporter:
              Benety Goh
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: