[DOCS-10777] 3.2 users reading 3.4 version of createIndex should be warned specifying collation is a silent, but upgrade-blocking, error. Created: 12/Sep/17  Updated: 29/Oct/23  Resolved: 12/Sep/17

Status: Closed
Project: Documentation
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Task Priority: Critical - P2
Reporter: Akira Kurogane Assignee: Kay Kim (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
Participants:
Days since reply: 5 years, 27 weeks, 1 day ago

 Description   

A 3.2 user can create an index with a "collation" option. It succeeds, even though collation is not supported in 3.2. I.e. it seems to be silently ignored.

2017-09-12T12:42:10.774+1000 I CONTROL  [initandlisten] MongoDB starting : pid=5962 port=27017 dbpath=/tmp/data 64-bit host=10gensyd2
2017-09-12T12:42:10.774+1000 I CONTROL  [initandlisten] db version v3.2.10
...
2017-09-12T12:53:19.782+1000 I NETWORK  [initandlisten] connection accepted from 127.0.0.1:36858 #2 (1 connection now open)
2017-09-12T13:06:16.784+1000 I INDEX    [conn2] build index on: product.foo properties: { v: 1, key: { orderDate: 1.0, category: 1.0 }, name: "date_category_fr", ns: "product.foo", collation: { locale: "fr", strength: 2.0 } }
2017-09-12T13:06:16.784+1000 I INDEX    [conn2]          building index using bulk method
2017-09-12T13:06:16.785+1000 I INDEX    [conn2] build index done.  scanned 0 total records. 0 secs

The problem is when they upgrade 3.4. As they do an in-place, binary-version only upgrade the 3.4 mongod will not be running in "3.4" feature compatibility mode at first. In this mode it strictly checks that indexes are 3.2 compatible, and exits with "Fatal Assertion 28782" when it finds the index with the collation:

2017-09-12T13:34:31.762+1000 I CONTROL  [initandlisten] MongoDB starting : pid=6705 port=27017 dbpath=/tmp/data 64-bit host=10gensyd2
2017-09-12T13:34:31.762+1000 I CONTROL  [initandlisten] db version v3.4.1-126-gdd491eeb54
...
2017-09-12T13:34:31.933+1000 F INDEX    [initandlisten] Found an invalid index { v: 1, key: { orderDate: 1.0, category: 1.0 }, name: "date_category_fr", ns: "product.foo", collation: { locale: "fr", strength: 2.0 } } on the product.foo collection: CannotCreateIndex: Index version v=1 does not support the 'collation' option
2017-09-12T13:34:31.933+1000 I -        [initandlisten] Fatal Assertion 28782 at src/mongo/db/catalog/index_catalog.cpp 144
2017-09-12T13:34:31.933+1000 I -        [initandlisten]
 
***aborting after fassert() failure

I think we should add a warning, in only the 3.4 version of documentation, at the following section. https://docs.mongodb.com/manual/reference/method/db.collection.createIndex/#option-for-collation

E.g. 'Warning: 3.2 users should not specify collation option - it will be silently accepted but then block the upgrade to 3.4'



 Comments   
Comment by Daniele Graziani [ 07/Aug/18 ]

Also, if you create a collection in 3.2 such as:

db.createCollection("testCollation",{collation: {"invalid": "this is an invalid collation document"}})

{ "ok" : 1 }

It will succeed but upon upgrading to 3.4 it will fail.

Comment by Kay Kim (Inactive) [ 12/Sep/17 ]

Comment by Akira Kurogane [ 12/Sep/17 ]

Thanks Kim!

Comment by Kay Kim (Inactive) [ 12/Sep/17 ]

[master] https://github.com/mongodb/docs/commit/d35c7619c8d0a9c624c8e51bf14eebc2dd6b9061

[v3.4]
https://github.com/mongodb/docs/commit/25f6d838ebb8ae64c0f301fcae5a4ee84f78d799

Generated at Thu Feb 08 08:01:20 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.