feat: add connection pool options to Oracle state store#4411
Conversation
cc12184 to
bbcfba1
Compare
Expose four database/sql connection-pool tunables as component metadata so operators can tune the Oracle state store without forking the component: maxOpenConns -> db.SetMaxOpenConns(int) maxIdleConns -> db.SetMaxIdleConns(int) connMaxLifetime -> db.SetConnMaxLifetime(time.Duration) connMaxIdleTime -> db.SetConnMaxIdleTime(time.Duration) Each setter is called only when the user provides the option (non-zero value), preserving Go's built-in database/sql defaults when the field is omitted. The pattern and field names mirror the MySQL bindings component (bindings/mysql). Fixes dapr#4276 Signed-off-by: Nelson Parente <nelson@diagrid.io>
bbcfba1 to
98b72d9
Compare
There was a problem hiding this comment.
⚠️ Not ready to approve
The documentation around maxIdleConns currently misstates the effective/default behavior (and Init still leaks a DB handle on ensureStateTable failure), which should be corrected before approval.
Pull request overview
This PR adds configurable database/sql connection pool tuning to the Oracle state store via new metadata fields, allowing operators to adjust pooling behavior (max open/idle connections, max lifetime/idle time) while preserving Go’s defaults when options are not provided.
Changes:
- Extended
oracleDatabaseMetadatawith four connection-pool fields and applied them duringInitvia a dedicatedapplyConnectionPoolhelper. - Adjusted
Initflow to ping before assigningo.db, and to close the DB on ping failure. - Added tests validating metadata decoding and basic application of pool settings; updated component metadata documentation.
File summaries
| File | Description |
|---|---|
| state/oracledatabase/oracledatabaseaccess.go | Adds pool configuration fields + helper and applies pool settings during initialization. |
| state/oracledatabase/oracledatabaseaccess_test.go | Adds tests for decoding pool metadata and applying MaxOpenConns via *sql.DB stats. |
| state/oracledatabase/metadata.yaml | Documents the new pool-related metadata options. |
Copilot's findings
- Files reviewed: 3/3 changed files
- Comments generated: 3
Note
Your feedback helps us improve the quality of this feature.
Please use 👍 or 👎 to tell us whether this assessment is correct.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…ns docs (Copilot review) Signed-off-by: Nelson Parente <nelson_parente@live.com.pt>
There was a problem hiding this comment.
✅ Ready to approve
The changes are low-risk, test-covered, and align with existing patterns, with only a minor comment/doc wording nit noted.
Note: this review does not count toward required approvals for merging.
Copilot's findings
- Files reviewed: 3/3 changed files
- Comments generated: 1
Note
Your feedback helps us improve the quality of this feature.
Please use 👍 or 👎 to tell us whether this assessment is correct.
…y (Copilot review) Signed-off-by: Nelson Parente <nelson_parente@live.com.pt>
Motivation
The Oracle state store uses the Go
go-oradriver via the standarddatabase/sqlabstraction. Connection pooling is therefore controlled by*sql.DB, not the driver/connection string. Today the Oracle state store exposes no way to tune the connection pool, so operators are stuck with Go's defaults regardless of their workload.This PR adds four metadata options to configure the
database/sqlconnection pool for the Oracle state store.New metadata options
database/sqlsettermaxOpenConnsdb.SetMaxOpenConns(int)maxIdleConnsdb.SetMaxIdleConns(int)connMaxLifetimedb.SetConnMaxLifetime(time.Duration)connMaxIdleTimedb.SetConnMaxIdleTime(time.Duration)Each setter is called only when the user explicitly provides the option (non-zero value). Omitting a field leaves Go's built-in
database/sqldefault unchanged, so this change is fully backwards-compatible.Reference implementation
The pattern, field names, types, and "apply only if set" guard are intentionally mirrored from the existing MySQL bindings component (
bindings/mysql/mysql.go), which already implements all four options identically.Changes
state/oracledatabase/oracledatabaseaccess.go— added four fields tooracleDatabaseMetadata(withmapstructuretags) and four guardeddb.Set*calls inInitaftersql.Open.state/oracledatabase/metadata.yaml— documented all four new fields (type, description, example, default).state/oracledatabase/oracledatabaseaccess_test.go— added three new tests:TestParseMetadataConnectionPool: table-driven test verifying metadata parsing for all four fields, including zero/omitted values and duration shorthand.TestConnectionPoolApplied: verifies that non-zero pool settings are applied to*sql.DB(uses go-sqlmock, no live Oracle DB required).TestConnectionPoolZeroValuesSkipped: verifies that zero values leave the Go default (MaxOpenConnections == 0).Fixes #4276
📖 Documentation: dapr/docs#5221