Open
Description
Environment
Rust: rustc 1.82.0 (f6e511eec 2024-10-15)
OS: Linux 31004c8e 6.10.6+bpo-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.10.6-1~bpo12+1 (2024-08-26) x86_64 GNU/Linux
mongodb rust package: 3.2.3
bson rust package: 2.14.0
mongodb server: 4.4.18
mongodb topology: localhost replica set with one member
The bug
I expect Database::list_collections()
method provide cursor which can do .deserialize_current()
for every collection in every database.
In my environment it fails on local.oplog.rs
collection.
In the same time the list_collections()
method from pymongo python packages works fine with same mongodb server i.e. it can iterates over basic data of collections including "local.oplog.rs" collection.
Code which fails
use core::time::Duration;
use mongodb::{
bson::doc,
options::{ClientOptions, ServerAddress},
sync::Client,
};
fn main() {
let client = Client::with_options(
ClientOptions::builder()
.hosts(vec![ServerAddress::parse("localhost").unwrap()])
.build(),
)
.unwrap();
let mut cursor = client
.database("local")
.list_collections()
.filter(doc! {"name": "oplog.rs"})
.run()
.unwrap();
while cursor.advance().unwrap() {
match cursor.deserialize_current() {
Err(error) => {
println!("Raw document:");
println!("{:?}", cursor.current());
cursor.deserialize_current().unwrap();
}
_ => (),
};
}
}
Output
Raw document:
RawDocument { data: "91000000026e616d6500090000006f706c6f672e7273000274797065000b000000636f6c6c656374696f6e00036f7074696f6e73002a0000000863617070656400010173697a6500000000802392f341086175746f496e646578496400000003696e666f002b00000008726561644f6e6c79000005757569640010000000047f25e931b53642cca6a47030796979a20000" }
thread 'main' panicked at src/bin/test.rs:26:46:
called `Result::unwrap()` on an `Err` value: Error { kind: BsonDeserialization(DeserializationError { message: "invalid type: floating point `5253511168.0`, expected u64" }), labels: {}, wire_version: None, source: None }
stack backtrace:
0: rust_begin_unwind
at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/panicking.rs:662:5
1: core::panicking::panic_fmt
at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/panicking.rs:74:14
2: core::result::unwrap_failed
at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/result.rs:1677:5
3: core::result::Result<T,E>::unwrap
at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/result.rs:1102:23
4: test::main
at ./src/bin/test.rs:26:17
5: core::ops::function::FnOnce::call_once
at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Output of mongodb shell collstats command
> db.runCommand({"collstats": "oplog.rs"})
{
"ns" : "local.oplog.rs",
"size" : 5222406025,
"count" : 11329019,
"avgObjSize" : 460,
"storageSize" : 1785073664,
"freeStorageSize" : 12488704,
"capped" : true,
"max" : -1,
"maxSize" : NumberLong("5253511168"),
"sleepCount" : 0,
"sleepMS" : 0,
... SOME OUTPUT IS TRUNCATED
"nindexes" : 0,
"indexDetails" : {
},
"indexBuilds" : [ ],
"totalIndexSize" : 0,
"totalSize" : 1785073664,
"indexSizes" : {
},
"scaleFactor" : 1,
"ok" : 1,
"$clusterTime" : {
"clusterTime" : Timestamp(1742557269, 1),
"signature" : {
"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
"keyId" : NumberLong(0)
}
},
"operationTime" : Timestamp(1742557269, 1)
}
Metadata
Metadata
Assignees
Labels
No labels