[SERVER-5022] full document always loaded for matches if there is a chunk manager Created: 20/Feb/12  Updated: 21/Dec/14  Resolved: 05/Sep/14

Status: Closed
Project: Core Server
Component/s: Querying, Sharding
Affects Version/s: None
Fix Version/s: 2.7.6

Type: Improvement Priority: Major - P3
Reporter: Aaron Staple Assignee: Greg Studer
Resolution: Done Votes: 5
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: File test-index-covered.py    
Issue Links:
Depends
Related
related to DOCS-4571 In 2.8 sharded clusters support cover... Closed
is related to DOCS-2793 Document that sharded clusters don't ... Closed
is related to SERVER-3334 Stop processing bson fields in projec... Backlog
Tested
Backwards Compatibility: Fully Compatible
Participants:

 Description   

This renders covered indexes ineffective when shardingState.needShardChunkManager(pq.ns()) is true. Not sure if this is true in all sharding setups or just some.

                DiskLoc cl = _c->currLoc();
                if ( _chunkManager && ! _chunkManager->belongsToMe( cl.obj() ) ) { // TODO: should make this covered at some point
                    _nChunkSkips++;
                    // log() << "TEMP skipping un-owned chunk: " << _c->current() << endl;
                }



 Comments   
Comment by J Rassi [ 08/Oct/14 ]

dan@10gen.com: I don't think it quite "lifts the restriction" entirely, since the change in this ticket only permits covered queries against indexes that have the shard key as a component (that is, the shard still needs to check if it owns the chunk).

Comment by Daniel Pasette (Inactive) [ 08/Oct/14 ]

samk, this change does require doc changes because it lifts the limitation that sharded queries are not covered. See: http://docs.mongodb.org/manual/core/query-optimization/#limitations

Comment by Githook User [ 03/Sep/14 ]

Author:

{u'username': u'gregstuder', u'name': u'Greg Studer', u'email': u'greg@10gen.com'}

Message: SERVER-5022 cleanup keypattern.h and shardkey.h, remove dead code
Branch: master
https://github.com/mongodb/mongo/commit/a39b938918e09bda67ea9e516101f43b9ef25a51

Comment by Githook User [ 02/Sep/14 ]

Author:

{u'username': u'gregstuder', u'name': u'Greg Studer', u'email': u'greg@10gen.com'}

Message: SERVER-5022 allow covered queries with shard filter
Branch: master
https://github.com/mongodb/mongo/commit/2f7fce0df9e48b804ff560bccd469e2fcad2325f

Comment by Jason R. Coombs [ 20/Jun/14 ]

Why is it not both higher priority and a bug that clients are required to query secondaries to perform queries against an index?

Comment by Jason R. Coombs [ 20/Jun/14 ]

This issue continues to be a serious impediment to our use of MongoDB. The workaround to use the secondaries for queries which must be fulfilled by indexes is clumsy and error-prone. It means that on the whole, our systems rely on both a primary and secondary. That means that rather than having redundancy and failover, we have two points of failure (if either primary or secondary is unavailable, our systems fail).

Comment by Alexander Komyagin [ 05/May/14 ]

Attaching the script that can be used to easily demonstrate the issue (thanks to jaraco). With reading from primary in a sharded cluster script fails, with reading from secondaries - succeeds.

Comment by Aaron Staple [ 03/Oct/12 ]

Here's what that code looks like now

    bool QueryResponseBuilder::chunkMatches( ResultDetails* resultDetails ) {
        if ( !_chunkManager ) {
            return true;
        }
        // TODO: should make this covered at some point
        resultDetails->loadedRecord = true;
        if ( _chunkManager->belongsToMe( _cursor->current() ) ) {
            return true;
        }
        resultDetails->chunkSkip = true;
        return false;
    }

Generated at Thu Feb 08 03:07:39 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.