Skip to content

Conversation

@HGD-coder
Copy link

What this PR does:

  • Fixed connection leak in pkg/datasource/sql/datasource/base/meta_cache.go by adding defer conn.Close()
  • Fixed connection leak in pkg/datasource/sql/db.go by adding defer conn.Close()
  • Added proper error handling in pkg/datasource/sql/async_worker.go to prevent nil pointer panic when db.Conn() fails

Which issue(s) this PR fixes:

Fixes #991

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

NONE

@github-actions github-actions bot added bug Something isn't working documentation Improvements or additions to documentation coding milestone labels Nov 23, 2025
@0x-infinity
Copy link
Contributor

Plz check and fix CI issues.

@HGD-coder
Copy link
Author

The previous test code used db: &sql.DB{} to create a database object. This is an incomplete instance where essential internal fields (like the driverConn) are nil. When the code under test attempts to call the conn.Close() method, it causes the program to crash (a panic) due to a nil pointer dereference.

@slievrly slievrly added this to the 2.1.0 milestone Nov 25, 2025
@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 61.60%. Comparing base (afb8650) to head (62f38dd).

Files with missing lines Patch % Lines
pkg/datasource/sql/async_worker.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #997      +/-   ##
==========================================
- Coverage   61.65%   61.60%   -0.05%     
==========================================
  Files         213      213              
  Lines       13054    13058       +4     
==========================================
- Hits         8049     8045       -4     
- Misses       4481     4486       +5     
- Partials      524      527       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working coding documentation Improvements or additions to documentation milestone

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Connection leaks caused by improperly closed database connections

4 participants