Remove an event

This guide erases one event from an index and from the values computed from it, for an erasure request.

To correct an event rather than erase it, send a reversal instead ( Late, corrected and missing events ).

Before you start, know:

  • the sinks the event reached: the index, and every latest sink whose statement read it (a bucket, a decision, a profile);
  • the event's key and identity in each: here payment 1001 of merchant 7, in a Redis index keyed shop:pay:{<merchant>} and a table pay_history;
  • whether the topic still holds the record. A replay would write it again: remove it while no replay can reach it, or after the topic dropped it.

The layout of each sink is in The write layout .

1. Remove it from a Redis index

In a sorted set, the member is the row in the sink's FORMAT, scored by its INDEXED ON time in seconds. The hash <key>:ids maps each UNIQUE ON value to that score:

redis-cli HGET 'shop:pay:{7}:ids' 1001                       # the score of payment 1001
redis-cli ZRANGE 'shop:pay:{7}' <score> <score> BYSCORE      # the members at that score: pick payment 1001's
redis-cli ZREM 'shop:pay:{7}' '<member>'
redis-cli HDEL 'shop:pay:{7}:ids' 1001
bash

2. Remove it from a table index

DELETE FROM pay_history WHERE merchant_id = 7 AND payment_id = 1001;
sql

3. Remove what was computed from it

A latest value computed from the event, such as a bucket's total or a decision, keeps it until its key is written again. Either delete that key too, or let a later record of the same key rewrite it. A table row is deleted by its key; a Redis value with DEL.

4. Remove it from the logs

A logger on a statement that read the event wrote it into its files ( Feature logging ). Those files are yours: erase the rows there with your usual tools, by the call's inputs.

Check the result

redis-cli HGET 'shop:pay:{7}:ids' 1001                       # (nil)
bash
SELECT count(*) FROM pay_history WHERE merchant_id = 7 AND payment_id = 1001;   -- 0
sql

A window read for merchant 7 no longer counts the payment.

Common failures

  • The event came back: a replay read the record again from the topic. Remove it again once the topic no longer holds it, or exclude it in the hook's WHERE.
  • A total still counts it: a latest value computed from it was not rewritten (§ 3).

Related