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

fix race in AbstractOplogFetcherTest::OplogFetcherReturnsOperationFailedIfExecutorFailsToScheduleFind

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

      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@mongodb.com Benety Goh
            Reporter:
            benety.goh@mongodb.com Benety Goh
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: