Flaky system test: test_99b's second server hits 'too many clients' on the shared test database

Open
#7,226 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
64/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
postgresql, python
Domain
databases, testing

Research direction

Start with hindsight-system-tests/tests/test_99b_custom_llm_provider.py and the fixture that starts its second server; trace how it configures the HINDSIGHT_API_DB_POOL_* settings and compare with the pool defaults behind #4754. Reproduce the startup failure against the shared pg0://hindsight-systest database, then choose a way to keep both servers within its connection limit. Done when the test passes reliably without exhausting database connections.

Written by the indexing model from the issue text.

Description

core

What happens

tests/test_99b_custom_llm_provider.py::test_every_model_call_goes_through_the_custom_provider sometimes errors at setup. Its server exits during startup with:

asyncpg.exceptions.TooManyConnectionsError: sorry, too many clients already

Seen on PR #7224 (run 47091395339, job test-system (blackbox)). A rerun of that job passed, and the PR touched nothing in this path.

Why (likely)

The test starts a second hindsight-api against the same embedded Postgres instance (pg0://hindsight-systest) that the suite's main server is already using. The two connection pools together can go over the instance's max_connections. #4754 was the same collision for a single server: its default pool max equalled the embedded Postgres limit.

What should happen

A story that starts an extra server should fit inside the database's connection limit. Options:

  • Give the extra server a small pool (HINDSIGHT_API_DB_POOL_*).
  • Raise the system-test instance's max_connections.
  • Run the extra server against its own pg0 instance.

Where

  • hindsight-system-tests/tests/test_99b_custom_llm_provider.py, and the fixture that starts its server.
  • The pool defaults behind #4754.
Dominant language
Python
Stars
45.2k
Forks
5.9k
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from vectorize-io/hindsight

All issues in vectorize-io/hindsight

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.