[SERVER-55532] Make ReshardingTxnCloner's ClonerOneBatchThenCanceled cancel before batch response Created: 25/Mar/21  Updated: 29/Oct/23  Resolved: 30/Mar/21

Status: Closed
Project: Core Server
Component/s: Sharding
Affects Version/s: None
Fix Version/s: 4.9.0-rc1, 5.0.0-rc0

Type: Task Priority: Major - P3
Reporter: Haley Connelly Assignee: Haley Connelly
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Depends
Backwards Compatibility: Fully Compatible
Backport Requested:
v4.9
Sprint: Sharding 2021-04-05
Participants:
Linked BF Score: 154
Story Points: 1

 Description   

Before returning the batch response in ClonerOneBatchThenCanceled, the test should cancel the cancelToken to prevent the cloner from potentially making it another round before it gets cancelled. This is done in other test cases for the ReshardingTxnCloner
Note - the token should be canceled only once the request is sent to make sure the first batch doesn't get skipped entirely.

Motivation:
The test can hang if the token gets cancelled after the first batch is processed and already awaiting a new response. 

It can be reproduced as follows 

TEST_F(ReshardingTxnClonerTest, ClonerOneBatchThenCanceled) {
    const auto txns = makeSortedTxns(4);
    auto executor = makeTaskExecutorForCloner();
    ReshardingTxnCloner cloner(kTwoSourceIdList[1], Timestamp::max());
    auto opCtxToken = operationContext()->getCancellationToken();
    auto cancelSource = CancellationSource(opCtxToken);
    auto future = runCloner(cloner, executor, cancelSource.token());
 
    onCommandReturnTxnBatch(std::vector<BSONObj>(txns.begin(), txns.begin() + 2),
                            CursorId{123},
                            true /* isFirstBatch */);
    sleepsecs(2); // <---------------------- added for repro
    cancelSource.cancel();
 
    auto status = future.getNoThrow();
    ASSERT_EQ(status.code(), ErrorCodes::CallbackCanceled);
}



 Comments   
Comment by Githook User [ 06/Apr/21 ]

Author:

{'name': 'Haley Connelly', 'email': 'haley.connelly@mongodb.com', 'username': 'haleyConnelly'}

Message: SERVER-55532 Make ReshardingTxnCloner's ClonerOneBatchThenCanceled cancel before batch response

(cherry picked from commit 1b40b034bcaadcf5e9713e59970e2838af3fa4ca)
Branch: v4.9
https://github.com/mongodb/mongo/commit/6be4dc7f8338d9a8d961c7e770e64cba02ec2b5e

Comment by Githook User [ 30/Mar/21 ]

Author:

{'name': 'Haley Connelly', 'email': 'haley.connelly@mongodb.com', 'username': 'haleyConnelly'}

Message: SERVER-55532 Make ReshardingTxnCloner's ClonerOneBatchThenCanceled cancel before batch response
Branch: master
https://github.com/mongodb/mongo/commit/1b40b034bcaadcf5e9713e59970e2838af3fa4ca

Generated at Thu Feb 08 05:36:44 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.