ExportXMLWordPrintableJSON

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Query Execution
    • ALL
    • QE 2026-10-26
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      https://docs.google.com/document/d/1xyAVuODst8A4fEZYlVZmdjEojNoDzTxRSLwABAAqlPg/edit?tab=t.2rwh0ww68ut1#heading=h.qj09aw9xhs7o

      When a $group runs in the slot-based engine with a non-simple collation and spills to disk, the spill key is built by serializeValueIntoKeyString in src/mongo/db/exec/sbe/values/row.cpp. That function passes a collation transform for strings (row.cpp:485-495) but appends BSON Symbol values raw, with no collation, at row.cpp:496-504. The spill record id built in HashAggBaseStage::spillRowToDisk (src/mongo/db/exec/sbe/stages/hashagg_base.cpp:102-120) therefore breaks the invariant its own comment states: keys that are equal under the collation must encode to the same bytes so they sort next to each other. The merge in HashAggStage::getNextSpilled (src/mongo/db/exec/sbe/stages/hash_agg.cpp:366-384) is a single pass that only compares neighbouring records, so symbol group keys that are equal under the collation but encoded differently can be emitted as two separate groups with partial totals. The input that reaches it is an ordinary aggregate command with a collation and allowDiskUse over documents whose group field holds BSON Symbol values.

            Assignee:
            Evan Bergeron
            Reporter:
            Rushan Chen
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: