Repository navigation
feat: Add online append for sequence feature views - #7215
patelchaitany wants to merge 2 commits into
Conversation
Signed-off-by: Chaitany Patel <patelchaitany93@gmail.com>
There was a problem hiding this comment.
Devin Review found 1 potential issue.
2 flags not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)
| pipe.zadd(redis_key_bin, events) | ||
| if cutoff is not None: | ||
| pipe.zremrangebyscore(redis_key_bin, "-inf", f"({cutoff}") | ||
| if max_length: | ||
| pipe.zremrangebyrank(redis_key_bin, 0, -(max_length + 1)) |
There was a problem hiding this comment.
🔴 Late duplicates erase newer sequence events
When identical feature values for an entity arrive newest first, online_append replaces the newer timestamp with the older one. Age or length trimming can then delete the entry even though the newer event qualified for retention.
Learn more
write_to_online_store routes append-mode DataFrames through ingest_df without sorting the rows. Redis stores one timestamp per sorted-set member, and _group_append_events uses only the feature values as the member. Within one batch, the last row with matching values wins; across batches, ZADD unconditionally replaces the existing score. The newer timestamp is lost in both cases, and the retention commands can then remove the remaining entry. online_append_async has the same behavior.
Example: At noon, write a value of 7 for entity 42 with an 11:55 event time and a one-hour age limit. Then append a delayed 10:00 event with the same value. Redis moves the entry to 10:00 and trims it, leaving no record of the 11:55 event. Submitting the two rows in that order in one batch has the same result.
Recommended fix: Include the event timestamp in the member identity so the older event can be trimmed independently. If retaining the payload-only format for now, keep the maximum timestamp in each batch and prevent Redis score updates from decreasing an existing score, using ZADD GT where supported. Cover newest-first inputs both within one batch and across writes.
Was this helpful? React with 👍 or 👎 to provide feedback.
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #7215 +/- ##
==========================================
+ Coverage 54.10% 54.14% +0.04%
==========================================
Files 467 467
Lines 58940 59011 +71
Branches 8688 8703 +15
==========================================
+ Hits 31890 31953 +63
- Misses 24892 24893 +1
- Partials 2158 2165 +7
... and 1 file with indirect coverage changes Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
The sorted set member was only the serialized feature values, so two events with the same values shared one member. A late, older event then moved that member back to its own time, and the max_age trim could drop it, losing the newer event. This happened within one batch (last row wins) and across writes (ZADD replaces the score). Prefix the member with the event time as an 8-byte big-endian integer of microseconds. Each event is now its own member, and writing the same event time and values again still adds nothing. Signed-off-by: Chaitany Patel <patelchaitany93@gmail.com>
What this PR does / why we need it:
#6848 added
OnlineConfig, so a feature view can be set tomode="sequence"withwrite_mode="append". But every online write still went throughonline_write_batch, which keeps only the latest value per entity. This PR adds the write path that keeps every event.OnlineStoreAPI.online_appendandonline_append_asynctake the same rows asonline_write_batch. The default implementations raiseNotImplementedError, so other stores keep working and fail clearly only when a feature view uses append mode.seq:<feature view>:followed by the entity's existing hash key.feast.types.Map. Each event is its own member, even when its values repeat an earlier event, so a late, older event can't move or trim a newer one. Writing the same event time and values again adds nothing.ZADDper batch. All keys go in one non-transactional pipeline.ZADD,ZREMRANGEBYSCOREdrops events older thanmax_age, thenZREMRANGEBYRANKkeeps the newestmax_length.key_ttl_secondsapplies to these keys the same way it does to the hash keys. The trim is not atomic with the write, so readers should read at mostmax_lengthevents.PassthroughProvider.ingest_dfandingest_df_async(used bywrite_to_online_storeand push) callonline_appendwhen the feature view'sonline_config.write_modeis"append", andonline_write_batchotherwise. Feature views withoutonline_configbehave exactly as before.Out of scope (follow-up PRs)
feast materializefor sequence-mode feature views.online_read_sequence) andget_online_featuressupport.delete_tableandteardowndon't remove theseq:keys yet.Which issue(s) this PR fixes:
Part of RHOAIENG-80117 (online append). Follows #6848.
Checks
git commit -s)Testing Strategy
New tests:
tests/unit/infra/online_store/test_online_store_base.py:online_appendandonline_append_asyncraiseNotImplementedErrorby default.tests/unit/infra/online_store/test_redis.py: every value for an entity is kept in its sorted set; themax_lengthandmax_agetrims are issued after theZADD; the async path uses the async Redis client; a late, older event with the same values, in the same batch or a later write, doesn't move the newer event's time, so themax_agetrim keeps it.tests/unit/test_online_config_apply.py:write_to_online_storecallsonline_appendfor an append-mode feature view andonline_write_batchotherwise.The related unit suites pass (60 passed). ruff and scoped mypy on the changed modules are clean.