data-api: fix health check shutdown; adjust db idle reset feature
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user