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

SIGINT not working on 4-rc3 #2638

Closed
rex-remind101 opened this issue Feb 8, 2022 · 9 comments
Closed

SIGINT not working on 4-rc3 #2638

rex-remind101 opened this issue Feb 8, 2022 · 9 comments
Labels
N/A Not applicable or remedied without code change.

Comments

@rex-remind101
Copy link

Expected Behavior

^C sends SIGINT and kills the program after updating from 3.3.3 ro 4-rc3.

Current Behavior

SIGINT is ignored.

Possible Solution

Stop ignoring the signal.

Steps to Reproduce (for bugs)

  1. Cargo.toml updates dependency to actix-web = "4.0.0-rc.3".
  2. cargo run.
  3. ^C.
  4. ???.
  5. The program does not terminate.

Context

Trying to kill the program.

Your Environment

macOS 11.6.
rustc 1.58.1 (db9d1b20b 2022-01-20)
actix-web = "4.0.0-rc.3"

@robjtede
Copy link
Member

robjtede commented Feb 8, 2022

can you post your app code too

@rex-remind101
Copy link
Author

In totality I cannot, but if there's something specific you need I could likely post that.

@rex-remind101
Copy link
Author

rex-remind101 commented Feb 8, 2022

We had also updated to this:

async-graphql = "3.0.29"
async-graphql-actix-web = "3.0.29"

so that's a possible confounder.

@robjtede
Copy link
Member

robjtede commented Feb 8, 2022

Just your main fn would do, things related to server set up

@rex-remind101
Copy link
Author

#[actix_web::main]
async fn main() -> std::io::Result<()> {
    env_logger::init();
    // Initialize opentracing.
    let statsd_string_url = env::var_os("redacted").extract_or("localhost:redacted_port");
    let _tracer = new_pipeline()
        .with_agent_endpoint("http://".to_string() + &statsd_string_url)
        .with_service_name("redacted")
        .with_version(<redacted>)
        .install_batch(opentelemetry::runtime::Tokio)
        .unwrap();

    let db_url = env::var_os("redacted")
        .extract_or("redacted");
    let pool = Arc::new(
        PgPoolOptions::new()
            .max_connections(<redacted_uint>)
            .connect(db_url.as_str())
            .await
            .unwrap(),
    );

    let schema = Schema::build(schema::MyQuery, EmptyMutation, EmptySubscription).finish();

    HttpServer::new(move || {
        App::new()
            .wrap_fn(|request, service| {
                // Wrap every request in a trace.
                let tracer = opentelemetry::global::tracer("redacted");
                let name = request.path().to_string();
                let span_builder = tracer.span_builder(name.clone());
                let span = span_builder
                    .start(&tracer);
                let ctx = Context::current_with_span(span);
                let _guard = ctx.clone().attach();

                let result = service.call(request).with_context(ctx.clone());

                use futures::FutureExt;
                result.map(move |response| {
                    let status_code = match &response {
                        ...redacted, returns an integer http status code
                    };
                    ctx.span().set_attribute(
                        opentelemetry::Key::new("redacted").i64(status_code.into()),
                    );
                    response
                })
            })
            .app_data(AppState {
                pool: pool.clone(),
                schema: schema.clone(),
            })
            .service(web::resource("/").guard(guard::Post()).to(index))
            .service(web::resource("/").guard(guard::Get()).to(playground))
            .service(health)
    })
    .bind("redacted_host:redacted_port")?
    .run()
    .await?;

    // Ensure all spans have been reported.
    opentelemetry::global::shutdown_tracer_provider();

    Ok(())
}

@rex-remind101
Copy link
Author

Some logs

^C[2022-02-08T22:38:11Z INFO  actix_server::server] SIGINT received; starting forced shutdown
[2022-02-08T22:38:11Z DEBUG actix_server::accept] Paused accepting connections on <redacted_host>:<redacted_port>
[2022-02-08T22:38:11Z INFO  actix_server::worker] Shutting down idle worker
[2022-02-08T22:38:11Z INFO  actix_server::worker] Shutting down idle worker
[2022-02-08T22:38:11Z INFO  actix_server::worker] Shutting down idle worker
[2022-02-08T22:38:11Z INFO  actix_server::accept] Accept thread stopped
[2022-02-08T22:38:11Z INFO  actix_server::worker] Shutting down idle worker
[2022-02-08T22:38:11Z INFO  actix_server::worker] Shutting down idle worker
[2022-02-08T22:38:11Z INFO  actix_server::worker] Shutting down idle worker
^C

@robjtede
Copy link
Member

robjtede commented Feb 8, 2022

okay so it's definitely catching the SIGINT, stick a log between the server shutdown and the tracer shutdown

@rex-remind101
Copy link
Author

log::error!("here1");
// Ensure all spans have been reported.
opentelemetry::global::shutdown_tracer_provider();
log::error!("here2");

Never do we reach "here2". Seems like this may be opentelemetry related, even though that library wasn't updated in version, we did switch to tokio feature there prompting this actix-web update to use tokio 1 in both places.

@fakeshadow
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
N/A Not applicable or remedied without code change.
Projects
None yet
Development

No branches or pull requests

3 participants