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

[BUG]: Thread pool lru cache #1690

Closed

Conversation

tazarov
Copy link
Contributor

@tazarov tazarov commented Feb 1, 2024

Description of changes

The problem stems from how AnyIO handles synchronous calls when back pressure is on uvicorn. As it turns out, threads from the pool are used (max is 40); however, the thread contexts change, which causes the Connections to no longer be linked to thread-local but remain in the _connections set of the pool, leading to an infinite growth of open file handles (one per Connection). To solve this, an LRU cache is introduced to keep track of and clean up Connections that are not used for a configurable amount of time.

Summarize the changes made by this PR.

  • Improvements & Bug fixes
    • LRU cache in the PerThread SQLite connection pool

Test plan

How are these changes tested?

  • Tests pass locally with pytest for python, yarn test for js

Documentation Changes

N/A

Copy link

github-actions bot commented Feb 1, 2024

Reviewer Checklist

Please leverage this checklist to ensure your code review is thorough before approving

Testing, Bugs, Errors, Logs, Documentation

  • Can you think of any use case in which the code does not behave as intended? Have they been tested?
  • Can you think of any inputs or external events that could break the code? Is user input validated and safe? Have they been tested?
  • If appropriate, are there adequate property based tests?
  • If appropriate, are there adequate unit tests?
  • Should any logging, debugging, tracing information be added or removed?
  • Are error messages user-friendly?
  • Have all documentation changes needed been made?
  • Have all non-obvious changes been commented?

System Compatibility

  • Are there any potential impacts on other parts of the system or backward compatibility?
  • Does this change intersect with any items on our roadmap, and if so, is there a plan for fitting them together?

Quality

  • Is this code of a unexpectedly high quality (Readability, Modularity, Intuitiveness)

@jasdeepsngh576
Copy link

When is this fix going to be released. We are facing similar issue where file handles are growing infinitely even for global chroma client.

@mrityunjayupadhyay
Copy link

We are running this issue frequently. Kindly give an ETA of fix.

@tazarov
Copy link
Contributor Author

tazarov commented Mar 15, 2024

@HammadB, wdyt, does the PR make sense?

@tazarov
Copy link
Contributor Author

tazarov commented Mar 28, 2024

Try to see if #1938 resolves this.

@tazarov
Copy link
Contributor Author

tazarov commented Apr 3, 2024

Try to see if #1938 resolves this.

After testing with a Chroma community member in a prod/prod-like environment, I can confirm that #1938 does not resolve the issue.

@tazarov
Copy link
Contributor Author

tazarov commented Apr 17, 2024

Closing this in favor of #2014

@tazarov tazarov closed this Apr 17, 2024
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

Successfully merging this pull request may close these issues.

3 participants