Releases: mongodb/mongo-rust-driver
v2.7.0-beta
The MongoDB Rust driver team is pleased to announce the v2.7.0-beta release of the mongodb
crate, now available for download from crates.io.
Highlighted Changes
BETA: Serialization Behavior Change
When serializing values via serde, the serializer can indicate whether or not the target format is human-readable, allowing types to change behavior based on that. The Rust driver had inadvertently been serializing values given to find_one_and_replace
and replace_one
as human-readible when all other methods serialize as non-human-readible; this bug is fixed in 2.7.0-beta, with those methods also serializing as non-human-readible.
However, it is potentially possible (if unlikely) that user code may rely on this bug, so out of an abundance of caution we are releasing this version as a beta. If your code does rely on human-readable serialization, you can specify that via the new human_readable_serialization
field in CollectionOptions
.
run_cursor_command
The Rust driver provides the run_command
method as a way for users to directly send bson commands to the server; this is particularly useful when the driver does not yet have support for a newly-added server command. However, using this with commands that return a cursor requires re-implementing the logic for cursor iteration, which can be tedious and error-prone. The new run_cursor_command
method avoids those problems, directly returning a Cursor
using the same iteration logic as other methods.
SDAM Logging
The Rust driver will now log SDAM events when using the tracing-unstable
feature.
Client Management
The Client
type now provides three additional ways to shape behavior to fit your workload:
ClientOptions.max_connecting
lets you specify how many "in flight" connections can be established in parallel. This was previously fixed at 2 and defaults to the same value.Client::warm_connection_pool
will create new connections to bring the connection pool up tomin_pool_size
, which can provide more predictable performance in some circumstances.Client::shutdown
will cleanly stop background tasks and wait for outstanding handles to be dropped. This is particularly useful when using event handlers that reference external resources, as otherwise those handlers may be invoked in a background task even after theClient
has been dropped.
Included Changes
Below are a selected list of changes with user impact; for a full list of changes see this GitHub query.
New Features
- RUST-1420 Cache AWS credentials received from endpoints (#905)
- RUST-1604 Add custom bucketing fields to timeseries options (#907)
- RUST-1588: Add RunCursorCommand (#912)
- RUST-802 Support Unix Domain Sockets (#908) (thanks @PureWhiteWu!)
- RUST-1509 SDAM Logging (#918)
- RUST-1608 Clean shutdown for Client (#920)
- RUST-1712 Provide a connection pool warmup method (#932)
- RUST-1712 Support User Configuration for max_connecting (#923) (thanks @LuisOsta!)
- RUST-1687 Add human_readable_serialization option to Collection (#902) (thanks @maiconpavi!)
Improvements
- RUST-1433 Propagate original error for some labeled retry errors (#903)
- minor: improve README.md (#934)
- upgrade webpki (#935) (thanks @fuchsnj!)
Bugfixes
v2.6.1
The MongoDB Rust driver team is pleased to announce the v2.6.1 release of the mongodb
crate, now available for download from crates.io. This release removes a potential panic from the SessionCursor::with_type
method.
Included Changes
Bugfixes
v2.6.0
The MongoDB Rust driver team is pleased to announce the v2.6.0 release of the mongodb
crate, now available for download from crates.io.
Included Changes
Below are a selected list of changes with user impact; for a full list of changes see this GitHub query.
New Features
- RUST-1421 Implement
FromStr
forNamespace
(#889) - RUST-906 Add native support for AWS IAM Roles for service accounts, EKS in particular (#885)
- RUST-1417 Add support for GCP attached service accounts when using GCP KMS (#877)
- RUST-1442 On-demand Azure KMS credentials (#872)
- RUST-1571 Add i64 server ID field to
ConnectionInfo
(#894)
Improvements
Bugfixes
- RUST-1645 Fix AWS Lambda detection logic (#876)
- RUST-1370 Only check specific fields for hello equality (#892)
Tasks
v2.5.0
The MongoDB Rust driver team is pleased to announce the v2.5.0 release of the mongodb
crate, now available for download from crates.io.
Highlighted Changes
In-Use Encryption: Automatically Create Keys
This release adds the ClientEncryption::create_encrypted_collection
helper method, which will automatically create encryption keys as needed when creating a collection with the encrypted_fields
option.
Convenient Transactions
This release adds the ClientSession::with_transaction
helper method, which will handle automatically creating, retrying, and committing or aborting a transaction.
Included Changes
Below are a selected list of changes with user impact; for a full list of changes see this GitHub query.
New Features
- RUST-1587 Implement server selection tracing events (#805)
- RUST-1314 Support on-demand AWS credentials for in-use encryption (#831)
- RUST-107 Convenient transactions (#849)
- RUST-1411 Add create_encrypted_collection helper (#853)
Improvements
- RUST-1069 Defer implicit session check out until after connection check out (#811)
- RUST-1582 Expose collection.client() as public (#822) (Thanks LuisOsta!)
- RUST-1503 Test csfle against older server versions (#832)
- RUST-1607: allow uuidRepresentation in connection string (#838) (Thanks terakilobyte!)
- RUST-1501 Collect FaaS platform metadata (#844)
- RUST-1585 Do not perform server selection to determine sessions support (#854)
Bugfixes
v2.4.0
The MongoDB Rust driver team is pleased to announce the v2.4.0 release of the mongodb
crate, now available for download from crates.io.
Highlighted Changes
In-Use Encryption
This release brings support for Client-Side Field Level Encryption and Queryable Encryption. For detailed installation and usage instructions, please see the Encryption section of the driver manual. Please note that the API is currently unstable and may change in breaking ways in future releases.
GridFS
This release adds support for GridFS, allowing storage and retrieval of files that exceed the BSON document size limit. Please see the documentation of the new gridfs module for more information.
Streaming Monitoring Protocol
This release can now use the streaming monitoring protocol with MongoDB 4.4+ servers, reducing the time it takes for the client to discover server state changes compared to the old polling protocol.
Tracing Integration
The driver now emits tracing
events at points of interest. To consume these events, you must enable the driverโs tracing-unstable
feature flag and either:
- register a tracing
Subscriber
in your application (see the tracing docs), OR - register a
log
-compatible logger in your application (see thelog
documentation for details), and enable alog
compatibility feature flag fortracing
, as detailed here.
This API is considered unstable as the tracing
crate has not reached 1.0 yet; future minor versions of the driver may upgrade the tracing
dependency to a new version which is not backwards-compatible with Subscriber
s that depend on older versions of tracing
.
Events will be emitted under the following targets:
mongodb::command
: Events related to command execution starting, succeeding, or failing.mongodb::connection
: Events related to the driverโs underlying connection pools and their connections.
Future work will introduce events under additional targets and may add driver-defined tracing spans for intervals of interest.
MSRV Increase
The minimum supported Rust version (MSRV) for this crate is now Rust 1.57.
Included Changes
Below are a selected list of changes with user impact; for a full list of changes see this GitHub query.
New Features
- RUST-1384 Implement auto encryption (#717)
- RUST-1385 Implement explicit encryption (#726)
- RUST-1305 Use uuid 1.x internally and add support for bson uuid 1.x (#709)
- RUST-1400 GridFS download methods (#747)
- RUST-1478 GridFS upload methods (#751)
- RUST-1401 Additional GridFS API (#763)
- RUST-580 Add tracing integration and command tracing events (#757)
- RUST-1510 Implement connection pool tracing messages (#766)
Improvements
- RUST-360 Streaming monitoring protocol (#721)
- RUST-1071 Add comment field to all options structs
- minor: improve compile error when sync and tokio-runtime features are enabled (#788)
- extend error types to impl serialization (#797) (Thanks borngraced!)
Bugfixes
- RUST-1443 Ensure monitors close after server is removed from topology (#744)
- RUST-1576 Allow "timeseries"-typed collections in list_collections output (#814)
- minor: fix documentation of new features (#823)
Tasks
- RUST-1253 Add AWS Lambda Examples (#714)
- Deps: bump dependencies (#722) (Thanks Some-Dood!)
- RUST-1445 Bump MSRV to 1.57 (#727)
- RUST-1403 Remove oldtime feature from chrono dependency (#691) (Thanks oskgo!)
- RUST-1450 Bump pretty_assertions dependency to 1.3.0 (#734)
- Fix typo in README (#735) (Thanks sgasse!)
- minor: document cursor/change stream Drop implementations (#745)
- RUST-1560 Fix README typo (#798) (Thanks lonesometraveler!)
v2.4.0-beta.2
The MongoDB Rust driver team is pleased to announce the v2.4.0-beta.2 release of the mongodb
crate, now available for download from crates.io. Please note that this is a beta release; the API for in-use encryption may change between this and the final 2.4.0 release.
Highlighted Changes
This release fixes a bug that caused the documentation for in-use encryption not to render on docs.rs.
v2.4.0-beta.1
The MongoDB Rust driver team is pleased to announce the v2.4.0-beta.1 release of the mongodb
crate, now available for download from crates.io. Please note that this is a beta release; the API for in-use encryption may change between this and the final 2.4.0 release.
Highlighted Changes
This release fixes a bug that could cause list_collections
to fail when timeseries collections were present; see RUST-1576 for details.
v2.4.0-beta
The MongoDB Rust driver team is pleased to announce the v2.4.0-beta release of the mongodb
crate, now available for download from crates.io. Please note that this is a beta release; the API for in-use encryption may change between this and the final 2.4.0 release.
Highlighted Changes
In-Use Encryption
This release brings support for Client-Side Field Level Encryption and Queryable Encryption. For detailed installation and usage instructions, please see the Encryption section of the driver manual. Please note that rewrapManyDataKey
and automatic KMS credentials are not yet supported in the Rust driver.
GridFS
This release adds support for GridFS, allowing storage and retrieval of files that exceed the BSON document size limit. Please see the documentation of the new gridfs module for more information.
Streaming Monitoring Protocol
This release can now use the streaming monitoring protocol with MongoDB 4.4+ servers, reducing the time it takes for the client to discover server state changes compared to the old polling protocol.
Tracing Integration
The driver now emits tracing
events at points of interest. To consume these events, you must enable the driverโs tracing-unstable
feature flag and either:
- register a tracing
Subscriber
in your application (see the tracing docs), OR - register a
log
-compatible logger in your application (see thelog
documentation for details), and enable alog
compatibility feature flag fortracing
, as detailed here.
This API is considered unstable as the tracing
crate has not reached 1.0 yet; future minor versions of the driver may upgrade the tracing
dependency to a new version which is not backwards-compatible with Subscriber
s that depend on older versions of tracing
.
Events will be emitted under the following targets:
mongodb::command
: Events related to command execution starting, succeeding, or failing.mongodb::connection
: Events related to the driverโs underlying connection pools and their connections.
Future work will introduce events under additional targets and may add driver-defined tracing spans for intervals of interest.
MSRV Increase
The minimum supported Rust version (MSRV) for this crate is now Rust 1.57.
Included Changes
Below are a selected list of changes with user impact; for a full list of changes see this GitHub query.
New Features
- RUST-1384 Implement auto encryption (#717)
- RUST-1385 Implement explicit encryption (#726)
- RUST-1305 Use uuid 1.x internally and add support for bson uuid 1.x (#709)
- RUST-1400 GridFS download methods (#747)
- RUST-1478 GridFS upload methods (#751)
- RUST-1401 Additional GridFS API (#763)
- RUST-580 Add tracing integration and command tracing events (#757)
- RUST-1510 Implement connection pool tracing messages (#766)
Improvements
- RUST-360 Streaming monitoring protocol (#721)
- RUST-1071 Add comment field to all options structs
- minor: improve compile error when sync and tokio-runtime features are enabled (#788)
- extend error types to impl serialization (#797) (Thanks borngraced!)
Bugfixes
Tasks
- RUST-1253 Add AWS Lambda Examples (#714)
- Deps: bump dependencies (#722) (Thanks Some-Dood!)
- RUST-1445 Bump MSRV to 1.57 (#727)
- RUST-1403 Remove oldtime feature from chrono dependency (#691) (Thanks oskgo!)
- RUST-1450 Bump pretty_assertions dependency to 1.3.0 (#734)
- Fix typo in README (#735) (Thanks sgasse!)
- minor: document cursor/change stream Drop implementations (#745)
- RUST-1560 Fix README typo (#798) (Thanks lonesometraveler!)
v2.3.1
The MongoDB Rust driver team is pleased to announce the v2.3.1 release of the mongodb
crate, now available for download from crates.io.
This release fixes a bug that caused connection establishment when using async-std to be blocking, and another bug that would cause the driver to attempt to continue monitoring servers that were removed from the topology.
Full Release Notes
Bugfixes
v2.3.0
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 Client
s.
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:
ConnectionString
only contains client options that are universal across MongoDB drivers and can be set via a MongoDB connection string, whereasClientOptions
also contains Rust driver-specific options,- When using a
mongodb+srv
connection string, initializing aClientOptions
will perform SRV and TXT lookup, whereas initializing aConnectionString
will not. Note that if aConnectionString
is initialized and then used to construct aClientOptions
or aClient
, 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 withInvalidOptions
error - [RUST-1328] -
ServerDescriptionChangedEvent
s 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 toEstimatedDocumentCountOptions
- [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