Skip to content

Command failed: Error code 8000 (AtlasError): missing nsInfo #1260

Closed
@abhi3700

Description

@abhi3700

Versions/Environment

  1. What version of Rust are you using?
    rustc 1.84.0-nightly
  2. What operating system are you using?
    macOS
  3. 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]
  4. What version of MongoDB are you using? (Check with the MongoDB shell using db.version())
    8.0.3
  5. 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?
Error: Kind: Command failed: Error code 8000 (AtlasError): missing nsInfo, labels: {}
  • 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]
async fn main() -> 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(())
}


async fn m_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(())
}

To Reproduce
Steps to reproduce the behavior:

  1. Used the code above.
  2. Run via cargo r
  3. Bug occurs.
Namespace { db: "hello", coll: "hello3" }
Error: Kind: Command failed: Error code 8000 (AtlasError): missing nsInfo, labels: {}

Location:
    libs/databases/mongo/demo/examples/hello3.rs:150:18

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions