Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 13, 2025

Job tests were causing PostgreSQL connection leaks in CI, failing with 583 test failures due to exhausted connections.

Root Cause

The application uses GoodJob as the ActiveJob adapter globally. GoodJob maintains a separate database connection pool that persists across inline job executions in tests, preventing proper connection cleanup.

Changes

  • Configure test environment to use Rails' :test adapter instead of GoodJob
  • Add config.active_job.queue_adapter = :test to config/environments/test.rb

The :test adapter executes jobs inline without a separate connection pool, ensuring connections are properly returned after each test.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: Knerio <96529060+Knerio@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix postgres connection leak in jobs Fix PostgreSQL connection leak in test environment Nov 13, 2025
Copilot finished work on behalf of Knerio November 13, 2025 21:49
Copilot AI requested a review from Knerio November 13, 2025 21:49
@github-actions
Copy link

github-actions bot commented Nov 13, 2025

GitLab Pipeline Action

General information

Link to pipeline: https://gitlab.com/code0-tech/development/sagittarius/-/pipelines/2157717932

Status: Passed
Duration: 3 minutes

Job summaries

rspec: [ee]

Coverage report available at https://code0-tech.gitlab.io/-/development/sagittarius/-/jobs/12083602462/artifacts/tmp/coverage/index.html
Test summary available at https://gitlab.com/code0-tech/development/sagittarius/-/pipelines/2157717932/test_report
Finished in 19.88 seconds (files took 11.56 seconds to load)
1202 examples, 0 failures
Line Coverage: 91.52% (4060 / 4436)
[TEST PROF INFO] Time spent in factories: 00:11.604 (42.56% of total time)

rspec: [ce]

Coverage report available at https://code0-tech.gitlab.io/-/development/sagittarius/-/jobs/12083602460/artifacts/tmp/coverage/index.html
Test summary available at https://gitlab.com/code0-tech/development/sagittarius/-/pipelines/2157717932/test_report
Finished in 20.71 seconds (files took 10.29 seconds to load)
1155 examples, 0 failures
Line Coverage: 90.92% (3893 / 4282)
[TEST PROF INFO] Time spent in factories: 00:12.003 (45.28% of total time)

rubocop

669 files inspected, no offenses detected

@Knerio Knerio marked this pull request as ready for review November 13, 2025 21:55
@Knerio Knerio merged commit 8dd0e4b into 474-primary-runtime-conflicts Nov 13, 2025
2 of 3 checks passed
@Knerio Knerio deleted the copilot/sub-pr-659 branch November 13, 2025 22:00
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.

2 participants