feat(database/gdb): add MaxIdleConnTime configuration for SetConnMaxIdleTime support#4625
Merged
hailaz merged 1 commit intogogf:masterfrom Jan 19, 2026
Merged
Conversation
…dleTime support (gogf#4596) Add support for Go 1.15+ sql.DB.SetConnMaxIdleTime() method: - Add MaxIdleConnTime field to ConfigNode (json: maxIdleTime) - Add SetMaxIdleConnTime method to DB interface and Core - Apply MaxIdleConnTime setting during connection pool initialization - Add unit tests for the new configuration option This allows users to configure the maximum idle time for database connections, which is useful for databases with limited connection licenses (e.g., DamengDB).
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds support for configuring the maximum idle time for database connections through the MaxIdleConnTime configuration field, enabling use of Go 1.15+'s sql.DB.SetConnMaxIdleTime() method.
Changes:
- Added
MaxIdleConnTimeconfiguration field and setter method to support idle connection timeout - Integrated the new configuration into the connection pool initialization logic
- Added comprehensive unit tests for the new functionality
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| database/gdb/gdb_core_config.go | Added MaxIdleConnTime field to ConfigNode struct and implemented SetMaxIdleConnTime() method with documentation |
| database/gdb/gdb.go | Added interface method, MaxIdleConnTime field to dynamicConfig, and initialization logic in getSqlDb() |
| database/gdb/gdb_z_core_config_test.go | Added unit test for SetMaxIdleConnTime() method in existing connection settings test |
| database/gdb/gdb_z_core_config_external_test.go | Added comprehensive test for all connection pool configuration fields including MaxIdleConnTime |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
hailaz
approved these changes
Jan 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
MaxIdleConnTimeconfiguration field to support Go 1.15+sql.DB.SetConnMaxIdleTime()methodSetMaxIdleConnTime()method to DB interface and Core implementationRelated Issue
Closes #4596
Changes
database/gdb/gdb_core_config.goMaxIdleConnTimefield toConfigNode, addSetMaxIdleConnTime()methoddatabase/gdb/gdb.godynamicConfigfield, initialization logicdatabase/gdb/gdb_z_core_config_test.goSetMaxIdleConnTimedatabase/gdb/gdb_z_core_config_external_test.goConfigNodeconnection pool settings testUsage
Configuration file:
Code:
Test Plan
go test -run "Test_Core_SetMaxConnections|Test_ConfigNode_ConnectionPoolSettings")