Uploaded image for project: 'Rust Driver'
  1. Rust Driver
  2. RUST-597

Running a mongodb query from an actix-web handler fails to build on rust's stable-x86_64-unknown-linux-gnu toolchain.

    • Type: Icon: Bug Bug
    • Resolution: Works as Designed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:

      /*
      The code below can be used to reproduce the error on stable-x86_64-unknown-linux-gnu

      The build process failed with an out-of-memory error on stable but builds okay on nightly.

      My machine has a RAM capacity of 11.6GiB and a 2GiB swap memory capacity. Before build 6.8GiB RAM and 336.0MiB of swap memory is in use. During build, the RAM and swap memory usage rises in an almost linear manner during the final build phase.

      Cargo.toml
      =========

      [dependencies]
      mongodb = "1.1"
      actix-web = "3"

      main.rs
      ======
      */

      use actix_web::

      {get, web, App, HttpResponse, HttpServer}

      ;
      use mongodb::

      {bson::Document, Client, Database}

      ;

      pub struct AppState

      { pub db: Database, }

      #[get("/test")]
      async fn test(state: web::Data<AppState>) -> HttpResponse

      { let _ = state .db .collection("scrolls") .find_one(Document::new(), None) .await; HttpResponse::Ok().json(true) }

      #[actix_web::main]
      async fn main() -> Result<(), std::io::Error> {
      let result = Client::with_uri_str("mongodb://localhost:27017/").await;
      let client = result.expect("Failed to connect!");

      HttpServer::new(move || {
      App::new()
      .data(AppState

      { db: client.database("gateway"), }

      )
      .service(test)
      })
      .bind("127.0.0.1:8080")?
      .run()
      .await
      }

            Assignee:
            patrick.freed@mongodb.com Patrick Freed
            Reporter:
            crystalflow.mwangi@gmail.com Samuel Mwangi
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: