Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
abhi3700 opened this issue Dec 5, 2024 · 1 comment
Closed

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

abhi3700 opened this issue Dec 5, 2024 · 1 comment
Assignees
Labels

Comments

@abhi3700
Copy link

abhi3700 commented Dec 5, 2024

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
@abhi3700
Copy link
Author

abhi3700 commented Dec 6, 2024

FIX:
Upgraded my shared cluster (FREE tier) to a dedicated cluster (Paid tier).

@abhi3700 abhi3700 closed this as completed Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants