tdfs4ds.serve.health¶
tdfs4ds.serve.health
¶
Is the database still there? A monitor for the admin app (0.3.7.4).
One daemon thread per app process asks the database SELECT 1 every
TDFS4DS_SERVE_HEALTH_INTERVAL seconds (default 60, 0 = off), on its own raw
teradatasql connection built from the same TDFS4DS_TD_* variables as
reconnect._connect_kwargs(). It never touches teradataml's shared connection: a probe
on that connection, while a panel is using it, is what broke the app before (see
activity). The connection is kept open between ticks and reopened after a failure.
States of snapshot()["state"]:
connected- the probe answered (latency_ms,last_ok).lost- transport error or timeout: the database is not reachable.refused- the logon was refused (Error 8017 / SQLState 28000: expired token, wrong password).unknown- nothing to probe with (noTDFS4DS_TD_*credentials in the environment) or not probed yet. The shared connection is not used as a fallback.
On connected -> lost/refused the app's CONNECTED flag goes False with the reason in
LAST_CONNECT_ERROR, so every panel shows it. On lost -> connected the teradataml context
is restored with reconnect_teradata(), but only when no background job runs (a job
holds statements on the shared connection); otherwise reconnect_pending is set and the
next tick tries again. reconnect_now() is the same path for the status bar's button.
The monitor also runs the periodic configuration checks (config_checks).
_TIMEOUT_MARKERS
module-attribute
¶
interval_seconds
¶
TDFS4DS_SERVE_HEALTH_INTERVAL as seconds; 0 = disabled; a bad value = default.
classify_error
¶
('refused' | 'lost', detail) for a failure of the probe.
Refused only when the database answered and said no (the markers
reconnect_teradata already uses); everything else that kept the probe from getting
an answer is a lost connection. The detail is the whole message without the driver's
Go frames.
probe_once
¶
One probe. Returns {'state', 'detail', 'latency_ms'}; never raises.
reconnect_now
¶
Restore teradataml's context. {'ok', 'status', 'pending'}; never raises.
Refused while a background job runs: the job holds statements on the shared connection,
and replacing it under them is what corrupted the app before. A manual call says so; the
automatic one leaves reconnect_pending set and retries on the next tick.