Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-55966

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

    • Fully Compatible
    • ALL
    • v5.0
    • 3

      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@mongodb.com Amirsaman Memaripour
            Reporter:
            max.hirschhorn@mongodb.com Max Hirschhorn
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: