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

Clean up debug string generation for MatchExpression

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.1.10
    • Affects Version/s: None
    • Component/s: Querying
    • Fully Compatible
    • Query 2019-04-08
    • 33

      SERVER-39233 changed the implementation of MatchExpression::toString() so that it calls MatchExpression::serialize(). This meant that existing call sites to MatchExpression::toString() started producing a different string. In particular, this caused us to lose verbose logging which prints information about the tags attached to the match expression tree during the planning process. This information has historically been super useful to quickly debug planner behavior, so I think it's important to add back. Query engineers frequently enable logLevel 5 for the "query" component during the development process to understand planner behavior, including how the match expression tree is tagged.

      However, some callers may not want this verbose logging for a few reasons:

      1. It's verbose. (Did I mention that?)
      2. The output can span multiple lines, so it's not a good format for logging at low debug levels or for error strings.
      3. The output does not actually represent real query syntax. Rather, it's an internal-only format that cannot be meaningfully re-parsed into a MatchExpression.

      This ticket should introduce two separate mechanisms for generating a debug string:

      1. MatchExpression::debugString(). This will produce the free-form verbose debug string described above. Most existing callers will be changed to use debugString().
      2. MatchExpression::toString(). This will serialize the MatchExpression to a semantically valid query represented as BSON, and then turn that BSON object into a string by the usual means.

            Assignee:
            david.storch@mongodb.com David Storch
            Reporter:
            david.storch@mongodb.com David Storch
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: