-
Type: Task
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Labels:None
Description
Description:
Although it is unlikely that any of our users will be affected, this could theoretically present compatibility problems, which we may want to document as part of the release notes for 4.2.
- Users on x86 will not be affected.
- Users are only susceptible to a compatibility problem if they are using a hashed index and the indexed field contains a double value of 2^63.
- Such values are not supported. The existing documentation notes that hashed fields should not contain any floating point values greater than 2^53 (https://docs.mongodb.com/manual/core/index-hashed/#considerations).
- A hashed field "contains" 2^63 if its value is 2^63 or if it is an object or array that contains a field with the value 2^63.
- Before upgrading, PowerPC users may want to check if their databases have any hashed indexes and if any of the indexed fields contain a 2^63 double value.
- If any such documents exist and the hashed index is the shard key, the user will need to remove the affect documents before upgrading and then insert them back after upgrading.
- If the hashed index is not part of the shard key, then the user also has the option to delete and then re-create the index after upgrading.
- If the collection exists on a standalone mongod (not part of a replica set), the user can simply call the reIndex function on the hashed index.
Before upgrading, the user can query a hashed index to see if any of its fields are equal to 2^63 in the shell:
db.COLLECTION_NAME.find({FIELD_NAME: Math.pow(2, 63)})
If it is possible that the hashed field has object or array values, the user should use a more thorough check:
db.COLLECTION_NAME.find({ $where: function() { function findVal(obj, val) { if (obj === val) return true; for (const child in obj) { if (findVal(obj[child], val)) { return true; } } return false; } return findVal(this.FIELD_NAME, Math.pow(2, 63)); } })COLLECTION_NAME and FIELD_NAME should be replaced with the name of the collection containing the hashed index and the name of the field that the index hashes. If this search returns no documents for any fields with a hashed index, then the user can upgrade normally.
Engineering Ticket Description:
As noted in
SERVER-37183, the hash function used for double values performs an undefined cast when hashing the value 2^63, and the resulting value is different on PPC than on other supported platforms. We should make this hash value consistent across architectures, but before we do that, we need a path for existing PPC installations to rehash any documents with a hashed index key that includes a 2^63 double value.
Scope of changes
Impact to Other Docs
MVP (Work and Date)
Resources (Scope or Design Docs, Invision, etc.)
- documents
-
SERVER-38623 Make safeNumberLongForHash consistent between PPC and other architectures
- Closed