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

Unify Status and Uassert Integer Code Spaces

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Diagnostics
    • Service Arch

      To unify the space of error codes from uasserts and error_codes, error_codes.err codes other than OK must start at 1 and not exceed 3,999. These are the "semantically meaningful error codes", and along with OK (0) are the only values that mongo servers should examine for decision making purposes.

      0 remains an invalid uassert code, and is the "OK" code for Statuses. 0 means no error in both spaces and the unified space.

      4,000-8,999 are "location codes" for the subscription build.

      10,000+ are "location codes" for code common to the subscription and free builds.

      Once we unify the two error code spaces as described abvoe, we should get rid of the "location" code in Status. When a command wishes to return a status, it does so as follows:

      { ok: 1, code: <status code>, errmsg: <reason string>, ... }

      If the code is 0/OK, there is no errmsg.

      Optionally, the command may include codeString, with the string name of the code. Commands may return extra information as they require.

      All codes with semantic meaning, as opposed to location-identifying meaning, must be defined in src/mongo/base/error_codes.err. Further, after this issue is resolved, error_codes.err must be append-only. This allows driver writers to pull https://github.com/mongodb/mongo/blob/master/src/mongo/base/error_codes.err whenever they wish (at driver build time?) and use it to auto-generate a language-specific error codes module.

      The header comment for buildscripts/errorcodes.py should document this.

            backlog-server-servicearch [DO NOT USE] Backlog - Service Architecture
            schwerin@mongodb.com Andy Schwerin
            0 Vote for this issue
            6 Start watching this issue