-
Notifications
You must be signed in to change notification settings - Fork 996
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
meta/sql: more connection control options #5512
Conversation
Redis and KV have similar configurations, perhaps can change to a handling method similar to redis.ParseURL |
Got. |
Redis connection pool is provided by the driver, you can control the settings by meta url, we just need to make it clear in docuemnt. While sql's connection pool is provided by the database/sql module, not by driver. for redis/tikv: https://github.com/redis/go-redis/blob/91dddc2e1108c779e8c5b85fd667029873c95172/options.go#L451 setupConnParams function |
These parameters are not universal, so it is more appropriate to use query parameters in the meta-url, which may be supported natively by the driver library. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5512 +/- ##
==========================================
- Coverage 55.09% 54.92% -0.17%
==========================================
Files 166 165 -1
Lines 47787 47929 +142
==========================================
Hits 26327 26327
- Misses 18613 18732 +119
- Partials 2847 2870 +23 ☔ View full report in Codecov by Sentry. |
A better default setting may be "max_open_conns=30&max_idle_conns=30&max_idle_time=300&max_life_time=3600". Let the max_idle_conns >= max_open_conns can eliminate the short connections effectively |
Add four new options for sql meta engine
1, max-open-conns, limit the maximum connection, default 0 (unlimited)
2, max-idle-conns, limit the maximum idle connection, previous is cpu number * 2, the new default is 10
3, max-idle-time, previous is 5 mins, no changed, just expose the option.
4, max-life-time, if a connection has be created more than given time, it will be closed anyway, default is 3600, as a backend connection may have some unclean resources.