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.
check_context
¶
Is teradataml's shared context alive? {'state': 'ok'|'dead'|'unchecked', 'detail'}.
The raw probe above never touches this context, so it could not see it die (0.3.7.35:
a dead context answered connected for the rest of the process). Two steps, never
raising: a check of the connection object that sends nothing (always), then SELECT 1
through teradataml, only when no request and no job runs (it shares the one connection).
Before this process has ever had an open context nothing is judged (offline, or the app
never connected: unchecked).
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.
apply_context
¶
Record the context check; repair a dead one. True when the context is (now) fine.
A dead context makes the app report itself disconnected (CONNECTED False with the
reason) until it is repaired, which happens at once when no request or job runs, else
on a later tick. Repairs are logged at WARNING whatever DISPLAY_LOGS says.
tick
¶
One monitor step: probe, apply, check teradataml's context, periodic configuration checks.