-
Type:
Bug
-
Resolution: Unresolved
-
Priority:
Major - P3
-
None
-
Affects Version/s: 7.0.0, 8.0.0, 8.2.0, 9.0.0-rc0, 8.3.0
-
Component/s: None
-
None
-
Storage Execution
-
ALL
-
-
None
-
None
-
None
-
None
-
None
-
None
-
None
When an insert produces a DuplicateKey error on a clustered collection whose _id is a Decimal128, the server throws an uncaught KeyString format error, either 50810 for values >=1 or 50825 for values < 1.
Root cause
A clustered collection's RecordId is the KeyString encoding of _id with the TypeBits intentionally discarded, the type information lives only in the document body as mentioned on this comment.
When there is a write conflict, to produce a user-friendly duplicate-key message, the insert path decodes the existing RecordId back to BSON. That decode runs with an empty TypeBits that is represents of kInt. When the values carry decimal-format markers then we throw in toBsonValue().