Skip to content

fix: resolve resource leaks, goroutine leaks, and signal handling issues#41

Merged
zx06 merged 3 commits intomainfrom
fix/resource-leaks-and-bugs
Apr 9, 2026
Merged

fix: resolve resource leaks, goroutine leaks, and signal handling issues#41
zx06 merged 3 commits intomainfrom
fix/resource-leaks-and-bugs

Conversation

@zx06
Copy link
Copy Markdown
Owner

@zx06 zx06 commented Apr 9, 2026

  • Fix MySQL registeredDials sync.Map entry leak by adding proper cleanup with DeregisterDialContext in close hook
  • Fix goroutine leak in proxy handleConnection by closing connections and waiting for io.Copy goroutines on context cancellation
  • Add signal handler for stdio MCP mode to enable graceful shutdown of active database connections and SSH tunnels
  • Add nil config check in NewToolHandler to prevent panic
  • Fix silent error swallowing in proxy io.Copy operations with logging
  • Add HTTP server timeouts and proper shutdown error handling in MCP
  • Fix potential race condition in closeHooks slice with mutex protection

All changes pass go vet, golangci-lint, and test suite with race detector.

- Fix MySQL registeredDials sync.Map entry leak by adding proper cleanup
  with DeregisterDialContext in close hook
- Fix goroutine leak in proxy handleConnection by closing connections
  and waiting for io.Copy goroutines on context cancellation
- Add signal handler for stdio MCP mode to enable graceful shutdown
  of active database connections and SSH tunnels
- Add nil config check in NewToolHandler to prevent panic
- Fix silent error swallowing in proxy io.Copy operations with logging
- Add HTTP server timeouts and proper shutdown error handling in MCP
- Fix potential race condition in closeHooks slice with mutex protection

All changes pass go vet, golangci-lint, and test suite with race detector.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 9, 2026

Codecov Report

❌ Patch coverage is 62.85714% with 26 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.46%. Comparing base (d55f4cf) to head (70af99a).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
cmd/xsql/mcp.go 48.00% 13 Missing ⚠️
internal/proxy/proxy.go 72.22% 5 Missing ⚠️
internal/db/mysql/driver.go 73.33% 2 Missing and 2 partials ⚠️
internal/mcp/tools.go 0.00% 3 Missing and 1 partial ⚠️

❌ Your patch status has failed because the patch coverage (62.85%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #41      +/-   ##
==========================================
- Coverage   81.72%   81.46%   -0.27%     
==========================================
  Files          41       41              
  Lines        2933     2978      +45     
==========================================
+ Hits         2397     2426      +29     
- Misses        409      420      +11     
- Partials      127      132       +5     
Flag Coverage Δ
e2e 43.99% <0.00%> (-0.11%) ⬇️
integration 43.99% <0.00%> (-0.11%) ⬇️
unittests 69.84% <62.85%> (-0.09%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Apr 9, 2026

@zx06 zx06 merged commit 77bacda into main Apr 9, 2026
14 of 15 checks passed
@zx06 zx06 deleted the fix/resource-leaks-and-bugs branch April 9, 2026 09:38
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.

1 participant