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

Future cancellation doesn't seem to works when a client disconnect #3462

Open
irevoire opened this issue Aug 28, 2024 · 0 comments
Open

Future cancellation doesn't seem to works when a client disconnect #3462

irevoire opened this issue Aug 28, 2024 · 0 comments

Comments

@irevoire
Copy link

irevoire commented Aug 28, 2024

Expected Behavior

I want actix-web to stop processing requests when the client closed the connection.

Current Behavior

It doesn't stop processing the request.

actix-future-cancellation.mp4

Possible Solution

Providing a way to see if the connection is still alive, if that’s even possible with tcp?

Steps to Reproduce (for bugs)

See https://github.com/irevoire/actix-web-future-cancellation-on-timeout

Context

In Meilisearch we cannot process more search requests than we have core.
But we don't want to refuse search requests when all cores are used, which means we have to store a queue of search requests to process.
Sometimes users have searches that can take a few seconds to process.
When this happens, emptying the queue takes time. But it shouldn’t since most clients will disconnect after waiting for a few seconds.

When the queue gives us a permit to process a new search requests, I would like to check if a client is still connected before doing any extra work.

Your Environment

  • Rust Version (I.e, output of rustc -V): rustc 1.78.0 (9b00956e5 2024-04-29)
  • Actix Web Version: 4.9.0 and 4.8.0
meili-bors bot added a commit to meilisearch/meilisearch that referenced this issue Aug 29, 2024
4899: stop trying to process searches after one minute r=ManyTheFish a=irevoire

# Pull Request

## Related issue
May be related to #4654 and https://github.com/meilisearch/meilisearch-support/issues/350

## What does this PR do?
- If we've been waiting for one whole minute for a search to process, we cancel it
- Ideally we should check if the connection was closed instead but that’s not possible currently: actix/actix-web#3462


Co-authored-by: Tamo <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant