Fix race in AsyncTryWithRetryStrategyCanBeCanceled unit test

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Major - P3
    • 9.0.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • None
    • Server Programmability
    • Fully Compatible
    • ALL
    • Programmability 2026-04-28
    • 0
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      This test creates a future like this:

          auto resultFut = AsyncTry([](const TargetingMetadata&) {})
                               .withRetryStrategy(strategy)
                               .on(executor(), cancelSource.token());
      

      A comment says that it should hang forever if not canceled, but this is untrue. Because the body (passed to the AsyncTry constructor) returns nothing, it becomes an OK status here. So we treat the body of the retry loop as a success, rather than actually executing a retry loop.

      However, the test usually passes because the main thread manages to cancel before we even get that far.

      This can be confirmed by inserting a sleep between the on(...) and the cancel(), which makes the test fail reliably.

      The fix is simple: the body should return a not-OK status that will cause the retry loop to execute. Looking at the very similar AsyncTryUntilCanBeCanceled test, it has an until returning false to achieve the same effect.

            Assignee:
            Ryan Berryhill
            Reporter:
            Ryan Berryhill
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: