[SERVER-51795] Explain command on sharded clusters does not support readConcern Created: 21/Oct/20  Updated: 17/Nov/23  Resolved: 17/Nov/23

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: None
Fix Version/s: 7.3.0-rc0

Type: Bug Priority: Major - P3
Reporter: Ian Boros Assignee: Henri Nikku
Resolution: Fixed Votes: 0
Labels: quick-tech-debt
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Query Optimization
Backwards Compatibility: Fully Compatible
Operating System: ALL
Participants:
Case:

 Description   

On standalones, the explain command does not support readConcern, as it uses the default implementation of supportsReadConcern() (see here). For example

db.c.runCommand({explain: {find: "c", query: {a: 1}}, readConcern: {level: "available"}}) // Error

It is, however, legal to provide a readConcern in the inner command. For example:

db.c.runCommand({explain: {count: "c", query: {a: 1}, readConcern: {level: "available"}}})

When running explain on a sharded cluster, mongos will "hoist" generic options from the inner command into the top-level "explain" command which it sends to the shards. See here). The result of this is that attempting to explain a query with a readConcern other than "local" on mongos throws an error.

It is possible to get different query plans using different readConcern levels, and it would be extremely useful if explain() could reflect this. For example, queries run with readConcern "available" do not perform orphan filtering, and do not need a SHARD_FILTER stage. In many cases, this can lead to a completely different plan being used than if the query had been run with a stronger readConcern.



 Comments   
Comment by Githook User [ 17/Nov/23 ]

Author:

{'name': 'henrinikku', 'email': 'henri.nikku@mongodb.com', 'username': 'henrinikku'}

Message: SERVER-51795 Allow explain for all read concern levels
Branch: master
https://github.com/mongodb/mongo/commit/feaffd83c4fe443a1568cc2ec543e9849c0c56ff

Comment by Ana Meza [ 11/Feb/22 ]

Hi jacob.evans, just wondering if do you remember what was the decision to close this PR?

Generated at Thu Feb 08 05:26:27 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.