Skip to content

Bigtable online store ignores failed row writes, so feast materialize exits 0 with rows missing #7244

Backlog

Description

@AnhVanGiang

Expected Behavior

If Bigtable rejects rows during feast materialize (or any other online_write_batch call), the call raises and
the command exits non-zero. The window is not recorded as materialized, so the next run writes it again.

Current Behavior

BigtableOnlineStore._write_rows_to_bt calls bt_table.mutate_rows(rows) and ignores what it returns
(sdk/python/feast/infra/online_stores/bigtable.py:411 on master). Table.mutate_rows does not raise when rows
fail. It returns one google.rpc.Status per row, and the caller has to check them. Because Feast never checks,
a write that fails completely or partly is dropped without any error:

  • feast materialize exits 0 and prints nothing unusual.
  • The window is recorded in the registry. materialize_incremental() starts from
    feature_view.most_recent_end_time, so later incremental runs skip the window and never write the missing
    rows. Only re-running that window by hand fixes it.
  • On master, the materialization tracker also records the feature view as a success (from reading the code).

On google-cloud-bigtable 2.45.0 and later, a single transient error is enough to trigger this. Feast calls
set_cell without a timestamp, which uses the server-side timestamp (-1). SetCell.is_idempotent() is False
for that value, and the client only re-queues idempotent entries (data/_sync_autogen/_mutate_rows.py), so
Feast's writes are never retried. The client also attaches any exception raised by the RPC to every unfinished
row and returns it as that row's status instead of raising. I measured this with a refused connection (status 14
for every row, on 2.45.0 and 2.50.2). Other RPC errors such as DEADLINE_EXCEEDED or auth failures take the same
path in the source, but I did not trigger them.

Below 2.45.0 the legacy client retries retryable codes until its 120 s deadline. A row that never got a response
comes back as None, and a row with a per-row error keeps its last status. With a refused connection on 2.32.0,
online_write_batch returned normally after about two minutes, and mutate_rows had returned
[None, None, None]. Feast ignores those too.

write_to_online_store, push and the other compute engines all go through online_write_batch, so they hit
the same code. I only ran the local engine.

Steps to reproduce

This needs no emulator and no cloud access. It points the client at a closed local port, so every write fails.

# BIGTABLE_EMULATOR_HOST=localhost:1 python minimal_repro.py
from datetime import datetime, timezone

from google.cloud.bigtable.table import Table

from feast import Entity, FeatureView, Field, FileSource
from feast.infra.online_stores.bigtable import BigtableOnlineStore, BigtableOnlineStoreConfig
from feast.protos.feast.types.EntityKey_pb2 import EntityKey
from feast.protos.feast.types.Value_pb2 import Value
from feast.repo_config import RepoConfig
from feast.types import Int64

config = RepoConfig(
    project="repro",
    provider="local",
    registry="registry.db",
    online_store=BigtableOnlineStoreConfig(project_id="p", instance="i"),
    entity_key_serialization_version=3,
)
fv = FeatureView(
    name="driver_stats",
    entities=[Entity(name="driver", join_keys=["driver_id"])],
    schema=[Field(name="trips", dtype=Int64)],
    source=FileSource(path="unused.parquet", timestamp_field="ts"),
)
now = datetime.now(timezone.utc)
rows = [
    (EntityKey(join_keys=["driver_id"], entity_values=[Value(int64_val=i)]), {"trips": Value(int64_val=i)}, now, None)
    for i in range(3)
]

returned = []
original = Table.mutate_rows
Table.mutate_rows = lambda self, r, *a, **k: returned.append(original(self, r, *a, **k)) or returned[-1]

BigtableOnlineStore().online_write_batch(config, fv, rows, progress=None)
print("online_write_batch returned normally")
print("statuses mutate_rows returned:", [None if s is None else s.code for s in returned[0]])

Output on Feast 0.54.0 and 0.68.0 with google-cloud-bigtable 2.50.2 (2.45.0 prints the same; 2.32.0 prints
[None, None, None] after about two minutes):

online_write_batch returned normally
statuses mutate_rows returned: [14, 14, 14]

The wrapper around Table.mutate_rows only records the return value so it can be printed. Feast behaves the
same without it.

I also ran a fuller version with the CLI against the Bigtable emulator
(cloud.google.com/go/bigtable/cmd/emulator v1.58.2), with two feature views on two tables:

Scenario feast exit code Rows online Per-row statuses
materialize with Bigtable unreachable 0 0/5, 0/5 {14: 5}, {14: 5}
then materialize-incremental with Bigtable back 0 0/5, 0/5 (the window is skipped) n/a
materialize after one table loses its column family 0 5/5, 0/5 {0: 5}, {13: 5}

A single mutate_rows call can also partly fail: with rows a, b and c, where b names a missing column
family, the statuses are [0, 13, 0] and only a and c are stored.

Specifications

  • Version: Feast 0.54.0 and 0.68.0 (latest release) reproduced; on master f2abc7c926 the unit tests in the
    PR fail the same way. google-cloud-bigtable 2.50.2 for the emulator runs; the minimal repro also on 2.45.0 and 2.32.0.
  • Platform: Python 3.11, macOS arm64. Nothing here depends on the platform.
  • Subsystem: online store, Bigtable (sdk/python/feast/infra/online_stores/bigtable.py)

Possible Solution

Check the statuses in _write_rows_to_bt and raise if any row is None or has a non-zero code.
online_write_batch already re-raises exceptions from its write futures via task.result(), so the error
reaches the caller, and the window is not recorded. I have a PR ready with this change and unit tests.

Retries could be a separate change. Writing cells with an explicit timestamp would make them idempotent, so the
client would retry transient errors for up to its 120 s deadline. That changes which cell wins when two writes
race (client clock instead of server clock), so it seemed worth discussing first.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions