Settings the serving tutorials use
The serving tutorials run on a test server, with records dated in the past. A few settings make their results the same on every run. This page says what each one does, and what to write in production instead.
What you need
- featuremeshd with hooks, started with
serving.test_controls: true( A test server ). - A Kafka broker. The tutorials reach it at
kafka://host.docker.internal:29093. - Redis, at
redis://host.docker.internal:26379. - PostgreSQL, at
host.docker.internal:25432, database and userfeaturemesh. Its password is read from the environment variableFEATUREMESH_DEMOS_PG_PASSWORD.
To use your own stores, change these addresses in the definitions.
Loading what you create
featuremeshd loads new and changed definitions at its next registry sync, every 60 seconds by default. The tutorials load them at once: after each step that creates, replaces or drops features, run
RECOMPILE SERVING; The pages leave this step out. Without it, the next step can run against the previous definition: a hook keeps its old EXPIRE, or a statement is not served yet.
To run a tutorial again, drop its namespace first, then load the drop ( Drop features ): DROP FEATURES IF EXISTS IN FM.TUTORIALS.HOOK_BUCKETS UP TO LEVEL 9; for Buckets per key , then RECOMPILE SERVING;. A CREATE OR REPLACE over the last run's definitions can be refused, since later steps changed the features it replaces. Dropping the features leaves what the last run wrote: delete its index keys in Redis too, or the new run counts the old payments.
redis-cli -p 26379 --scan --pattern 'tut_hook_buckets:*' | xargs redis-cli -p 26379 DEL The tutorial's first PostgreSQL step drops and creates its tables and queues again. RECOMPILE SERVING answers with the status of every definition ( Status and writes ).
Amounts as DOUBLE
The tutorials declare amounts DOUBLE, so that results stay short. For money, declare DECIMAL from the record to the sink ( Keep money exact ).
Records dated in the past
Every payment of the hook tutorials carries fixed times, on 2025-11-24. The results you see are then the results you get, whatever the day you run the tutorial. Two settings follow from these old dates.
| Setting | In the tutorials | Why | In production |
|---|---|---|---|
RETENTION on an index or a value | INTERVAL '36500 DAY' | A store trims what is older than its own clock minus RETENTION. Against today's clock, the tutorial's records are a year old, so a short retention would trim them at once. | The window your readers need, plus a margin ( Size RETENTION, EXPIRE and memory ) |
EXPIRE on a scheduled hook | INTERVAL '36500 DAY' | A drain drops, unrun, an entry whose due time is older than EXPIRE. The tutorial's entries are due a year ago, so a short EXPIRE would drop them all. | Minutes to hours: the longest lateness you still count |
A statement that reads a window takes the time as an input, AT, rather than REQUEST_TIME(). A call can then ask for the window as it was at 15:13 on the records' day.
Draining by hand
A scheduled hook queues entries, and featuremeshd's drainer runs them once they are due. The tutorials drain by hand, so that you see each run.
EVERY = INTERVAL '1 HOUR'sets the drainer's period to an hour. The drainer then stays out of the way while you follow the steps. In production, leaveEVERYout: the default drains every 5 seconds. A period close toEXPIRElets entries expire before a drain runs them.TEST SERVING DRAIN '<hook>';drains a hook's queue at once, until nothing is due. It answers with what it ran: the batches, the calls that succeeded, the entries dropped pastEXPIRE, the entries removed, the data errors ( Test commands ).TEST SERVING WAIT '<view>';waits for a materialized view's run in progress.
A test server
These commands work only on a server started with serving.test_controls: true ( Configure featuremeshd ). A production server refuses them, and keeps the setting off ( Protect the port ).
The steps that send records use the same setting. Each one is TEST SERVING PRODUCE '<records>', where <records> is the feature that maps the stream's records (PAYMENTS in the tutorials), followed by one JSON record per line. It produces them to the hook's topic, then waits until every hook on the topic has read past them. In production, your producers write to the topic, and nothing waits.
Test commands
The TEST SERVING commands are for test servers only. A server without serving.test_controls: true refuses them. The same setting allows statement.request_time on a prepared call ( Prepared statements ).
| Command | Does | Answers |
|---|---|---|
TEST SERVING DRAIN '<hook>'; | drains a scheduled hook's queue until nothing is due, and steps the hooks ON its statement once. A hook without AT runs and writes. A scheduled one only queues its entries, for its own drain | HOOK, DRAINS, FIRED, EXPIRED, DELETED, DATA_ERRORS |
TEST SERVING RUN '<view>'; | runs a materialized view's current slot at once | VIEW, SLOT, RUN, ATTEMPTS, ROWS, DELETED, DATA_ERRORS, STALE, HELD |
TEST SERVING WAIT '<view>'; | waits, up to 30 seconds, for the view's run in progress on this featuremeshd, such as one a RECOMPUTE started | as RUN |
TEST SERVING HOLD '<view>'; | the view's next run computes, then keeps its rows unlanded, with its run number | VIEW |
TEST SERVING RESUME '<view>'; | lands the held run now, as a run that outlived its lease would | as RUN |
TEST SERVING FAIL SINK '<sink>' [TIMES <n>]; | makes the next n writes of a hook's sink fail, 1 by default. 0 clears | SINK, FAILURES |
TEST SERVING SWEEP; | runs the RETENTION sweep of every table sink now | SINK, DELETED |
TEST SERVING READ SINK '<sink>'; | reads the run a view's object-store sink published, through its manifest, as a reader does | the run's rows |
TEST SERVING PRODUCE '<records>' then one JSON object per line | <records> is the feature that maps the stream's records, EXTERNAL_COLUMNS(… FROM TABLE(STREAM[topic])). Produces records to its topic, which a served hook consumes. Each line takes value, and optionally key, time, partition and headers | TOPIC, PARTITION, OFFSET |
TEST SERVING DRAIN answers in six columns:
| Column | Counts |
|---|---|
HOOK | the hook drained |
DRAINS | the batches run |
FIRED | the calls that succeeded |
EXPIRED | entries dropped unrun, past EXPIRE |
DELETED | entries removed from the queue after their run. These are not values removed from a sink, which are the hook's deletions |
DATA_ERRORS | data errors |
A drain that cannot finish is an error. That happens when another featuremeshd holds the queue's lease, or when a source, sink or queue fails. A view run that fails, or that another replica holds, is an error too.
To test an alert, make a sink fail with TEST SERVING FAIL SINK 'FM.SHOP.PER_MINUTE' TIMES 20; and watch the stalled alert fire, then clear ( Monitor and recover ).
Related
- Configure featuremeshd : consumer groups, replicas, leases and the other settings of a production server.
- Hooks :
EVERY,EXPIREand the other hook settings. - Size
RETENTION,EXPIREand memory : the production values.