Run a view from an orchestrator

This guide has an orchestrator (Airflow, Dagster, a cron job) run a materialized view after its inputs landed: it checks the keyset, triggers the run over HTTP, and follows the outcome.

Before you start, have:

  • the view created without SCHEDULE, so that only your orchestrator runs it ( Materialized views );
  • hooks pods with enough memory for the run (§ View memory below), and their HTTP port reachable from the orchestrator ( Deploy ).

1. Check the keyset's source

A keyset that comes back empty empties the sinks ( When the keyset is empty ). Before the run, have the orchestrator check the keyset's source: its export landed, its row count is plausible. The run reads the source again, so keep it unchanged from the check until the run's outcome, for instance by swapping a new export in only after the check passes, and not again before the run lands.

2. Trigger the run and follow it

An orchestrator sends RECOMPUTE MATERIALIZED VIEW to one hooks replica over HTTP, then asks that same replica for the outcome. POD is one pod's address: the chart's headless Service, featuremeshd-hooks-hooks for a release named featuremeshd-hooks, resolves to every pod's address, and each answers for its own runs only. Resolve it once, pick one address, and keep it for the poll:

curl -s http://$POD:10090/v1/featureql -H 'content-type: application/json' --data-binary @- <<'JSON'
{"query": "RECOMPUTE MATERIALIZED VIEW FM.SHOP.REVENUE;"}
JSON
# {"data": {"rows": [{"VIEW": "FM.SHOP.REVENUE", "SLOT": "2026-11-25T02:00:00.000000", "RUN": 42, "STATUS": "STARTED"}], …}, …}

curl -s http://$POD:10090/v1/featureql -H 'content-type: application/json' --data-binary @- <<'JSON'
{"query": "SHOW SERVING STATUS LIKE 'FM.SHOP.REVENUE';"}
JSON
# MESSAGE: {"running": null, "last": {"run": 42, "outcome": "OK", "rows": 1830, "error": null, …}, …}
bash
The orchestrator getsIt meansThen
STATUS = 'STARTED' and a RUNthe run goes on; neither featuremeshd's 10-second HTTP limit nor a client that disconnects stops itpoll SHOW SERVING STATUS on that pod until running is no longer that run and last.run is it
last.outcome = 'OK'every sink took the run, or had a newer one already (last.stale names them)done
last.outcome = 'FAILED'the run's one attempt failed: last.error says why; nothing is retriedRECOMPUTE again: a new run, and, without SCHEDULE, a new slot
an error: <view>: another replica (<holder>) is running it, or <view>: a run of it is in progress on this replicabusy: nothing startedwait for that run, then ask again if you still need one
an error: materialized views run on a featuremeshd with hooks enabled …this replica does not run viewssend it to a hooks replica
no answer, or last without that run (the pod restarted, or a later run followed)unknownread the sinks' watermarks ( How a run lands ): a run equal to RUN landed it, a greater one a later run; check before asking again

View memory

A view run holds its keyset in memory, under the process's memory limit, which serving calls, hook batches and other runs of that process share ( Size featuremeshd's memory ). Any featuremeshd with hooks enabled can win a view's lease, so give every such featuremeshd the memory of the largest view run.

A run's memory grows with its keyset, the width of its rows and what its sources return. No published number sizes it for you: run your largest view at its real size, read the pod's memory during the run, and set memoryLimitMb in the chart above that peak, with the container's limit above it.

Check the result

The run landed when the sinks' watermark holds its run number: a run equal to RUN landed it, a greater one a later run ( How a run lands ). Read it from the store, the same for every replica, rather than from one pod's memory.

Common failures

  • The sinks are empty after a run: the keyset came back empty (§ 1).
  • busy on every call: another replica holds the view's lease, for a run still in progress. Wait for it.
  • The pod restarted during the run: its SHOW SERVING STATUS no longer knows the run. Read the watermark before asking again.
  • A run that fails for memory: its keyset does not fit the engine's memory pool. Raise memoryLimitMb, and the container's limit above it, on every hooks pod.

Related