-
Type: Improvement
-
Resolution: Unresolved
-
Priority: Unknown
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
Summary
The mongoc_handshake_data_append logic has some limitations as to how much data we can collect about our clients. Since the first call to `mongoc_handshake_data_append` locks in metadata, which is then used for all clients created afterwards, this can cause wrong data to be collected, even when mongoc_cleanup is called correctly.
Motivation
While evaluating the PHP driver usage on Atlas, I noticed that apparently 60% of our users only use the MongoDB extension, but not the high-level API. Based on personal observations, I consider this number to be way too low, which led me to suspecting that we are getting incorrect data.
For one, the amount of data we can send is limited, and I'm not sure we're sending the right data in the right format. However, this is not something that we can fix here, as the handshake spec defines what to do here. I'll file a separate DRIVERS ticket for that effort.
Particularly for PHP, there are multiple places where we need to add info to the metadata. The PHP extension adds its own name and version, as does the PHP library. The Doctrine ODM does this as well, but this doesn't show up at all. There is a separate problem in ODM about this, but we'd expect the PHP library information to show up correctly. However, the following code would report only usage for ext-mongodb, but not for the library when both manager and client connect to the server:
$manager = new MongoDB\Driver\Manager(null, [], ['disableClientPersistence' => true]); $client = new MongoDB\Client(null, [], ['disableClientPersistence' => true]);
The first instantiation of a Manager object calls `mongoc_handshake_data_append`, which freezes the handshake struct, rendering the second call (when creating a new manager with different app metadata) useless and always reporting `ext-mongodb` usage.
Changing this behaviour would not only help report correct data, but it also solves the issue if we look at the higher-level applications as well: if a customer used Symfony and Laravel and uses the same application server to run both applications, we'd only ever get one usage reported, as PHP processes usually do not terminate (CLI being a notable exception) after serving a request. A PHP process that first handles a script that connects to MongoDB using Laravel, then later handles a script that connects to MongoDB using Symfony, we'd never know the customer was using Symfony at all.
- is related to
-
CDRIVER-3441 Document mongoc_handshake_data_append
- Closed
-
CDRIVER-3864 Allow mongoc_handshake_data_append to operate on a client level
- Backlog
- related to
-
CDRIVER-1547 Replace global state with context objects
- Backlog