Private
Public Access
1
0

data-api: fix health check shutdown; adjust db idle reset feature
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2025-01-03 14:28:36 +01:00
parent d206f9d20e
commit 9fb3edacef
4 changed files with 8 additions and 3 deletions

View File

@@ -107,6 +107,7 @@ func (srv *Server) fetchGraph(ctx context.Context, serverIP string) (string, []b
client := retryablehttp.NewClient()
client.Logger = log
client.HTTPClient.Transport = otelhttp.NewTransport(
client.HTTPClient.Transport,
otelhttp.WithClientTrace(func(ctx context.Context) *httptrace.ClientTrace {

View File

@@ -284,7 +284,7 @@ func healthHandler(srv *Server, log *slog.Logger) func(w http.ResponseWriter, re
g, ctx := errgroup.WithContext(ctx)
stats := srv.db.Stats()
if stats.OpenConnections > 5 {
if stats.OpenConnections > 3 {
log.InfoContext(ctx, "health requests", "url", req.URL.String(), "stats", stats)
}
@@ -293,9 +293,11 @@ func healthHandler(srv *Server, log *slog.Logger) func(w http.ResponseWriter, re
log.InfoContext(ctx, "db reset request", "err", err, "reset", reset)
if err == nil && reset {
// this feature was to debug some specific problem
log.InfoContext(ctx, "setting idle db conns to zero")
srv.db.SetConnMaxLifetime(30 * time.Second)
srv.db.SetMaxIdleConns(0)
srv.db.SetConnMaxLifetime(5 * time.Second)
srv.db.SetMaxIdleConns(4)
}
}