[SERVER-6832] sharding on prefix doesn't trigger "move top chunk" heuristic and causes assertion 10367 Created: 23/Aug/12  Updated: 11/Jul/16  Resolved: 04/Sep/12

Status: Closed
Project: Core Server
Component/s: Index Maintenance, Sharding
Affects Version/s: 2.2.0-rc1
Fix Version/s: 2.2.1, 2.3.0

Type: Bug Priority: Minor - P4
Reporter: Kevin Matulef Assignee: Kevin Matulef
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: File prefix_assertion.js    
Operating System: ALL
Participants:

 Description   

Sharding on a key that's a prefix of an existing index can leave assertions in the logs that look like:

 m30001| Wed Aug 22 22:00:27 [conn4] assertion 10367 no index found for specified keyPattern: {} min: { a: 0.0 } max: { a: MaxKey } ns:test.foo query:{ query: {}, $min: { a: 0.0 }, $max: { a: MaxKey } }

The source of these assertions is a query made at the end of the "splitChunk" command. The query errors because it assumes the existence of an index that's an exact match for the shard key. The query is only used to decide whether to append the "shouldMigrate" flag to the result of the command, which in turn is used as some sort of heuristic by Chunk::splitIfShould() to decide which chunk to move after the split. Leaving out the "shouldMigrate" flag does not appear to affect correctness. I suspect this heuristic is rarely triggered anyway. However because of this issue, using a prefix shard key may yield slightly different behavior than a shard key with an exact index match.

Test attached which shows the assertions.



 Comments   
Comment by auto [ 12/Sep/12 ]

Author:

{u'date': u'2012-08-22T19:20:20-07:00', u'email': u'matulef@10gen.com', u'name': u'Kevin Matulef'}

Message: SERVER-6832 make 'move-top-chunk' heuristic work with prefix shard keys
Branch: v2.2
https://github.com/mongodb/mongo/commit/35da96298e36bd506ebe6b9b8746eee86415d6a1

Comment by auto [ 27/Aug/12 ]

Author:

{u'date': u'2012-08-22T19:20:20-07:00', u'name': u'Kevin Matulef', u'email': u'matulef@10gen.com'}

Message: SERVER-6832 make 'move-top-chunk' heuristic work with prefix shard keys
Branch: master
https://github.com/mongodb/mongo/commit/f876d2d71a7c238889c222164571a9e7170ec080

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