AsyncTry no longer handles exceptions from until() lambda, leading to process crash

XMLWordPrintableJSON

    • Fully Compatible
    • ALL
    • v5.0
    • 3
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      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);
      }
      

              Assignee:
              Amirsaman Memaripour
              Reporter:
              Max Hirschhorn
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: