Monitor and recover

This guide sets the alerts that tell you a hook, a queue, a view or the registry sync needs attention, then gets a stalled hook moving again, deals with a record that always fails, and clears queue entries pinned far in the future.

Both halves start from the same two signals. A metric, summed over replicas, tells you something is wrong. SHOW SERVING STATUS on one pod tells you what.

Before you start, have:

  • featuremeshd exporting its OpenTelemetry metrics to your collector (telemetry.metrics.exporters, Configure featuremeshd );
  • access to the hooks pods' HTTP port ( Reach a pod ), and to the stores the hooks write.

Every metric and its labels are in featuremeshd metrics . The status columns they mirror are in Status and writes . What each failure does to a record, an entry and a value is in Delivery and failures .

1. Aggregate across replicas

Sum the counters over replicas. Take the maximum of the queue gauges, not their sum, since each replica reports the same queue ( featuremeshd metrics ).

2. Set the alerts

Alert onMetricIt meansThen
the registry sync failingtime() - featuremeshd.registry.sync.last_success above a few sync periods (60 s each by default), or featuremeshd.serving.definitions with status = ERROR above zerodefinitions keep running as loaded, but no CREATE, DROP or RECOMPILE SERVING reaches this replica. Every rollout step waits on itfix the registry's reachability or token
a hook stalledfeaturemeshd.hooks.stalled at 1, featuremeshd.hooks.sink.failures risingit retries the same batch until its source, sink or queue answers, with every partition of that hook this replica holds Find what holds a hook
consumer lag growing for minutesfeaturemeshd.hooks.lagan event hook falls behind its topicadd replicas, up to the topic's partition count ( Replicas and resources ), or find the slow source
a queue falling behindfeaturemeshd.hooks.queue.oldest_due_age above a few drain periodsthe drainer is late. Past EXPIRE, buckets are lostcheck the hook's stores, then drain batches
entries expired or droppedfeaturemeshd.hooks.queue.entries_expired, .entries_dropped above zerobuckets never written, or a late correction to a bucket written before lost replay and review EXPIRE
data errorsfeaturemeshd.hooks.data_errorsrecords that do not decode, calls that raise, or calls still failing on a source once their batch has failed for poison_after. All are skippedread SHOW SERVING WRITES for the codes
deletions rising, above all after a deploymentfeaturemeshd.hooks.deletionscalls raise, and their keys' latest values are removed. A definition that raises on every record removes every key its records reachroll back the definition ( Tombstones )
a queue's lease changing handsfeaturemeshd.hooks.queue.lease_lost risinga drainer stopped answering long enough for another replica to take its queue ( Leases ). A steady rise is a replica that pauses (memory, CPU) and loses its drains' workcheck the pods' memory and CPU
a logger dropping rowsfeaturemeshd.logger.calls_dropped, featuremeshd.logger.rows with outcome dropped_write_failedthe values are served or written, but the log misses themcheck the log sink, or raise queue_capacity ( Delivery )
a view failingfeaturemeshd.views.runs with outcome = faileda run's one attempt failedlast.error in SHOW SERVING STATUS
serving calls failing or slowfeaturemeshd.serving.source.failures rising, featuremeshd.serving.call.duration above your endpoint's budget, both with caller = servinga source does not answer, or answers late. Calls fail or fall back ( Errors and fallbacks )check the source, and measure the statement again ( Deploy )

3. Watch what the metrics do not show

  • A stalled hook freezes its own gauges. lag and newest_record_time move at each commit, so they stand still while a hook is STALLED. The queue gauges freeze while drains fail. Pair every lag or queue alert with featuremeshd.hooks.stalled. Alert also on the lag your broker's tools show for the consumer group named as the hook.
  • How far behind a hook reads. On a topic that is never quiet, time() - featuremeshd.hooks.newest_record_time is how far behind the hook reads, plus however late producers stamp their records.
  • A queue's depth is not lateness. depth also counts entries not due yet, so it grows before a bucket closes without anything being late. Alert on oldest_due_age.
  • A burst of data errors with retries rising is a partial outage of a source that outlasted poison_after. Its keys' latest values were removed ( A store answers for some keys only ).
  • A missing bucket reads as zero. An hour without payments has no bucket, and neither has an hour whose bucket is not written yet, or expired. A sum over buckets cannot tell them apart. While featuremeshd.hooks.queue.oldest_due_age stays under the read's lag tolerance and entries_expired at zero, a missing bucket is an hour without payments ( Long horizons ).
  • A view that never landed leaves no series. featuremeshd.views.last_success_time exists only on a replica that landed a run since it started. To alert on a view not landing, read its sink's watermark, the same for every replica. Alert when its request_time (the slot published) is older than the schedule's period plus your margin ( How a run lands ). A view without SCHEDULE is your orchestrator's to watch. It checks each RECOMPUTE's outcome by its own deadline ( Run a view from an orchestrator ).
  • The health endpoint stays healthy while a hook is stalled ( Health is liveness only ).

4. Find what holds a hook

Ask each hooks replica, since each answers for the partitions and queues it holds:

SHOW SERVING STATUS LIKE 'FM.SHOP.%';
sql

A hook that does not move is STALLED. Its MESSAGE holds the details ( A hook's details ):

  • error names the source, sink or queue that does not answer, and why;
  • waits_on names the hook ON its statement whose failure holds it;
  • retries climbs while the batch is computed again.

SHOW SERVING WRITES LIKE 'FM.SHOP.%' LIMIT 50 lists the last ERROR and DELETE rows, with the partition and offset of each record ( SHOW SERVING WRITES ).

A hook STALLED on its topic, right after a deployment, reads a topic that does not exist, or one whose ACLs refuse its group. It starts once the topic exists or the ACL allows it ( Consumer groups ).

5. A store does not answer

When a sink, a queue, or a source read by every call is down, the hook waits and retries the same batch, with a backoff up to 30 seconds. No record is skipped, and the consumer keeps its partitions ( Failures in a batch ).

Bring the store back. The hook resumes on its own, from the batch it held. Nothing else is needed, unless the outage outlasted a scheduled hook's EXPIRE. A replay then rebuilds its dropped buckets ( Start, backfill and replay ).

6. A store answers for some keys only

When some calls of a batch succeed and others keep failing on a source, the failing ones become data errors once the batch has failed for poison_after, 2 minutes by default. They are skipped, and their keys' latest values are removed.

  • Raise poison_after in the configuration when a statement reads a store whose partial outages last longer, a clustered store's failover for instance. It costs time, since one bad key then holds the others longer.
  • Replay the records skipped once the store is back ( Replay a topic ). Their partitions and offsets are in SHOW SERVING WRITES.

7. One record always fails

A batch whose every call fails keeps retrying, even when it is one record whose key always fails. On a quiet topic, most batches are one record, and every partition of that replica waits behind it. Three ways past it:

  1. Fix the source, so that the key answers.

  2. Drop the record. Add a WHERE to the hook that excludes it, then RECOMPILE SERVING.

  3. Skip it. Drop the hook, move its group one offset past the record with your broker's tools, and create the hook again:

    bash kafka-consumer-groups --bootstrap-server broker:9092 --group prod.FM.SHOP.ON_PAYMENT
    --topic payments:3 --reset-offsets --to-offset 18421 --execute # partition 3, the offset after the record

    The steps around the reset are in Replay a topic .

8. An entry pinned far in the future

A scheduled hook whose due time follows the payload's event_time, as a profile's does, can be pinned by a payment dated in the future. A payment stamped a year ahead leaves an entry due in a year. Under POLICY = 'latest', no later payment pulls it back, so the key is not computed again for a year.

Guard the event hook against such records. This WHERE drops a payment dated more than a minute after its Kafka timestamp, which also keeps it out of the index:

FeatureQL
CREATE OR REPLACE FEATURES IN FM.TUTORIALS.HOOK_REF AS
PERSIST
    on_payment := HOOK(
        RUN pay_ps
        ON payments AS p
        WHERE p[amount] > 0 AND p[event_time] <= p[record_time] + INTERVAL '1 MINUTE'
        USING (p[payment_id], p[merchant_id], p[amount], p[event_time])
        TO pay_index
        WITH (
            START = 'earliest'
        )
    )
;
Result
feature_name VARCHARstatus VARCHARmessage VARCHAR
FM.TUTORIALS.HOOK_REF.ON_PAYMENTREPLACEDFeature was replaced

Remove an entry already pinned by hand. A queue's entries are not keyed by a readable reference ( Queues ), so remove them by due time, while no drain runs them. In a table queue, the lease is the row whose ref_hash is not 32 bytes:

-- PostgreSQL, MySQL/MariaDB: the entries due after 2027-01-01
DELETE FROM minute_queue WHERE due_time > 1798761600 AND octet_length(ref_hash) = 32;
sql
# Redis: the same entries, from both keys
redis-cli ZRANGE '{minute_queue}:due' 1798761600 +inf BYSCORE    # their hashes
redis-cli ZREM '{minute_queue}:due' <hash> …
redis-cli HDEL '{minute_queue}:entries' <hash> …
bash

The next payment of each key queues a new entry, with a due time the guard allows.

Check the alerts and the recovery

  • The stalled alert fires, then clears. On a test server, make a sink fail a few times with the test commands ( Test commands ), and watch the alert.
  • The hook's STATUS is back to RUNNING, and featuremeshd.hooks.stalled to 0.
  • retries stops climbing, and each partition's lag falls.
  • A scheduled hook's oldest_due_age_seconds falls back under a few drain periods.

Common mistakes

  • Summing the queue gauges over replicas. Each replica reports the same queue.
  • Alerting on lag alone. It stands still while the hook is stalled.
  • Restarting the pod on an alert. A stalled hook waits for a store, and a restart does not bring the store back.
  • Raising poison_after without replaying. The records already skipped stay skipped, and their latest values stay removed.
  • Deleting queue entries a drain may run. Delete only entries due far in the future, which no drain reads yet.

Related