Skip to content

Releases: mongodb/mongo-rust-driver

v2.3.0-beta

07 Jun 15:22
514ee4a
Compare
Choose a tag to compare
v2.3.0-beta Pre-release
Pre-release

The MongoDB Rust driver team is pleased to announce the v2.3.0-beta release of the mongodb crate.

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.

The latest release candidate for MongoDB 6.0 is currently available for download here as well as on MongoDB Atlas.

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-1166] - Change streams support for user-facing PIT pre- and post-images
  • [RUST-1193] - Introduce ConnectionString type
  • [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 estimatedDocumentCount

v2.2.2

03 Jun 20:43
Compare
Choose a tag to compare

Description

The MongoDB Rust driver team is pleased to announce the 2.2.2 release of the mongodb crate. This release fixes a performance regression introduced in 2.2.0 for large reads when using rustls. It also fixes a rare bug that can cause commitTransaction retries to fail.

Full Release Notes

Bugfixes

  • RUST-1337 Use tokio's AsyncRead and AsyncWrite traits (#669)
    • This change fixes the performance regression mentioned above.
  • RUST-1274 Fix commitTransaction on checkout retries (#651)

v2.2.1

22 Apr 15:46
076a8db
Compare
Choose a tag to compare

The MongoDB Rust driver team is pleased to announce the v2.2.1 release of the mongodb crate.

This release includes a single change that upgrades the version of our rustc_version_runtime dependency from 0.1.4 to 0.2.1. The older version of rustc_version_runtime would create a file in the crate's src directory as part of the build process, which meant building the crate would fail on read-only file systems such as that used by docs.rs in the documentation process.

Included tickets

  • [RUST-1272] - docs.rs failed to build mongodb-2.2.0

v2.2.0

14 Apr 18:07
92161be
Compare
Choose a tag to compare

Description

The MongoDB Rust driver team is pleased to announce the v2.2.0 release of the mongodb crate.

Highlighted Changes

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

Change Streams (RUST-521, RUST-74, RUST-522, RUST-1149, RUST-523, RUST-1104)

This release adds support for Change Streams, which allow applications to access real-time data changes without the complexity and risk of tailing the oplog. Applications can use change streams to subscribe to all data changes on a single collection, a database, or an entire deployment, and immediately react to them.

let mut change_stream = coll.watch(None, None).await?;
let coll_ref = coll.clone();
task::spawn(async move {
    coll_ref.insert_one(doc! { "x": 1 }, None).await;
});
while let Some(event) = change_stream.next().await.transpose()? {
    println!("operation performed: {:?}, document: {:?}", event.operation_type, event.full_document);
    // operation performed: Insert, document: Some(Document({"x": Int32(1)}))
}

Raw BSON Incorporation (RUST-1133, RUST-1175)

This release uses the new raw BSON types introduced in v2.2 of the bson crate for internal operations, boosting performance in certain circumstances. It also allows for zero-copy deserialization when working with cursors via the new Cursor::deserialize_current method:

use serde::Deserialize;

#[derive(Debug, Deserialize)]
struct Cat<'a> {
    #[serde(borrow)]
    name: &'a str
}

let coll = db.collection::<Cat>("cat");
let mut cursor = coll.find(None, None).await?;
while cursor.advance().await? {
    println!("{:?}", cursor.deserialize_current()?);
}

MSRV and Dependency Update (RUST-1192, RUST-1220)

This release updates the version of all dependencies used by the Rust driver to their most recent, which required an update of the MSRV to 1.51.

OpenSSL Support (RUST-1083)

This release adds optional support for using OpenSSL for TLS streams via the new openssl-tls feature. Note that rustls is still required as a dependency in this case to avoid breaking backwards compatibility; this will be removed in a future major version release.

Full Release Notes

New Features

Bugfixes

  • minor: derive TypedBuilder for TimeseriesOptions (#557)
  • minor: fix external crate links (#552)
  • RUST-1163 Fix load balancer tests (#576)
  • RUST-812 Reduce flakiness of in_window::load_balancing_test (#568)
  • RUST-1163 Fix load balancer auth tests (#581)
  • RUST-1268 Use rustc_version_runtime for runtime metadata (#622)

Improvements

v2.2.0-beta

28 Mar 14:42
bb9d33f
Compare
Choose a tag to compare
v2.2.0-beta Pre-release
Pre-release

Description

The MongoDB Rust driver team is pleased to announce the v2.2.0-beta release of the mongodb crate.

Highlighted Changes

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

Change Streams (RUST-521, RUST-74, RUST-522, RUST-1149, RUST-523, RUST-1104)

This release adds support for Change Streams, which allow applications to access real-time data changes without the complexity and risk of tailing the oplog. Applications can use change streams to subscribe to all data changes on a single collection, a database, or an entire deployment, and immediately react to them.

let mut change_stream = coll.watch(None, None).await?;
let coll_ref = coll.clone();
task::spawn(async move {
    coll_ref.insert_one(doc! { "x": 1 }, None).await;
});
while let Some(event) = change_stream.next().await.transpose()? {
    println!("operation performed: {:?}, document: {:?}", event.operation_type, event.full_document);
    // operation performed: Insert, document: Some(Document({"x": Int32(1)}))
}

Raw BSON Incorporation (RUST-1133, RUST-1175)

This release uses the new raw BSON types introduced in v2.2 of the bson crate for internal operations, boosting performance in certain circumstances. It also allows for zero-copy deserialization when working with cursors via the new Cursor::deserialize_current method:

use serde::Deserialize;

#[derive(Debug, Deserialize)]
struct Cat<'a> {
    #[serde(borrow)]
    name: &'a str
}

let coll = db.collection::<Cat>("cat");
let mut cursor = coll.find(None, None).await?;
while cursor.advance().await? {
    println!("{:?}", cursor.deserialize_current()?);
}

MSRV and Dependency Update (RUST-1192, RUST-1220)

This release updates the version of all dependencies used by the Rust driver to their most recent, which required an update of the MSRV to 1.51.

OpenSSL Support (RUST-1083)

This release adds optional support for using OpenSSL for TLS streams via the new openssl-tls feature. Note that rustls is still required as a dependency in this case to avoid breaking backwards compatibility; this will be removed in a future major version release.

Full Release Notes

New Features

Bugfixes

  • minor: derive TypedBuilder for TimeseriesOptions (#557)
  • minor: fix external crate links (#552)
  • RUST-1163 Fix load balancer tests (#576)
  • RUST-812 Reduce flakiness of in_window::load_balancing_test (#568)
  • RUST-1163 Fix load balancer auth tests (#581)

Improvements

v2.1.0

14 Dec 19:13
Compare
Choose a tag to compare

Description

The MongoDB Rust driver team is pleased to announce the v2.1.0 release of the mongodb crate. This release contains a number of new features, bug fixes, and improvements, most notably support for Atlas Serverless.

Highlighted changes

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

Update dependency on bson to v2.1.0

The exported version of bson was updated to v2.1.0, which includes its own set of changes. Check out the bson release notes for more information.

Support for Atlas Serverless (RUST-653, RUST-983)

This release introduces load balancer support to the Rust driver, which enables it to be used with Atlas Serverless. As part of that, the test suite of the driver was updated to include testing against live Atlas Serverless instances to ensure full compatibility.

Wire protocol compression (RUST-54)

This release adds optional support for compressing the messages sent between the driver and the server. The available compression algorithms are zstd, snappy, and zlib, and they can be enabled via the zstd-compression, snappy-compression, and zlib-compression feature flags respectively. By default, none of the feature flags are enabled.

let mut options = ClientOptions::parse("mongodb://localhost:27017").await?;

// the server will select the algorithm it supports from the list provided by the driver
options.compressors = Some(vec![
    Compressor::Snappy,
    Compressor::Zlib {
        level: Default::default(),
    },
    Compressor::Zstd {
        level: Default::default(),
    },
]);
let client = Client::with_options(options)?;
let resp = client
    .database("admin")
    .run_command(
        doc! {
            "ping": 1
        },
        None,
    )
    .await?;
println!("{}", resp);

Causal consistency (RUST-48)

This release adds driver support for causal consistency and enables it by default on all ClientSessions. For more information on the guarantees provided by causal consistency, check out the MongoDB manual.

let options = SessionOptions::builder().causal_consistency(true).build();
let mut session = client.start_session(Some(options)).await?;

let coll_options = CollectionOptions::builder()
    .read_concern(ReadConcern::majority())
    .write_concern(WriteConcern::builder().w(Acknowledgment::Majority).build())
    .build();
let collection = client
    .database("foo")
    .collection_with_options("bar", coll_options);

collection
    .insert_one_with_session(doc! { "read": "me" }, None, &mut session)
    .await?;
collection
    .find_one_with_session(doc! { "read": "me" }, None, &mut session)
    .await?
    .expect("causal consistency guarantees we can read our own writes");

Full Release Notes

New Features

Bugfixes

  • RUST-1122 Fix x509 auth for pkcs8 keys and Atlas free tier (#532) (thanks for reporting @Zageron!)
  • RUST-856 Fix race between server selection and server monitoring (#460)
  • RUST-992 Fix default authSource for PLAIN authentication (#451)
  • RUST-1037 secondaryPreferred read preference is not forwarded to mongos (#480)
  • RUST-1046 Fix iteration of session cursors when batchSize doesn't divide result size (#483)
  • RUST-1047 Ensure TopologyClosedEvent is the last SDAM event emitted (#485)
  • RUST-1060 Omit non-pub fields from Debug output of ClientOptions (#512)

Improvements

Task

v1.2.5

14 Dec 20:01
Compare
Choose a tag to compare

The MongoDB Rust driver team is pleased to announce the 1.2.5 release of the mongodb crate. This release includes a bug fix for x509 authentication.

v2.1.0-beta

16 Nov 22:50
Compare
Choose a tag to compare
v2.1.0-beta Pre-release
Pre-release

Description

The MongoDB Rust driver team is pleased to announce the v2.1.0-beta release of the mongodb crate. This release is a preview of the upcoming v2.1.0 release, which will be functionally the same but may contain fixes for any bugs identified in this beta. This release contains a number of new features, bug fixes, and improvements, most notably support for Atlas Serverless.

Highlighted changes

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

Update dependency on bson to v2.1.0-beta

The exported version of bson was updated to v2.1.0-beta, which includes its own set of changes. Check out the bson release notes for more information.

Support for Atlas Serverless (RUST-653, RUST-983)

This release introduces load balancer support to the Rust driver, which enables it to be used with Atlas Serverless. As part of that, the test suite of the driver was updated to include testing against live Atlas Serverless instances to ensure full compatibility.

Wire protocol compression (RUST-54)

This release adds optional support for compressing the messages sent between the driver and the server. The available compression algorithms are zstd, snappy, and zlib, and they can be enabled via the zstd-compression, snappy-compression, and zlib-compression feature flags respectively. By default, none of the feature flags are enabled.

let mut options = ClientOptions::parse("mongodb://localhost:27017").await?;

// the server will select the algorithm it supports from the list provided by the driver
options.compressors = Some(vec![
    Compressor::Snappy,
    Compressor::Zlib {
        level: Default::default(),
    },
    Compressor::Zstd {
        level: Default::default(),
    },
]);
let client = Client::with_options(options)?;
let resp = client
    .database("admin")
    .run_command(
        doc! {
            "ping": 1
        },
        None,
    )
    .await?;
println!("{}", resp);

Causal consistency (RUST-48)

This release adds driver support for causal consistency and enables it by default on all ClientSessions. For more information on the guarantees provided by causal consistency, check out the MongoDB manual.

let options = SessionOptions::builder().causal_consistency(true).build();
let mut session = client.start_session(Some(options)).await?;

let coll_options = CollectionOptions::builder()
    .read_concern(ReadConcern::majority())
    .write_concern(WriteConcern::builder().w(Acknowledgment::Majority).build())
    .build();
let collection = client
    .database("foo")
    .collection_with_options("bar", coll_options);

collection
    .insert_one_with_session(doc! { "read": "me" }, None, &mut session)
    .await?;
collection
    .find_one_with_session(doc! { "read": "me" }, None, &mut session)
    .await?
    .expect("causal consistency guarantees we can read our own writes");

Full Release Notes

New Features

Bugfixes

  • RUST-856 Fix race between server selection and server monitoring (#460)
  • RUST-992 Fix default authSource for PLAIN authentication (#451)
  • RUST-1037 secondaryPreferred read preference is not forwarded to mongos (#480)
  • RUST-1046 Fix iteration of session cursors when batchSize doesn't divide result size (#483)
  • RUST-1047 Ensure TopologyClosedEvent is the last SDAM event emitted (#485)
  • RUST-1060 Omit non-pub fields from Debug output of ClientOptions (#512)

Improvements

Task

v2.0.2

12 Nov 21:01
Compare
Choose a tag to compare

Description

The MongoDB Rust driver team is pleased to announce the 2.0.2 release of the mongodb crate. This release includes a minor bug fix.

  • RUST-1060 Omit non-pub fields from Debug output of ClientOptions (#516)

v1.2.4

12 Nov 21:51
Compare
Choose a tag to compare

Description

The MongoDB Rust driver team is pleased to announce the 1.2.4 release of the mongodb crate. This release includes a minor bug fix.

  • RUST-1060 Omit non-pub fields from Debug output of ClientOptions (#516)