Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-54925

Move away from using Bson_serialization_type “any”

    • Type: Icon: Task Task
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 5.0.0-rc0
    • Affects Version/s: None
    • Component/s: Querying
    • Fully Compatible
    • Query Execution 2021-04-05, Query Execution 2021-04-19

      Using Bson_serialization_type “any” means that idl compatibility checker script can’t do any type checking, since that logic is in cpp, so we want to disallow this type from parameters/reply fields as a result.

      However, lots of commands actually use it for valid reasons.
      For now we added some exceptions to allow using Bson_serialization_type “any” in our idl_checker script, these are the lisf of fields that still using Bson_serialization_type “any” that require your attention:

      src/mongo/db/explain.idl

      1. The 'explain'' command has parameter 'collation' that has type 'IDLAnyType' 
      2. The 'explain'' command has parameter 'use44SortKeys' that has type 'IDLAnyType' 
      3. The 'explain'' command has parameter 'useNewUpsert' that has type 'IDLAnyType'

      src/mongo/db/ops/write_ops.idl

      1. 'update' has a reply field '_id' of type 'IDLAnyTypeOwned'
      2. The 'findAndModify'' command has parameter 'hint' that has type 'indexHint' 
      3. The 'findAndModify'' command has parameter 'update' that has type 'update_modification' 
      4. 'findAndModify' has a reply field 'upserted' of type 'IDLAnyTypeOwned' 
      5. 'delete' command has a parameter of type 'DeleteOpEntry' which has 'limit' and 'hint'

      src/mongo/db/pipeline/aggregate_command.idl: 

      1. The 'aggregate'' command has parameter 'pipeline' that has type 'pipeline' 
      2. The 'aggregate'' command has parameter 'explain' that has type 'explainVerbosity' 
      3. The 'aggregate'' command has parameter 'allowDiskUse' that has type 'optionalBool' 
      4. The 'aggregate'' command has parameter 'cursor' that has type 'aggregateCursor' 
      5. The 'aggregate'' command has parameter 'hint' that has type 'indexHint'
      6. The 'aggregate'' command has parameter 'needsMerge' that has type 'optionalBool'
      7. The 'aggregate'' command has parameter 'fromMongos' that has type 'optionalBool'
      8. The 'aggregate'' command has parameter '$_requestReshardingResumeToken' that has type 'optionalBool'
      9. The 'aggregate'' command has parameter 'isMapReduceCommand' that has type 'optionalBool'
      10. 'aggregate' has a reply field 'partialResultsReturned' of type 'optionalBool'

       

      src/mongo/db/query/find_command.idl

      1. The 'find'' command has parameter 'filter' that has type 'object_owned_nonempty_serialize' 
      2. The 'find'' command has parameter 'projection' that has type 'object_owned_nonempty_serialize'
      3. The 'find'' command has parameter 'sort' that has type 'object_owned_nonempty_serialize'
      4. The 'find'' command has parameter 'hint' that has type 'indexHint'
      5. The 'find'' command has parameter 'collation' that has type 'object_owned_nonempty_serialize'
      6. The 'find'' command has parameter 'singleBatch' that has type 'optionalBool'
      7. The 'find'' command has parameter 'allowDiskUse' that has type 'optionalBool'
      8. The 'find'' command has parameter 'min' that has type 'object_owned_nonempty_serialize'
      9. The 'find'' command has parameter 'max' that has type 'object_owned_nonempty_serialize'
      10. The 'find'' command has parameter 'returnKey' that has type 'optionalBool'
      11. The 'find'' command has parameter 'showRecordId' that has type 'optionalBool'
      12. The 'find'' command has parameter '$queryOptions' that has type 'object_owned_nonempty_serialize'
      13. The 'find'' command has parameter 'tailable' that has type 'optionalBool'
      14. The 'find'' command has parameter 'oplogReplay' that has type 'boolNoOpSerializer' 
      15. The 'find'' command has parameter 'noCursorTimeout' that has type 'optionalBool'
      16. The 'find'' command has parameter 'awaitData' that has type 'optionalBool'
      17. The 'find'' command has parameter 'allowPartialResults' that has type 'optionalBool'
      18. The 'find'' command has parameter 'readOnce' that has type 'optionalBool'
      19. The 'find'' command has parameter 'allowSpeculativeMajorityRead' that has type 'optionalBool'
      20. The 'find'' command has parameter '$_requestResumeToken' that has type 'optionalBool' 
      21. The 'find'' command has parameter '$_resumeAfter' that has type 'object_owned_nonempty_serialize'
      22. The 'find'' command has parameter 'maxTimeMS' that has type 'maxTimeMS' 
      23. 'find' has a reply field 'partialResultsReturned' of type 'optionalBool' 

      Take a look at these fields and try to identify which ones can be converted away from using Bson_serialization_type “any”, and which ones must keep using it.
      Here are the two outcomes:
      1- if the field can be converted:

      • This change should be done before 5.0 (if the field is "stable") as this will be the realese for API stable Version 1
      • The exception for that field should be removed from idl_checker script (TODO will be added with this ticket number).

      2- if the field can't be converted, or the change can't be done before 5.0.

      • The type of that field type should stay of Bson_serialization_type “any” and can't be changed later for any reason unless it is defined as "unstable".
      • We need to put comments on the serialization/deserialization to prevent the behavioral changes (preferably to add tests to ensure that.)

            Assignee:
            mohammad.dashti@mongodb.com Mohammad Dashti (Inactive)
            Reporter:
            m.maher@mongodb.com Moustafa Maher
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: