You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What version of Rust are you using? rustc 1.84.0-nightly
What operating system are you using?
macOS
What versions of the driver and its dependencies are you using? (Run cargo pkgid mongodb & cargo pkgid bson) registry+https://github.com/rust-lang/crates.io-index#[email protected] registry+https://github.com/rust-lang/crates.io-index#[email protected]
What version of MongoDB are you using? (Check with the MongoDB shell using db.version()) 8.0.3
What is your MongoDB topology (standalone, replica set, sharded cluster, serverless)?
replica set
Describe the bug
Error when calling bulk_write function.
BE SPECIFIC:
What is the expected behavior and what is actually happening? bulk_write fn is supposed to work fine like other DB operations (insert_one, update_one, delete_one...). Also, defined namespace as well.
Do you have any particular output that demonstrates this problem?
Do you have any ideas on why this may be happening that could give us a
clue in the right direction?
I searched in the internet, may be due to the cluster being shared which I don't believe.
Did this issue arise out of nowhere, or after an update (of the driver,
server, and/or Rust)?
I am using bulk_write for the 1st time in any of the rust crate version. So, not sure about its output in older version.
Are there multiple ways of triggering this bug (perhaps more than one
function produce a crash)?
If you know how to reproduce this bug, please include a code snippet here:
View code
#[tokio::main]asyncfnmain() -> eyre::Result<()>{
dotenvy::from_path("./.env").expect("Failed to load the env file");let mongodb_uri = std::env::var("MONGODB_URI").expect("Invalid MONGODB_URI");let client = mongodb::Client::with_uri_str(mongodb_uri).await.expect("Failed to connect to MongoDB");let db = client.database("hello");let collection:Collection<Document> = db.collection("hello3");// M-1: multiple requests to DB for delete, insert, update.// m_1(&collection).await?;m_2(&db,&collection).await?;Ok(())}asyncfnm_2(db:&Database,collection:&Collection<Document>) -> eyre::Result<()>{let sample = doc!{"balance":Decimal128::from_str("1002343243235352.034325345233243241")?,"pending_amt":Decimal128::from_str("200.03456")?
};let num = Decimal128::from_str("100.434")?;let pipeline = vec![
doc! {"$set":{"balance":{"$add":["$balance",
bson!(num)]}}},
doc! {"$set":{"balance":{"$subtract":["$balance",
bson!(num)]}}},
doc! {"$set":{"balance":{"$subtract":["$balance","$pending_amt"]}}},];let namespace = collection.namespace();let namespace = Namespace{db:"hello".to_string(),coll:"hello3".to_string()};println!("{:?}", namespace);let delete_model = WriteModel::DeleteOne(DeleteOneModel::builder().filter(doc!{}).collation(None).hint(None).namespace(namespace.clone()).build(),);let insert_model = WriteModel::InsertOne(InsertOneModel::builder().document(sample).namespace(namespace.clone()).build(),);let update_model = WriteModel::UpdateOne(UpdateOneModel::builder().filter(doc!{}).update(pipeline).array_filters(None).collation(None).hint(None).namespace(namespace).build(),);let models = vec![delete_model, insert_model, update_model];// let result = db.client().bulk_write(models).await?;let result = collection.client().bulk_write(models).await?;println!("{:?}", result);Ok(())}
Versions/Environment
rustc 1.84.0-nightly
macOS
cargo pkgid mongodb
&cargo pkgid bson
)registry+https://github.com/rust-lang/crates.io-index#[email protected]
registry+https://github.com/rust-lang/crates.io-index#[email protected]
db.version()
)8.0.3
replica set
Describe the bug
Error when calling
bulk_write
function.BE SPECIFIC:
bulk_write
fn is supposed to work fine like other DB operations (insert_one, update_one, delete_one...). Also, defined namespace as well.clue in the right direction?
I searched in the internet, may be due to the cluster being shared which I don't believe.
server, and/or Rust)?
I am using
bulk_write
for the 1st time in any of the rust crate version. So, not sure about its output in older version.function produce a crash)?
View code
To Reproduce
Steps to reproduce the behavior:
cargo r
The text was updated successfully, but these errors were encountered: