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

cancelling a waiter does not free all associated memory until a slot is returned #59

Open
problame opened this issue Oct 28, 2024 · 0 comments

Comments

@problame
Copy link
Collaborator

Problem

Assume all slots are in use by submitted operations.

If we now want to perform another tokio-epoll-uring operation, we enqueue in SlotsInnerState::Open::waiters here:

https://github.com/neondatabase/tokio-epoll-uring/blob/9cf400e9086cea7b2c06960d66276a61fea775a4/tokio-epoll-uring/src/system/slots.rs#L419-L427

If we now drop the returned rx, the tx remains stored in waiters until return_slot gets called and we run

https://github.com/neondatabase/tokio-epoll-uring/blob/9cf400e9086cea7b2c06960d66276a61fea775a4/tokio-epoll-uring/src/system/slots.rs#L219-L236

That happens only if one of the submitted operations completes.

In the meantime, the txes pile up in waiters.

Impact

Memory exhaustion and hence OOM kill in pathological cases.

Unlikely, but, could happen if more and more ops are requested and filesystem hangs completely.

The OOM could make it harder to understand the root cause in such cases.

Solution

  • Proactive cleanup of the waiters array as part of Drop impl?
  • Wrap waiters in a semaphore?
  • Follow long-standing TODO to replace waiters with a bounded channel (cap=SLOT_SIZE) that in idle state stores all the slot indices?

Context

I found this bug while

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