refactor: Remove unnecessary SQL.UsageError parameter from PoolAcqTimeoutObs

PoolAcqTimeoutObs is always created with SQL.AcquisitionTimeoutUsageError so the parameter does not provide any useful information.
On the other hand, it complicates debouncing logic in Logger as logWithDebounce has to lazily create the debouncer (which is error prone and hence the logic has a race condition).

This change removes the parameter from PoolAcqTimeoutObs. It is a prerequisite to simplifying logWithDebounce.
This commit is contained in:
Michał Kłeczek
2026-02-15 13:14:10 -05:00
committed by Steve Chavez
parent c5d495006a
commit d6816d8d2a
4 changed files with 5 additions and 6 deletions
+1 -1
View File
@@ -222,7 +222,7 @@ usePool AppState{stateObserver=observer, stateMainThreadId=mainThreadId, ..} ses
whenLeft res (\case
SQL.AcquisitionTimeoutUsageError ->
observer $ PoolAcqTimeoutObs SQL.AcquisitionTimeoutUsageError
observer PoolAcqTimeoutObs
err@(SQL.ConnectionUsageError e) ->
let failureMessage = BS.unpack $ fromMaybe mempty e in
when (("FATAL: password authentication failed" `isInfixOf` failureMessage) || ("no password supplied" `isInfixOf` failureMessage)) $ do
+1 -1
View File
@@ -88,7 +88,7 @@ shouldLogResponse logLevel = case logLevel of
-- All observations are logged except some that depend on the log-level
observationLogger :: LoggerState -> LogLevel -> ObservationHandler
observationLogger loggerState logLevel obs = case obs of
o@(PoolAcqTimeoutObs _) -> do
o@PoolAcqTimeoutObs -> do
when (logLevel >= LogError) $ do
logWithDebounce loggerState $
logWithZTime loggerState $ observationMessage o
+1 -1
View File
@@ -50,7 +50,7 @@ init configDbPoolSize = do
-- Only some observations are used as metrics
observationMetrics :: MetricsState -> ObservationHandler
observationMetrics MetricsState{..} obs = case obs of
(PoolAcqTimeoutObs _) -> do
PoolAcqTimeoutObs -> do
incCounter poolTimeouts
(HasqlPoolObs (SQL.ConnectionObservation _ status)) -> case status of
SQL.ReadyForUseConnectionStatus -> do
+2 -3
View File
@@ -59,7 +59,7 @@ data Observation
| QueryErrorCodeHighObs SQL.UsageError
| QueryPgVersionError SQL.UsageError
| PoolInit Int
| PoolAcqTimeoutObs SQL.UsageError
| PoolAcqTimeoutObs
| HasqlPoolObs SQL.Observation
| PoolRequest
| PoolRequestFullfilled
@@ -140,8 +140,7 @@ observationMessage = \case
"Config reloaded"
PoolInit poolSize ->
"Connection Pool initialized with a maximum size of " <> show poolSize <> " connections"
PoolAcqTimeoutObs usageErr ->
jsonMessage usageErr
PoolAcqTimeoutObs -> jsonMessage SQL.AcquisitionTimeoutUsageError
HasqlPoolObs (SQL.ConnectionObservation uuid status) ->
"Connection " <> show uuid <> (
case status of