Skip to content

v2.3.0

Compare
Choose a tag to compare
@kmahar kmahar released this 19 Jul 15:45
· 391 commits to main since this release
39b53d8

The MongoDB Rust driver team is pleased to announce the v2.3.0 release of the mongodb crate, now available for download from crates.io.

Highlighted Changes

The following sections detail some of the major changes included in this release. For a full list of changes, see the Full Release Notes section below.

MSRV Increase (RUST-1263)

The minimum supported Rust version (MSRV) for this crate is now Rust 1.53.

MongoDB 6.0 Support

This release adds support for a number of new features added in MongoDB 6.0, including change streams with document pre- and post-images and clustered collections.

MongoDB 6.0 is now GA and available for use on MongoDB Atlas, and can also be downloaded here. Release notes for MongoDB 6.0 can be found here.

Changes to mongodb::Collection::estimated_document_count implementation (RUST-1216)

When adding support for MongoDB 5.0, the driver's implementation of estimated_document_count was changed from using the count command to the aggregate command with the $collStats aggregation stage. This change first appeared in our 2.0.0-alpha.1 release. This change inadvertently broke support for using this method on views, as they do not support using $collStats.
In this release, we have reverted that change, and estimated_document_count is now once again implemented using the count command.
Please note that due to an oversight, count was omitted from the MongoDB Stable API version 1 in MongoDB server versions 5.0.0-5.0.8 and 5.1.0-5.3.1. Consequently, users of the Stable API who use estimated_document_count are recommended to either upgrade their MongoDB clusters to 5.0.9+ or 5.3.2+ (if on Atlas), or to set ClientOptions.server_api.strict to false when constructing Clients.

New ConnectionString type

RUST-1193 introduced a new public mongodb::options::ConnectionString type, which models a MongoDB connection string. This type can be used to parse a connection string and inspect and manipulate its contents, and to initialize a mongodb::options::ClientOptions, and in turn a mongodb::Client.

For example:

use mongodb::{
    Client,
    options::{ClientOptions, ConnectionString},
};

let mut conn_str = ConnectionString::parse("mongodb://localhost:27017/?appName=myApp1")?;
println!("{:?}", conn_str.app_name); // prints: Some("myApp1")
conn_str.app_name = Some("newAppName".to_string());
println!("{:?}", conn_str.app_name); // prints: Some("newAppName")

let options = ClientOptions::parse_connection_string(conn_str).await?;
let client = Client::with_options(options)?;

The differences between a ConnectionString and ClientOptions are that:

  1. ConnectionString only contains client options that are universal across MongoDB drivers and can be set via a MongoDB connection string, whereas ClientOptions also contains Rust driver-specific options,
  2. When using a mongodb+srv connection string, initializing a ClientOptions will perform SRV and TXT lookup, whereas initializing a ConnectionString will not. Note that if a ConnectionString is initialized and then used to construct a ClientOptions or a Client, SRV/TXT lookup will be performed at that time.

Included Tickets

Below are a selected list of tickets with user impact; for a full list of completed tickets see this Jira query.

Bug

  • [RUST-332] - Operations don't report errors for invalid setName in single topologies
  • [RUST-1274] - commitTransaction retry sometimes fails with InvalidOptions error
  • [RUST-1328] - ServerDescriptionChangedEvents for servers with errors always emitted even when description does not change
  • [RUST-1337] - Significant performance regression in large reads

New Feature

  • [RUST-910] - Add server connectionId to command monitoring events
  • [RUST-1070] / [RUST-1145] - Support let option for multiple CRUD commands
  • [RUST-1166] - Change streams support for user-facing PIT pre- and post-images
  • [RUST-1193] - Introduce ConnectionString type
  • [RUST-1215] - Add comment option to EstimatedDocumentCountOptions
  • [RUST-1271] - Clustered Indexes for all Collections
  • [RUST-1290] - Always report wallTime in the change stream event output

Task

Improvement

  • [RUST-488] - Allow using both async and sync API
  • [RUST-585] - Refactor Topology to use channels instead of locks
  • [RUST-803] - Use "hello" command for monitoring if supported
  • [RUST-1152] - Use hello command + OP_MSG when 'loadBalanced=True'
  • [RUST-1168] - Do not error when parsing change stream event documents
  • [RUST-1216] - Use the count command instead of collStats to implement estimated_document_count
  • [RUST-616] - Raise an error if response messageLength > ismaster.maxMessageSizeBytes