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

Partial index with $geoWithin filter crashes when querying a big polygon document

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Query Execution
    • ALL
    • QE 2023-02-06, QE 2023-02-20, QE 2023-03-06, QE 2023-03-20, QE 2023-04-03, QE 2023-04-17, QE 2023-05-01
    • 127

      jstest to reproduce the issue is attached.

      Imagine we create an index with partial filter expression {location: $geoWithin: <polygonA>}.
      And query the collection with filter {location: $getWithin: <polygonB>}.

      During planning, isSubsetOf(index filter expression, query expression) will be called to determine if index can be used.

      It will check if polygonB is inside polygonA: https://github.com/mongodb/mongo/blob/04299d14a33a89023b6bc69d8d59a618aa603e5d/src/mongo/db/matcher/expression_algo.cpp#L750

      GeoMatchExpression::matchesGeoContainer has an explicit check to never match big polygon, which fails for some reason
      https://github.com/mongodb/mongo/blob/04299d14a33a89023b6bc69d8d59a618aa603e5d/src/mongo/db/matcher/expression_geo.cpp#L415

      And GeometryContainer::contains is called that fails if the other container is a big polygon:
      https://github.com/mongodb/mongo/blob/04299d14a33a89023b6bc69d8d59a618aa603e5d/src/mongo/db/geo/geometry_container.cpp#L322

      It looks like the bug can be triggered easier by just inserting a document with big polygon and querying if it is within another geometry, but for some reason, the only way this actually breaks in partial index filter.

            Assignee:
            backlog-query-execution [DO NOT USE] Backlog - Query Execution
            Reporter:
            ivan.fefer@mongodb.com Ivan Fefer
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: