Announcing libbson and libmongoc 1.5.0
I’m pleased to announce version 1.5.0 of libbson and libmongoc, the libraries constituting the MongoDB C Driver.
libbson
We have a brand-new BSON Type, Decimal128, which MongoDB 3.4 and all drivers now implement.
The BSON “code” and “code with scope” types are better supported now: bson_append_code_with_scope now preserves the “code with scope” type if scope is an empty, non-NULL BSON document, and the “code” and “code with scope” types are properly translated to JSON like this:
'{"$code": "...", "$scope": {...}}'
We still don’t properly parse code and code with scope from JSON, stay tuned for libbson 1.6.
Other changes:
- bson_json_reader functions now always validate UTF-8.
- JSON parsing now preserves integer width.
- bson_strtoll now matches stroll: it detects range errors, and when parsing octal it stops at non-octal digits and returns what it parsed instead of setting errno.
- The configure option “–enable-hardening” had had no effect. It is removed in favor of system-wide compiler configuration.
libmongoc
Most changes to the MongoDB C Driver are for MongoDB 3.4 Support. We have a new option you can set in the URI and read preference option, “maxStalenessSeconds”, which expresses the maximum staleness a secondary can suffer and still be eligible for reads. I wrote the spec for the Max Staleness feature, which applies to all our drivers and to mongos; it’s been a challenge but I think we came up with something useful.
Clients now tell MongoDB about the system you’re running, the driver you use, and other information that can help you debug the source of your operations. You can set extra MongoDB client handshake data with mongoc_client_set_appname or mongoc_client_pool_set_appname.
We have some writeConcern and readConcern enhancements: all commands that write, like createIndexes
or the aggregate
command with $out
, now accept a write concern. We have a new read concern, linearizable
, for the most consistency-conscious applications.
MongoDB now supports collation. As with other databases, our collation feature lets you specifiy language-specific rules for sorting strings. There are collation examples for mongoc_client_read_command_with_opts, mongoc_collection_count_with_opts, mongoc_collection_find_with_opts, and mongoc_index_opt_t, plus the “Setting Collation Order” section of the “Bulk Write Operations” guide.
Hannes improved TLS support even further. On BSD he fixed our LibreSSL (libssl) support and added LibreSSL (libtls) support. On Windows, we can now build with Secure Channel and Visual Studio 2010. (We’d already built successfully with Secure Channel and Visual Studio 2013 and 2015.) Finally, we now support Server Name Indication with OpenSSL—all the other TLS libraries we work with had already supported SNI.
There are additional features for Application Performance Monitoring. You can now register for notifications about server topology changes, such as when a server or topology description changes, and when a monitoring heartbeat begins and succeeds or fails.
We have a stylish new API for executing commands with a flexible set of options passed as a BSON document. Read the docs for mongoc_collection_find_with_opts for details, and consult the list of new functions that implement this style:
- mongoc_client_read_command_with_opts
- mongoc_client_write_command_with_opts
- mongoc_client_read_write_command_with_opts
- mongoc_database_read_command_with_opts
- mongoc_database_write_command_with_opts
- mongoc_database_read_write_command_with_opts
- mongoc_collection_read_command_with_opts
- mongoc_collection_write_command_with_opts
- mongoc_collection_read_write_command_with_opts
- mongoc_gridfs_find_with_opts
- mongoc_gridfs_find_one_with_opts
- mongoc_bulk_operation_remove_one_with_opts
- mongoc_bulk_operation_remove_many_with_opts
- mongoc_bulk_operation_replace_one_with_opts
- mongoc_bulk_operation_update_one_with_opts
- mongoc_bulk_operation_update_many_with_opts
I fixed a tricky bug by making the connectTimeoutMS timer begin after DNS resolution, and reset for each interface attempted (e.g., if the driver first tries IPv6, then IPv4). Besides that bug, we squashed a few others: The random number generator used to select servers is now properly seeded, and secondary queries are now properly distributed according to localThresholdMS, not just to the lowest-latency secondary. The latency estimate is now reset after a connection error. I fixed crashes in mongoc_topology_invalidate_server and mongoc_client_kill_cursor.
I also dramatically improved error reporting when the driver fails to reach the server, and thanks to a bug report from Eliot Horowitz we now correctly distinguish “connection error” and “connection timeout”.
Links:
Thanks to everyone who contributed to this release.
- A. Jesse Jiryu Davis
- Hannes Magnusson
- Fiona Rowan
- Ian Boros
- Remi Collet
- Brian McCarthy
- Jeroen Ooms
- J. Rassi
- Christoph Schwarz
- Alexey Vorobeyev
- Brian Samek
Peace,
— A. Jesse Jiryu Davis
Image © A. Jesse Jiryu Davis