module TrinoEngineSupervisor

Event-driven lifecycle of the engine, driven by demand (maintenance executions).

Every transition happens under a row lock (SELECT … FOR UPDATE on the single trino_engine_states row), which closes three races at once: the destroy-during-acceptance window, concurrent drains and concurrent starts.

State machine: down -> starting -> up -> draining -> stopping -> down. “stopping” is the point of no return: destruction is in progress, and demand that arrives there must wait for down and trigger a fresh start.