Skip to content

update_one has overflowed its stack #1255

Closed
@zhuxiujia

Description

@zhuxiujia

see test code

tokio = { version = "1", features = ["macros"] }
serde = { version = "1.0", features = ["derive"] }
mongodb = { version = "3.1", features = [] }
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct Comment {
    #[serde(rename = "_id")]
    pub id: ObjectId,
    pub parent_id: Option<ObjectId>,

    pub user_id: ObjectId,
    pub user_name: String,
    pub user_avatar: String,
    pub user_content: String,
    pub user_image: String,
    pub user_vip: i32,

    pub user_like_count: i64,

    pub user_thumb_up_status: i32,

    pub level: i32,

    pub reply_user_id: String,
    pub reply_user_name: String,
    pub reply_user_avatar: String,
    pub reply_user_vip: i32,

    pub create_time: bson::DateTime,
    pub update_time: Option<bson::DateTime>,
    pub childs: Vec<ObjectId>,
}
pub async fn connect(url: &str) -> Result<Client, Error> {
    //"mongodb+srv://<username>:<password>@<cluster-url>/<dbname>?w=majority",
    let client_options = ClientOptions::parse(url).await?;
    let client = Client::with_options(client_options)?;
    Ok(client)
}
#[tokio::test]
async fn test_update() {
    let comment = Comment {
        id: ObjectId::from_str("674d7a29cfb65f58092f91d5").unwrap(),
        parent_id: None,
        user_id: Default::default(),
        user_name: "".to_string(),
        user_avatar: "".to_string(),
        user_content: "".to_string(),
        user_image: "".to_string(),
        user_vip: 0,
        user_like_count: 0,
        user_thumb_up_status: 0,
        level: 0,
        reply_user_id: "".to_string(),
        reply_user_name: "".to_string(),
        reply_user_avatar: "".to_string(),
        reply_user_vip: 0,
        create_time: bson::DateTime::now().into(),
        update_time: None,
        childs: vec![],
    };
    let client = connect("mongodb://127.0.0.1:27017").await.unwrap();
    let c = client.database("local").collection::<Comment>("comment");
    c.update_one(
        doc! {"_id": comment.id.clone()},
        UpdateModifications::from(doc! {"$set": comment}),
    )
    .await
    .unwrap();
}
  • log
thread 'test_update' has overflowed its stack
fatal runtime error: stack overflow
error: test failed, to rerun pass `-p xuangyin --test comment`

Caused by:
  process didn't exit successfully: `/Users/zxj/RustroverProjects/xuangyin_server/target/debug/deps/comment-c03b25efe0528ec9 test_update --format=json --exact -Z unstable-options --show-output` (signal: 6, SIGABRT: process abort signal)
error: 1 target failed:
    `-p xuangyin --test comment`

Process finished with exit code 101

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions