SQLite online store lets an older write overwrite a newer value
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 55/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- python, sqlite
調査の方向性
Start by reading SqliteOnlineStore.online_write_batch and the SQLite online store tests; compare its upsert behavior with Redis online_write_batch, as described in the issue. Check how event_ts is stored and handled for older rows, especially the UTC migration in #7235. Done means older event timestamps cannot replace newer values while equal timestamps and legacy ISO text rows remain replaceable, with regression tests covering those cases.
索引モデルが issue の本文から書いたものです。
説明
Expected Behavior
The online store is supposed to hold the latest value per entity key (that's how docs/getting-started/components/online-store.md puts it), so a write whose event timestamp is older than the stored one shouldn't replace it. Redis already works this way: its online_write_batch skips any row that isn't newer than the timestamp it holds, a check that goes back to #1961 and was extended to rows inside a single batch in #6656.
Current Behavior
SqliteOnlineStore.online_write_batch upserts with ON CONFLICT(entity_key, feature_name) DO UPDATE SET ... and no condition, so whatever arrives last wins no matter its event time. A feast materialize over an older window, a delayed push or a late batch rolls the entity back to the older value, and get_online_features keeps serving it until something newer gets written. Since SQLite is the default store from feast init, this is the one most people start on.
Steps to reproduce
import os
import tempfile
from datetime import datetime, timedelta, timezone
import pandas as pd
from feast import Entity, FeatureStore, FeatureView, Field, FileSource
from feast.types import Float32
from feast.value_type import ValueType
tmp = tempfile.mkdtemp()
now = datetime.now(timezone.utc).replace(microsecond=0)
src = os.path.join(tmp, "stats.parquet")
pd.DataFrame({"user_id": [42], "ts": [now], "a": [0.0]}).to_parquet(src)
with open(os.path.join(tmp, "feature_store.yaml"), "w") as f:
f.write(
f"project: repro\nregistry: {tmp}/registry.db\nprovider: local\n"
f"online_store:\n type: sqlite\n path: {tmp}/online.db\n"
"offline_store:\n type: dask\nentity_key_serialization_version: 3\n"
)
user = Entity(name="user", join_keys=["user_id"], value_type=ValueType.INT64)
fv = FeatureView(
name="u_fv",
entities=[user],
ttl=timedelta(days=1),
schema=[Field(name="a", dtype=Float32)],
source=FileSource(path=src, timestamp_field="ts"),
)
fs = FeatureStore(repo_path=tmp)
fs.apply([user, fv])
def write(hours_ago, a):
row = pd.DataFrame({"user_id": [42], "ts": [now - timedelta(hours=hours_ago)], "a": [a]})
fs.write_to_online_store("u_fv", row)
def read():
return fs.get_online_features(["u_fv:a"], [{"user_id": 42}]).to_dict()["a"][0]
write(1, 2.0)
print("after write at now-1h:", read())
write(5, -1.0)
print("after write at now-5h:", read())
On master (136e3b102) this prints:
after write at now-1h: 2.0
after write at now-5h: -1.0
Specifications
- Version: master at 136e3b102
- Platform: macOS, Python 3.12, SQLite 3.53.1
- Subsystem: SQLite online store
Possible Solution
Add a WHERE to the upsert so the row is only replaced when excluded.event_ts >= event_ts. With that, the script above prints 2.0 both times. Equal timestamps would still overwrite so re-materializing the same window stays idempotent, and rows written before #4797 (ISO text in event_ts, which SQLite sorts above any integer) have to stay replaceable. I have this on a branch with tests and can open a PR.
There's one interaction I'd like your take on first. #7235 switches the stored epochs to UTC. On a host west of UTC, rows written before that change hold epochs that are ahead of the real event time by the UTC offset, so with the guard they'd block newer writes, including the full feast materialize backfill that #7235's upgrade notes recommend, until event times catch up (five hours in New York). I could land this after #7235 and add to its upgrade notes that those hosts should rebuild the SQLite file, or put the check behind an option. Which would you rather have? Postgres looks like it has the same unconditional upsert too, but I've only checked SQLite.
- 主要言語
- Python
- スター
- 7.4k
- フォーク
- 1.5k
- 平均マージ
- 2日 6時間
- マージ済み PR(30日)
- 107
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
feast-dev/feast のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
BigQuery data quality monitoring fails: PRIMARY KEY placed outside the column list in monitoring table DDL対応中かも @liron-velocity が 51 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
get_online_features silently drops a join key value when it shares a name with an OnDemandFeatureView's RequestSource field対応中かも @OHMFOHS が 99 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
kind/bug priority/p2
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
feast-dev/feast#6778 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
feast-dev/feast の issue をすべて見る
似ている issue
-
accepted
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
future-agi/future-agi#6392 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
memmapped_arange ignores the start value and drops the last point above the memmap threshold対応中かも @prathameshfuke が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
StingraySoftware/HENDRICS#213 ·
-
Bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 2 日以内に返信
-
bot-triaged module: decompositions module: edge cases module: int overflow module: primTorch oncall: pt2 triage review
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信