[SERVER-31161] Index created through applyOps command should not inherit collection default collation Created: 19/Sep/17  Updated: 30/Oct/23  Resolved: 10/Oct/17

Status: Closed
Project: Core Server
Component/s: Index Maintenance
Affects Version/s: 3.5.13
Fix Version/s: 3.4.14, 3.6.0-rc0

Type: Bug Priority: Major - P3
Reporter: Tess Avitabile (Inactive) Assignee: Tess Avitabile (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Related
related to SERVER-36944 applyOps does not permit unknown fiel... Closed
is related to SERVER-31089 createIndex fails with "Index type 't... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v3.4
Steps To Reproduce:

> db.createCollection("c", {collation: {locale: "en_US"}})
{ "ok" : 1, "operationTime" : Timestamp(1505846099, 1) }
> db.runCommand({applyOps: [{ "ts" : Timestamp(1505846037, 1), "t" : NumberLong(1), "h" : NumberLong("216366330843306159"), "v" : 2, "op" : "i", "ns" : "test.system.indexes", "o" : { "v" : 2, "key" : { "a" : 1 }, "name" : "a_1", "ns" : "test.c" } }]})
{
	"applied" : 1,
	"results" : [
		true
	],
	"ok" : 1,
	"operationTime" : Timestamp(1505846128, 1)
}
> db.c.getIndexes()
[
	{
		"v" : 2,
		"key" : {
			"_id" : 1
		},
		"name" : "_id_",
		"ns" : "test.c",
		"collation" : {
			"locale" : "en_US",
			"caseLevel" : false,
			"caseFirst" : "off",
			"strength" : 3,
			"numericOrdering" : false,
			"alternate" : "non-ignorable",
			"maxVariable" : "punct",
			"normalization" : false,
			"backwards" : false,
			"version" : "57.1"
		}
	},
	{
		"v" : 2,
		"key" : {
			"a" : 1
		},
		"name" : "a_1",
		"ns" : "test.c",
		"collation" : {
			"locale" : "en_US",
			"caseLevel" : false,
			"caseFirst" : "off",
			"strength" : 3,
			"numericOrdering" : false,
			"alternate" : "non-ignorable",
			"maxVariable" : "punct",
			"normalization" : false,
			"backwards" : false,
			"version" : "57.1"
		}
	}
]

Sprint: Query 2017-10-23
Participants:

 Description   

An index created through the applyOps command currently inherits the collection default collation. This behavior is incorrect--replicating such an oplog entry does not cause the index to inherit the collection default collation. This is important, because for indexes with the simple collation, the collation is not specified in the oplog entry, even if the collection has a non-simple default collation.

Note that this bug only applies to oplog entries phrased as insertions into system.indexes, which are only generated when the featureCompatibilityVersion is 3.4. It does not apply to oplog entries of the form:

{ "ts" : Timestamp(1505845525, 1), "t" : NumberLong(1), "h" : NumberLong("8738799795251471513"), "v" : 2, "op" : "c", "ns" : "test.$cmd", "ui" : UUID("03829ff6-acc7-45a3-ab78-9bf4b563ba9c"), "wall" : ISODate("2017-09-19T18:25:25.757Z"), "o" : { "createIndexes" : "c", "v" : 2, "key" : { "a" : 1 }, "name" : "a_1" } }

Indexes created through the applyOps command using this style of oplog entry correctly do not inherit the collection default collation.

Note also that this bug does not apply to 3.4--it only exists in master.

This appears to happen because in the applyOps command, direct inserts into system.indexes cause us to run createIndexes directly on the server. This behavior was introduced in this commit.



 Comments   
Comment by Githook User [ 12/Feb/18 ]

Author:

{'email': 'louis.williams@mongodb.com', 'name': 'Louis Williams', 'username': 'louiswilliams'}

Message: SERVER-31161 Index created through applyOps command should not inherit collection default collation

(cherry picked from commit 49dfa0c0e938c265f987b585f3d41ae12a64f65a)
Branch: v3.4
https://github.com/mongodb/mongo/commit/74e24d88efe4a08a8d1e4c71229afb62b503bf73

Comment by David Storch [ 01/Feb/18 ]

louis.williams, I don't follow your comment above. Can you elaborate?

Comment by Louis Williams [ 31/Jan/18 ]

This is necessary because of the changes made in BACKPORT-719.

Comment by Githook User [ 10/Oct/17 ]

Author:

{'email': 'tess.avitabile@mongodb.com', 'name': 'Tess Avitabile', 'username': 'tessavitabile'}

Message: SERVER-31161 Index created through applyOps command should not inherit collection default collation
Branch: master
https://github.com/mongodb/mongo/commit/49dfa0c0e938c265f987b585f3d41ae12a64f65a

Generated at Thu Feb 08 04:26:11 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.