[SERVER-31089] createIndex fails with "Index type 'text' does not support collation" but applyops command succeeds for creating the same index Created: 14/Sep/17 Updated: 27/Oct/23 Resolved: 19/Sep/17 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Ankur Srivastava (Inactive) | Assignee: | Tess Avitabile (Inactive) |
| Resolution: | Works as Designed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Operating System: | ALL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Steps To Reproduce: | create a collection:
Create index with collation
Here is the result of getIndexes and oplog entry. Notice that collation specification is not present here.
try to create index without collation:
try to create index without collation using applyops:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Participants: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Description |
|
If a collection is created with collation specification, creation of a text index fails if {collation.locale: "simple"} is not provided during index creation. Creating the same index using applyOps command succeeds even if the {collation.locale: "simple"} is not provided in the applyops command. |
| Comments |
| Comment by Shane Harvey [ 07/Nov/17 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
We still have multiple representations of the simple collation; {collation:{ locale: "simple"}} for createIndexes and non-existent for getIndexes. We've just punted the multiple representation problem onto the user. I think #4 would have been (and still would be) a better solution. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by David Storch [ 29/Sep/17 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
No, that is intentional. Indexes created on versions prior to 3.4, of course, know nothing about collation and therefore have no collation-related metadata in the catalog. While developing the collation project, this fact gave us a few choices:
We opted for #2 since it was the simplest and did not suffer from having multiple representations of the simple collation. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Shane Harvey [ 29/Sep/17 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Isn't it a bug that the simple collation is not reported by getIndexes? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Tess Avitabile (Inactive) [ 19/Sep/17 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
When there is no collation in the getIndexes output, it means that the index has the simple collation. Then if the collection has a non-simple default collation, backup must specify {collation: {locale: "simple"}} in the createIndexes command. Otherwise, the index will inherit the collection default collation, which will be incorrect. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Ankur Srivastava (Inactive) [ 19/Sep/17 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I am using 3.4.7. for me, applyOps commad succeeds. Note that, I was using bkp as the database.
The problem is that the backup does not have collation information to pass to createIndex command. If you look at getIndexes output above, there is no way of knowing what collation was used to create the index. So backup tries to create the index without specifying the collation {locale: "simple"}, and it fails. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Tess Avitabile (Inactive) [ 19/Sep/17 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
ankur.srivastava, note that if there is no collation on the index in the getIndexes response or the oplog entry for index creation, it is always safe to specify {collation: {locale: "simple"}} in the createIndexes command. Though it is only necessary if the collection has a non-simple collation. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Tess Avitabile (Inactive) [ 19/Sep/17 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Thanks, anonymous.user, I have confirmed the behavior on the 3.4 branch. I'm going to close this as Works as Designed and open a bug for the behavior on master. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Kelsey Schubert [ 19/Sep/17 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
tess.avitabile, this was reported against 3.4.7. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Tess Avitabile (Inactive) [ 19/Sep/17 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
What version of the server are you using? When I tried the repro, the applyOps command failed. However, I believe it is a bug that the applyOps command failed. When creating an index, the applyOps command should not add the collection default collation to the index spec. It should behave identically to replicating an oplog entry that creates an index, which does not add the collection default collation to the index spec. The createIndexes command should add the collection default collation to the index spec. In the case of a collection with a non-simple default collation, if backup uses the createIndexes command to create an index with the simple collation, it must explicitly specify the collation {locale: "simple"}. |