fix: drop stale DB connections around LaunchDarkly fetch phase#7219
fix: drop stale DB connections around LaunchDarkly fetch phase#7219gagantrivedi merged 1 commit intomainfrom
Conversation
There was a problem hiding this comment.
Code review is billed via overage credits. To resume reviews, an organization admin can raise the monthly limit at claude.ai/admin-settings/claude-code.
Once credits are available, reopen this pull request to trigger a review.
|
The latest updates on your projects. Learn more about Vercel for GitHub. 3 Skipped Deployments
|
Docker builds report
|
Playwright Test Results (oss - depot-ubuntu-latest-16)Details
Playwright Test Results (oss - depot-ubuntu-latest-arm-16)Details
Playwright Test Results (private-cloud - depot-ubuntu-latest-arm-16)Details
Playwright Test Results (private-cloud - depot-ubuntu-latest-16)Details
Playwright Test Results (oss - depot-ubuntu-latest-16)Details
Playwright Test Results (oss - depot-ubuntu-latest-arm-16)Details
Playwright Test Results (private-cloud - depot-ubuntu-latest-arm-16)Details
Playwright Test Results (private-cloud - depot-ubuntu-latest-16)Details
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7219 +/- ##
=======================================
Coverage 98.35% 98.35%
=======================================
Files 1348 1350 +2
Lines 50666 50713 +47
=======================================
+ Hits 49834 49881 +47
Misses 832 832 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Visual Regression16 screenshots compared. See report for details. |
The LaunchDarkly import task holds a Django DB connection idle during a slow HTTP fetch of LD data (can exceed 5 min). RDS terminates the session on idle_session_timeout, and the following write phase fails with 'InterfaceError: connection already closed'. Adds a reusable context manager (closing_stale_connections) that calls django.db.close_old_connections when the wrapped block exits, and applies it around the LD fetch block so the write phase opens a fresh connection if the prior one was killed. pytest-django wraps tests in atomic(), which collides with close_old_connections' autocommit check; the affected test_process_import_request tests are switched to transaction=True.
4b08f9d to
a2cd61d
Compare
Changes
Closes #7167
The LaunchDarkly import task holds a Django DB connection idle during a slow HTTP fetch of LD data (can exceed 5 minutes on large projects). RDS terminates the session on
idle_session_timeout, and the subsequent write phase fails withInterfaceError: connection already closed(Sentry: FLAGSMITH-API-5MD).util.db.closing_stale_connections()— a context manager that callsdjango.db.close_old_connections()when the wrapped block exits. Healthy connections are untouched; only obsolete/unusable ones are dropped.process_import_request, so the write phase opens a fresh connection if the prior one was killed during the fetch.How did you test this code?
test_closing_stale_connections__exit__calls_close_old_connectionscovers the helper.test_process_import_request__*tests were switched to@pytest.mark.django_db(transaction=True)because pytest-django's defaultatomic()wrapping collides withclose_old_connections' autocommit check. All 17 LD service tests pass locally.