Commit Graph
5 Commits
Author SHA1 Message Date
Hein f66930c3c9 chore(gosec): enable gosec and address findings 2026-09-30 13:16:12 +02:00
HeinandClaude Sonnet 5.5 da1af1487e fix(dbmanager): keep the pool alive across errors and restarts
Implements the fixes from audit/pkg/dbmanager.audit.md.

- Stop closing the shared *sql.DB to recover from errors. Adapter
  factories and the health checker no longer call Reconnect; Reconnect is
  atomic and operator-only.
- Postgres uses a custom driver.Connector: Reconnect retires pooled
  connections by generation without closing the pool, so held Bun/GORM
  handles keep working. Verified against a live server restart.
- Add TCP keepalive, TCP_USER_TIMEOUT, a bounded reuse ping and
  statement_timeout as a runtime parameter; drop the 2 min timeout floor.
- Health check pings without holding the connection lock.
- Listener: single goroutine pair, bounded Close without UNLISTEN, and
  serialised use of the pgx connection (fixes conn busy and a close race).
- Fix Connect/Close/Connect/Close panic, idempotent Connect, dial outside
  the manager lock, clean up on partial failure.
- SQLite: pin :memory: to one connection, pragmas via DSN.
- Escape credentials in Postgres/MSSQL/Mongo DSNs; sslmode defaults to
  prefer. Wire retry settings, publish metrics, fix logger calls.
- NewConnectionFromDB: Close is a no-op with a warning (caller owns the
  pool); Reconnect only pings.
- Document correct usage in the README; mark the audit with what was done.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-09-30 12:40:14 +02:00
Hein 79a3912f93 fix(db): improve database connection handling and reconnection logic
* Added a database factory function to allow reconnection when the database is closed.
* Implemented mutex locks for safe concurrent access to the database connection.
* Updated all database query methods to handle reconnection attempts on closed connections.
* Enhanced error handling for database operations across multiple providers.
2026-04-09 09:19:28 +02:00
Hein 07016d1b73 feat(config): ✨ Update timeout settings for connections
Build , Vet Test, and Lint / Run Vet Tests (1.23.x) (push) Successful in -22m34s
Build , Vet Test, and Lint / Run Vet Tests (1.24.x) (push) Successful in -22m28s
Build , Vet Test, and Lint / Build (push) Successful in -26m3s
Build , Vet Test, and Lint / Lint Code (push) Successful in -25m22s
Tests / Integration Tests (push) Failing after -26m44s
Tests / Unit Tests (push) Successful in -26m2s
* Set default query timeout to 2 minutes and enforce minimum.
* Add statement_timeout for PostgreSQL DSN.
* Implement busy timeout for SQLite with a minimum of 2 minutes.
* Enforce minimum connection timeouts of 10 minutes for server instance.
2026-01-26 11:06:16 +02:00
Hein 6f05f15ff6 feat(dbmanager): ✨ Database connection Manager 2026-01-02 16:19:33 +02:00