[SERVER-55760] Cancelation tests for AsyncTry are racy Created: 02/Apr/21  Updated: 29/Oct/23  Resolved: 23/Jun/21

Status: Closed
Project: Core Server
Component/s: Internal Code
Affects Version/s: None
Fix Version/s: 5.0.3, 5.1.0-rc0

Type: Bug Priority: Major - P3
Reporter: Matthew Saltz (Inactive) Assignee: Alex Li
Resolution: Fixed Votes: 0
Labels: save-for-alex, servicearch-wfbf-day
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Related
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v5.0
Sprint: Service Arch 2021-06-14, Service Arch 2021-06-28
Participants:
Linked BF Score: 124

 Description   

These two tests that AsyncTryUntilWithDelay loops can be canceled by a CancellationToken should be split into four tests that use barriers to specify exactly when cancelSource.cancel() is called with respect to the execution of the loop.

E.g. AsyncTryUntilWithBackoffCanBeCanceled should be changed to AsyncTryUntilWithBackoffCanBeCanceledAfterLoopIsDoneExecuting and AsyncTryUntilWithBackoffCanBeCanceledWhileLoopIsExecuting. Example code for the former:

    
TEST_F(AsyncTryUntilTest, AsyncTryUntilWithBackoffCanBeCanceledAfterLoopIsDoneExecuting) {
        CancellationSource cancelSource;
        unittest::Barrier barrier{2};
        auto resultFut = AsyncTry([] {})
                                   .until([&](Status) {
                                        barrier.countDownAndWait();
                                        return false;
                                   })
                                   .withBackoffBetweenIterations(TestBackoff{Seconds(10000000)})
                                  .on(executor(), cancelSource.token());
        barrier.countDownAndWait();
        cancelSource.cancel();
        ASSERT_EQ(resultFut.getNoThrow(), kCanceledStatus);
    }

This will help tease out more possible bugs in the implementation.



 Comments   
Comment by Vivian Ge (Inactive) [ 06/Oct/21 ]

Updating the fixversion since branching activities occurred yesterday. This ticket will be in rc0 when it’s been triggered. For more active release information, please keep an eye on #server-release. Thank you!

Comment by Githook User [ 10/Aug/21 ]

Author:

{'name': 'Alex Li', 'email': 'alex.li@mongodb.com', 'username': 'alexli12456'}

Message: SERVER-55760 Fix data races in Cancelation tests for AsyncTry

(cherry picked from commit db5c817ceaeef2aadf86832f7878c50d32cbd382)
Branch: v5.0
https://github.com/mongodb/mongo/commit/f4ed55730b28d8f4d33d4b92f67379f93864c158

Comment by Githook User [ 23/Jun/21 ]

Author:

{'name': 'Alex Li', 'email': 'alex.li@mongodb.com'}

Message: SERVER-55760 Fix data races in Cancelation tests for AsyncTry
Branch: master
https://github.com/mongodb/mongo/commit/db5c817ceaeef2aadf86832f7878c50d32cbd382

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