[CDRIVER-2218] Only topology scanner performs MongoDB Handshake Created: 19/Jul/17  Updated: 28/Oct/23  Resolved: 08/Aug/17

Status: Closed
Project: C Driver
Component/s: libmongoc
Affects Version/s: None
Fix Version/s: 1.8.0

Type: Bug Priority: Major - P3
Reporter: Patrick Freed Assignee: Hannes Magnusson
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Gantt Dependency
has to be done before CXX-1340 Write integration tests for client me... Closed

 Description   

When using a client pool with a uri that has the ?appName=<something> option specified, none of the clients received from the pool will have the name passed to it. This is caused by the following lines 752-757 of mongoc-client.c, duplicated here:

   appname =
      mongoc_uri_get_option_as_utf8 (client->uri, MONGOC_URI_APPNAME, NULL);
   if (appname && client->topology->single_threaded) {
      /* the appname should have already been validated */
      BSON_ASSERT (mongoc_client_set_appname (client, appname));
   }

single_threaded is set to false when using a pool, as set at mongoc-client-pool.c:111.

This seems like a bug to me, but I could be misunderstanding how pools are meant to interact with the appName. The setting is explicitly excluded for multi-threaded contexts, so maybe this is intended. If it is indeed a bug, it should be fixed.



 Comments   
Comment by Githook User [ 08/Aug/17 ]

Author:

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

Message: Merge branch 'CDRIVER-2218-appname'

Comment by Githook User [ 08/Aug/17 ]

Author:

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

Message: Merge branch 'CDRIVER-2218-appname'

Comment by Githook User [ 08/Aug/17 ]

Author:

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

Message: Merge branch 'CDRIVER-2218-appname'

Comment by Githook User [ 08/Aug/17 ]

Author:

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

Message: CDRIVER-2218 Only topology scanner performs MongoDB Handshake
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/fb1031b76f1e28bdf96bb51cc5e71926b675f222

Comment by A. Jesse Jiryu Davis [ 20/Jul/17 ]

Good catch. bjori I think he's right that it's a bug. The handshake spec says,

The isMaster handshake MUST be performed on every socket to any and all servers upon establishing the connection to MongoDB, including reconnects of dropped connections and newly discovered members of a cluster. It MUST be the first command sent over the respective socket. If the command fails the client MUST disconnect.

Therefore, the cluster handshake from a pooled client should send appName. This will be easy to check with a mock server test.

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