-
Type:
Problem report
-
Resolution: Unresolved
-
Priority:
Trivial
-
None
-
Affects Version/s: 7.0.21, 7.0.22, 7.4.5, 7.4.6
-
Component/s: Agent2 plugin (G)
-
None
*Steps to reproduce:*
1. Configure MSSQL plugin to connect to a SQL Server that is unreachable
2. Let the agent run for an extended period (days/weeks)
3. Observe memory usage growing continuously
*Result:*
Memory usage grows unbounded. In our case, ~1.3GB after a month of failed connections.
*Root cause*:
In `plugin/dbconn/dbconn_item.go`, the `getDbConn()` function calls `sql.Open()`
which allocates a *sql.DB object. When `PingContext()` fails, the function returns
without calling `db.Close()`, leaking the connection pool resources.
*Current code (line ~129):*
```go err = db.PingContext(ctx) if err != nil { return nil, errs.Wrap(err, "failed to ping") }
Fix:
err = db.PingContext(ctx) if err != nil { db.Close() // Close to prevent memory leak return nil, errs.Wrap(err, "failed to ping") }
Environment:
- Windows Server
- Zabbix Agent 2 with MSSQL plugin
- SQL Server unreachable for extended period