[SERVER-55966] AsyncTry no longer handles exceptions from until() lambda, leading to process crash Created: 09/Apr/21  Updated: 29/Oct/23  Resolved: 22/Jul/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: Max Hirschhorn Assignee: Amirsaman Memaripour
Resolution: Fixed Votes: 0
Labels: servicearch-wfbf-day
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Problem/Incident
is caused by SERVER-54408 Rewrite AsyncTry-until to not use fut... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v5.0
Participants:
Story Points: 3

 Description   

The change from using .onCompletion() to using .getAsync() in SERVER-54408 made it so any exceptions thrown by the until() lambda are left uncaught. This leads the process to crash, specifically from the lambda called by mongo::ExecutorFuture<T>::getAsync() being wrapped in another lambda that is marked noexcept. AsyncTry should instead handle this exception and return a future ready with the exception as an error status.

TEST_F(AsyncTryUntilTest, UntilBodyPropagatesErrorToCaller) {
    auto resultFut = AsyncTry([] {})
                         .until([](Status status) {
                             uasserted(ErrorCodes::InternalError, "test error");
                             return true;
                         })
                         .on(executor(), CancellationToken::uncancelable());
 
    ASSERT_EQ(resultFut.getNoThrow(), ErrorCodes::InternalError);
}



 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 [ 23/Aug/21 ]

Author:

{'name': 'Amirsaman Memaripour', 'email': 'amirsaman.memaripour@mongodb.com', 'username': 'samanca'}

Message: SERVER-55966 Handle exceptions thrown from `AsyncTry::until`

(cherry picked from commit 6a9d44fd340399014208af39d979bd9094c7e45c)
Branch: v5.0
https://github.com/mongodb/mongo/commit/efd77f1ed9fd44b9422f1855f7d46ad18de69a1a

Comment by Githook User [ 22/Jul/21 ]

Author:

{'name': 'Amirsaman Memaripour', 'email': 'amirsaman.memaripour@mongodb.com', 'username': 'samanca'}

Message: SERVER-55966 Handle exceptions thrown from `AsyncTry::until`
Branch: master
https://github.com/mongodb/mongo/commit/6a9d44fd340399014208af39d979bd9094c7e45c

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