[SERVER-12242] can't run "compact" on a collection if it has an index on an empty field name Created: 02/Jan/14  Updated: 02/Apr/14  Resolved: 11/Feb/14

Status: Closed
Project: Core Server
Component/s: Index Maintenance
Affects Version/s: None
Fix Version/s: 2.6.0-rc0

Type: Bug Priority: Major - P3
Reporter: Michael O'Brien Assignee: Mathias Stearn
Resolution: Done Votes: 0
Labels: 26qa
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-12244 can't run reIndex() on collection if ... Closed
is related to DOCS-2726 dochub link for index validation not ... Closed
is related to SERVER-12070 Validate all indexes for new restrict... Closed
Backwards Compatibility: Minor Change
Operating System: ALL
Participants:

 Description   

creating an index on a nested field path, where one field name in the path is empty - for example db.test.createIndex(

{"a..b":1}

) was valid in <= 2.4.

However, after upgrading to 2.6, running "compact" on a collection that has an index of this type will fail.

 m27000| 2014-01-02T17:36:41.318-0500 [conn1] compact test.test begin
 m27000| 2014-01-02T17:36:41.318-0500 [conn1] paddingFactor:1 paddingBytes:0
 m27000| 2014-01-02T17:36:41.318-0500 [conn1] compact 2 extents
 m27000| 2014-01-02T17:36:41.318-0500 [conn1] compact orphan deleted lists
 m27000| 2014-01-02T17:36:41.318-0500 [conn1] compact dropping indexes
 m27000| 2014-01-02T17:36:41.319-0500 [conn1] compact begin extent #0 for namespace test.test
 m27000| 2014-01-02T17:36:41.319-0500 [conn1] compact paging in len=0.004096MB
 m27000| 2014-01-02T17:36:41.319-0500 [conn1] compact copying records
 m27000| 2014-01-02T17:36:41.319-0500 [conn1] compact finished extent #0 containing 65 documents (0.00286MB) oldPadding: 1.00699 1
 m27000| 2014-01-02T17:36:41.319-0500 [conn1] compact begin extent #1 for namespace test.test
 m27000| 2014-01-02T17:36:41.319-0500 [conn1] compact paging in len=0.016384MB
 m27000| 2014-01-02T17:36:41.319-0500 [conn1] compact copying records
 m27000| 2014-01-02T17:36:41.320-0500 [conn1] compact finished extent #1 containing 35 documents (0.00154MB) oldPadding: 1 1
 m27000| 2014-01-02T17:36:41.320-0500 [conn1] compact create index { _id: 1 }
 m27000| 2014-01-02T17:36:41.320-0500 [conn1] build index on: test.test properties: { v: 1, key: { _id: 1 }, name: "_id_", ns: "test.test" }
 m27000| 2014-01-02T17:36:41.321-0500 [conn1] build index done.  scanned 100 total records. 0 secs
 m27000| 2014-01-02T17:36:41.321-0500 [conn1] compact create index { a..b: 1.0 }
 m27000| 2014-01-02T17:36:41.321-0500 [conn1] failed to create index: CannotCreateIndex Index key cannot contain an empty field.
 m27000| 2014-01-02T17:36:41.321-0500 [conn1] compact test.test end (with error)
assert: [0] != [1] are not equal : undefined
Error: Printing Stack Trace
    at printStackTrace (src/mongo/shell/utils.js:38:15)
    at doassert (src/mongo/shell/assert.js:6:5)
    at Function.assert.eq (src/mongo/shell/assert.js:32:5)
    at test_compact.js:18:9
2014-01-02T17:36:41.325-0500 [0] != [1] are not equal : undefined at src/mongo/shell/assert.js:7
failed to load: test_compact.js
 m27000| 2014-01-02T17:36:41.325-0500 [signalProcessingThread] got signal 15 (Terminated: 15), will terminate after current cmd ends
 m27000| 2014-01-02T17:36:41.325-0500 [signalProcessingThread] now exiting



 Comments   
Comment by Githook User [ 02/Apr/14 ]

Author:

{u'username': u'jrassi', u'name': u'Jason Rassi', u'email': u'rassi@10gen.com'}

Message: SERVER-12242 SERVER-12244 Fix typo in compact/reIndex error messages

The error messages originally were incorrectly swapped with one
another.

(cherry picked from commit df0236cab083063fd125e289c6bac6b017bc6b67)
Branch: v2.6
https://github.com/mongodb/mongo/commit/65b84b79e5bb514e658065d5d9028b85061deae6

Comment by Githook User [ 02/Apr/14 ]

Author:

{u'username': u'jrassi', u'name': u'Jason Rassi', u'email': u'rassi@10gen.com'}

Message: SERVER-12242 SERVER-12244 Fix typo in compact/reIndex error messages

The error messages originally were incorrectly swapped with one
another.
Branch: master
https://github.com/mongodb/mongo/commit/df0236cab083063fd125e289c6bac6b017bc6b67

Comment by Githook User [ 11/Feb/14 ]

Author:

{u'username': u'RedBeard0531', u'name': u'Mathias Stearn', u'email': u'mathias@10gen.com'}

Message: SERVER-12070 SERVER-12242 SERVER-12244 Validate existing indexes
Branch: master
https://github.com/mongodb/mongo/commit/b5f67b6a6aec989aec7c01fd445b25c5804f9016

Comment by Githook User [ 11/Feb/14 ]

Author:

{u'username': u'RedBeard0531', u'name': u'Mathias Stearn', u'email': u'mathias@10gen.com'}

Message: Move index key validation into IndexCatalog::validateKeyPattern

This just moves around existing checks and tries to harmonize the error
messages. Should not change behavior other than error text.

Prep for SERVER-12070 SERVER-12242 SERVER-12244. They will all use this
function to do their validation.
Branch: master
https://github.com/mongodb/mongo/commit/320ccdad6bd6975a3d7480e1bf8374353c545ec6

Comment by Daniel Pasette (Inactive) [ 16/Jan/14 ]

We should do a validation step before compact which will use the same method used in checking for valid indexes used in SERVER-12070.

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