[SERVER-30616] fix race in AbstractOplogFetcherTest::OplogFetcherReturnsOperationFailedIfExecutorFailsToScheduleFind Created: 11/Aug/17  Updated: 30/Oct/23  Resolved: 11/Aug/17

Status: Closed
Project: Core Server
Component/s: Replication
Affects Version/s: None
Fix Version/s: 3.5.12

Type: Bug Priority: Major - P3
Reporter: Benety Goh Assignee: Benety Goh
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Repl 2017-08-21
Participants:
Linked BF Score: 0

 Description   

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

136
TEST_F(AbstractOplogFetcherTest, OplogFetcherReturnsOperationFailedIfExecutorFailsToScheduleFind) {
137
    ShutdownState shutdownState;
138
 
139
    TaskExecutorMock taskExecutorMock(&getExecutor());
140
    taskExecutorMock.shouldFailScheduleRemoteCommandRequest =
141
        [](const executor::RemoteCommandRequest&) { return true; };
142
 
143
    MockOplogFetcher oplogFetcher(
144
        &taskExecutorMock, lastFetched, source, nss, 0, stdx::ref(shutdownState));
145
 
146
    ASSERT_FALSE(oplogFetcher.isActive());
147
    ASSERT_OK(oplogFetcher.startup());
148
    ASSERT_TRUE(oplogFetcher.isActive());
149
 
150
    oplogFetcher.join();
151
 
152
    ASSERT_EQUALS(ErrorCodes::OperationFailed, shutdownState.getStatus());
153
}



 Comments   
Comment by Githook User [ 11/Aug/17 ]

Author:

{'name': 'Benety Goh', 'username': 'benety', 'email': 'benety@mongodb.com'}

Message: SERVER-30616 fix race in AbstractOplogFetcherTest::OplogFetcherReturnsOperationFailedIfExecutorFailsToScheduleFind
Branch: master
https://github.com/mongodb/mongo/commit/16b8d41a5fc1a18086f3aec1611b818a804adb6c

Generated at Thu Feb 08 04:24:26 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.