Function should return actual error code instead of hard-coded 0

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Unresolved
    • Priority: Trivial - P5
    • None
    • Affects Version/s: None
    • Component/s: DHandles
    • Storage Engines - Foundations
    • 486.514
    • None
    • None

      Issue Summary

      The function __wti_conn_dhandle_outdated currently always returns 0 at the end, regardless of the value of ret set within the function body. This approach can mask errors and lead to confusion, especially if ret is set to an error code and engineers expect it to be propagated.

      Context

      • The function attempts to mark a data handle as outdated if a matching URI is found.
      • Error codes are set via ret during operations such as __wt_conn_dhandle_find.
      • The current implementation:
        return (0);
        
      • This ignores any error code set in ret, except for the explicit WT_NOTFOUND handling.
      • Multiple engineers agree that returning ret is safer and clearer.

      Proposed Solution

      • Update the function to explicitly set ret = 0 if WT_NOTFOUND is encountered in the last else if.
      • Change the function's return statement to return (ret); at the end, ensuring error codes are properly propagated.

      Example revision

      if (ret == 0) {
          F_SET(session->dhandle, WT_DHANDLE_OUTDATED);
          WT_DHANDLE_RELEASE(session->dhandle);
      } else if (ret == WT_NOTFOUND) {
          ret = 0;
      } else {
          WT_RET(ret);
      }
      return (ret);
      

      Original Slack thread
      This ticket was generated by AI from a Slack thread.

            Assignee:
            Unassigned
            Reporter:
            Memento Slack Bot
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: