Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
feat: add forced database connection cleanup after timeout (#17132)
Danny Xu1b35475f41e7
diff --git a/backend/store/db_connection.go b/backend/store/db_connection.goindex d751d3a372..486ae3a501 100644--- a/backend/store/db_connection.go+++ b/backend/store/db_connection.go@@ -149,11 +149,20 @@ func (m *DBConnectionManager) reloadConnection(ctx context.Context, filePath strm.db = newDBm.mu.Unlock()- // Set max idle connections to 0 on the old pool to gradually close connections- // This allows active connections to complete naturally+ // Gracefully drain old connections and force close after 1 hourif oldDB != nil {+ // Set max idle connections to 0 to gradually close connections+ // This allows active connections to complete naturallyoldDB.SetMaxIdleConns(0)oldDB.SetConnMaxLifetime(1 * time.Minute)++ // Force close after 1 hour as a safety measure+ go func() {+ time.Sleep(1 * time.Hour)+ if err := oldDB.Close(); err != nil {+ slog.Warn("Failed to force close old database connection", "error", err)+ }+ }()}slog.Info("Database connection updated successfully", "file", filePath)