[CDRIVER-906] Separate command and query code Created: 06/Oct/15  Updated: 08/Dec/15  Resolved: 16/Nov/15

Status: Closed
Project: C Driver
Component/s: libmongoc
Affects Version/s: None
Fix Version/s: 1.3.0-beta0

Type: Improvement Priority: Major - P3
Reporter: A. Jesse Jiryu Davis Assignee: A. Jesse Jiryu Davis
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
depends on CDRIVER-807 Remove secondary-ok commands whitelist Closed
is depended on by CDRIVER-838 Support find, getMore and killCursor ... Closed
Related
related to CDRIVER-859 C - Test Driver handling of SASL PLAI... Closed
is related to PHPC-495 Upgrade bundled libbson and libmongoc... Closed

 Description   

Don't create an internal cursor to execute a command with OP_QUERY.

Still to do:

  • Get a new struct, mongoc_server_stream_t, that wraps a stream and server description
  • Update cluster to return mongoc_server_stream_t's with info from ismaster call on that stream
  • Reduce calls to mongoc_cluster_get_max_bson_obj_size and co., get those values from the mongoc_server_stream_t
  • Reduce calls to mongoc_topology_server_by_id, prefer to pass around mongoc_server_stream_t's rather than "hints" or server_id's
  • Reduce need to pass is_write_command around.
  • Reduce calls to topology_select in places like mongoc_collection_aggregate: get a stream and server description at the same time
  • Put $readPreference into the BSON as early as possible, in order to
    simplify run_command.
  • Refactor error-checking that's duplicated between my new
    _mongoc_rpc_parse_error and the existing mongoc_cursor_error DONE


 Comments   
Comment by Githook User [ 02/Dec/15 ]

Author:

{u'username': u'derickr', u'name': u'Derick Rethans', u'email': u'github@derickrethans.nl'}

Message: mongoc_topology_description_server_by_id now takes an additional bson_error_t (CDRIVER-906)
Branch: master
https://github.com/mongodb/mongo-php-driver/commit/4e912f1e77b152ad2f9382b69939d4c5c0fc3011

Comment by Githook User [ 04/Nov/15 ]

Author:

{u'username': u'bjori', u'name': u'Hannes Magnusson', u'email': u'bjori@php.net'}

Message: CDRIVER-906: reply is allowed to be NULL

Fixes test_ssl_single ()
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/bc86b1372272bb74dbc27a0b959adb4ce4bfe154

Comment by Githook User [ 30/Oct/15 ]

Author:

{u'username': u'ajdavis', u'name': u'A. Jesse Jiryu Davis', u'email': u'jesse@mongodb.com'}

Message: CDRIVER-906 respect bulk_operation_set_hint

Fix the driver's handling of bulk->hint, and fix related issues about
getting max_bson_size and other ismaster fields from a newly-connected
server stream.
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/92202b7013ff646a8529c5b5239135d80936914f

Comment by Githook User [ 30/Oct/15 ]

Author:

{u'username': u'ajdavis', u'name': u'A. Jesse Jiryu Davis', u'email': u'jesse@mongodb.com'}

Message: CDRIVER-906 add cluster_stream_for_optype()

Unify two common operations: selecting a server and getting a stream.

Before, we selected a server and got its id. Typically we then looked
up the server description by id to check values like max_wire_version,
and used the id to get a stream.

This caused verbose code & many mongoc_topology_description_server_by_id
calls. It complicated logic for applying read preferences to queries and
commands, and it stood in the way of separating queries from commands.

This is a large refactoring that bundles the three operations – select
a server, get a server description, and get a stream – into one call
_mongoc_cluster_stream_for_optype (). The return value is a new type
mongoc_server_stream_t that has everything required to do a command or
query with read preferences.

apply_read_preferences is therefore somewhat simplified, and callers of
mongoc_cluster_run_command don't need to pass around an is_write_command
bool.
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/89d5430fcad4668468c5bc0ac2748080a036d732

Comment by Githook User [ 22/Oct/15 ]

Author:

{u'username': u'ajdavis', u'name': u'A. Jesse Jiryu Davis', u'email': u'jesse@mongodb.com'}

Message: leak in mongoc_cluster_run_command_with_read_preference

Memory leak in unreleased code for CDRIVER-906.
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/43f9e1be62c34de5b8ef5f79f056305aac556b64

Comment by Githook User [ 21/Oct/15 ]

Author:

{u'username': u'ajdavis', u'name': u'A. Jesse Jiryu Davis', u'email': u'jesse@mongodb.com'}

Message: CDRIVER-906 NULL read prefs means PRIMARY

Simplify some code that handles mongoc_read_prefs_t pointers by
requiring that NULL is allowed and means PRIMARY almost everywhere.
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/6542c20194e4394cbd8eb33bbf7aa6799116fdfc

Comment by Githook User [ 21/Oct/15 ]

Author:

{u'username': u'ajdavis', u'name': u'A. Jesse Jiryu Davis', u'email': u'jesse@mongodb.com'}

Message: CDRIVER-906 redundant error-checking code
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/dedda5ed36678ebe28842350c88b84aeaf6c231c

Comment by Githook User [ 19/Oct/15 ]

Author:

{u'username': u'ajdavis', u'name': u'A. Jesse Jiryu Davis', u'email': u'jesse@mongodb.com'}

Message: CDRIVER-906 rename helper mongoc_read_prefs_is_primary_or_null
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/3e11c248ef2847ae9bbbf1b3408dc8984437d41b

Comment by Githook User [ 19/Oct/15 ]

Author:

{u'username': u'ajdavis', u'name': u'A. Jesse Jiryu Davis', u'email': u'jesse@mongodb.com'}

Message: CDRIVER-906 fix command_simple's read prefs
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/4e48e996c73bd603a91efed4978241d9e06b3237

Comment by Githook User [ 19/Oct/15 ]

Author:

{u'username': u'ajdavis', u'name': u'A. Jesse Jiryu Davis', u'email': u'jesse@mongodb.com'}

Message: CDRIVER-906 new command code detects "no cmd" err
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/aeb9ea4ac6abc95e90202eec1a69f4322aeec708

Comment by Githook User [ 19/Oct/15 ]

Author:

{u'username': u'ajdavis', u'name': u'A. Jesse Jiryu Davis', u'email': u'jesse@mongodb.com'}

Message: CDRIVER-906 remove cursor->is_write_command

Write commands no longer use mongoc_cursor_t.
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/f8dc09ae6f29f083869d918765a687357932ec16

Comment by Githook User [ 19/Oct/15 ]

Author:

{u'username': u'ajdavis', u'name': u'A. Jesse Jiryu Davis', u'email': u'jesse@mongodb.com'}

Message: CDRIVER-906 don't use cursor in command_simple

mongoc_client_command_simple now uses mongoc_cluster_run_command,
instead of creating a mongoc_cursor_t to execute the command.

To support this change, apply_read_preferences and its callers now
take an "is_write_command" bool, and const-correctness is cleaned up
for mongoc_read_pref_t* parameters.
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/db516758aae5488d06a39614186dfddb35f9334c

Comment by Githook User [ 19/Oct/15 ]

Author:

{u'username': u'ajdavis', u'name': u'A. Jesse Jiryu Davis', u'email': u'jesse@mongodb.com'}

Message: CDRIVER-906 refactor topology_server_by_id

mongoc_topology_server_by_id now takes a bson_error_t to fill out if
the server_id is invalid. Add a thread-safe API for getting topology
type and server type at once, update apply_read_preferences to use it.
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/6d68f65cda623e83aaf2caff60d5d96cb5da1d9f

Comment by Githook User [ 14/Oct/15 ]

Author:

{u'username': u'ajdavis', u'name': u'A. Jesse Jiryu Davis', u'email': u'jesse@mongodb.com'}

Message: CDRIVER-906 code layout
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/dacfcb678d759925868dcc97f4d339e189459c1e

Comment by Githook User [ 14/Oct/15 ]

Author:

{u'username': u'ajdavis', u'name': u'A. Jesse Jiryu Davis', u'email': u'jesse@mongodb.com'}

Message: CDRIVER-906 add run_command_with_read_preference

Continuing work for a full-featured command function that doesn't
create a mongoc_cursor_t. Previously I added error-parsing to
run_command, now we need a version of run_command that accepts a read
preference as well.
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/6f2e69857f44d507c3af537191ee3128c48404c8

Comment by Githook User [ 12/Oct/15 ]

Author:

{u'username': u'ajdavis', u'name': u'A. Jesse Jiryu Davis', u'email': u'jesse@mongodb.com'}

Message: CDRIVER-906 move command err parsing into run_command

Further preparations for separating query and command paths.
mongoc_cluster_run_command () is going to become the main internal
implementation of commands, so it should take responsibility for
parsing command errors.
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/268d6a1d8f66b58954c0bec9764a74946c12d1d8

Comment by Githook User [ 08/Oct/15 ]

Author:

{u'username': u'ajdavis', u'name': u'A. Jesse Jiryu Davis', u'email': u'jesse@mongodb.com'}

Message: CDRIVER-906 move read pref & error logic from mongoc-cursor.c

Preparing to separate command path from query path. No new code, just
moving from mongoc-cursor.c the code that will be shared between
commands and queries: the logic to apply a read preference to an
OP_QUERY, and the logic to turn an OP_REPLY into a bson_error_t.
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/9470dba64fa060de585f49ee05b22aa8d636e935

Generated at Wed Feb 07 21:10:58 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.