Skip to content

fix: Raise on failed Bigtable mutate_rows statuses in BigtableOnlineStore - #7245

Open
AnhVanGiang wants to merge 2 commits into
feast-dev:masterfrom
AnhVanGiang:fix/bigtable-mutate-rows-statuses
Open

AnhVanGiang wants to merge 2 commits into
feast-dev:masterfrom
AnhVanGiang:fix/bigtable-mutate-rows-statuses

Conversation

@AnhVanGiang

@AnhVanGiang AnhVanGiang commented Nov 26, 2026 •

Copy link
Copy Markdown

What this PR does / why we need it:

Problem

BigtableOnlineStore._write_rows_to_bt calls bt_table.mutate_rows(rows) and ignores what it returns.
Table.mutate_rows does not raise when rows fail. It returns one google.rpc.Status per row. A failed or partly
failed batch therefore returns normally, and online_write_batch and feast materialize report success (push
and write_to_online_store use the same call). The materialized window is also recorded in the registry,
so materialize_incremental moves past it and never writes the missing rows.

On google-cloud-bigtable 2.45.0 and later this happens on the first transient error. Feast writes cells with the
server-side timestamp, which the client treats as non-idempotent, so they are never retried, and the client
returns an exception raised by the RPC as each unfinished row's status. I measured a refused connection (status
14 on every row); other RPC errors take the same path in the client source. Below 2.45.0 the legacy client
retries retryable codes until its 120 s deadline, then returns None for rows that never got a response
(measured on 2.32.0 with a refused connection) and the last status for the rest.

Reproduction

This needs no emulator or cloud access. Pointing the client at a closed local port makes every write fail.
Save this as repro.py:

from datetime import datetime, timezone

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)
]
BigtableOnlineStore().online_write_batch(config, fv, rows, progress=None)
print("online_write_batch returned normally")
BIGTABLE_EMULATOR_HOST=localhost:1 python repro.py

On master (f2abc7c926) it prints this and exits 0, although all three writes failed:

online_write_batch returned normally

With this PR it exits 1:

RuntimeError: Failed to write 3 of 3 rows to Bigtable table repro.driver; first failed status: code=14

I ran this exact script on master and on this branch, in the same checkout with google-cloud-bigtable 2.50.2.
The issue has a variant that prints the statuses mutate_rows returns ([14, 14, 14]), runs on
google-cloud-bigtable 2.45.0 and 2.32.0 ([None, None, None] after about two minutes), and an end-to-end CLI run
against the Bigtable emulator: #7244.

Change

After mutate_rows, _write_rows_to_bt collects every row whose status is None or non-zero and raises
RuntimeError. The error gives the number of failed rows in that write request, the table, and the first failed
status code. The row key and the status message are left out. Counts are per request (one _write_rows_to_bt call), not per job. For example:

RuntimeError: Failed to write 5 of 5 rows to Bigtable table repro.rider; first failed status: code=13

online_write_batch already waits for every write future and calls task.result(), so the error reaches the
caller. Batches that succeeded stay written, as before: Bigtable writes are not atomic across requests, and
re-running the materialization rewrites the same cells. RuntimeError matches the existing "Not all batches
were written to Bigtable" error in online_write_batch. progress is now called only for batches
that succeeded.

Retry behaviour is unchanged. On 2.45.0 and later, a transient error now fails the job instead of losing the
batch silently, and a scheduler retry, if one is configured, runs it again. See Misc.

Verification

To run the tests, from sdk/python: pytest tests/unit/infra/online_store/test_bigtable_online_store.py.

4 new tests in that file: all rows OK (progress reported),
one failed status in three, None statuses, and the error reaching the caller through online_write_batch.
With bigtable.py reverted to master and the tests kept, 3 fail. The one that passes is the all-OK control. With
the change, all 12 tests in the file pass, and so do the 31 tests across both Bigtable unit test files. The
checks make lint-python runs (ruff check, ruff format --check, mypy feast) are clean. All of this ran in a master checkout
(f2abc7c926) with the CI requirements.

I also ran the Feast CLI with the local engine against the Bigtable emulator v1.58.2:

Scenario without this PR with this PR
Bigtable unreachable exit 0, window recorded exit 1, code=14, window not recorded
Healthy table all rows online exit 0, all rows online
One of two tables rejects its rows exit 0, that table empty exit 1, error names that table

These runs used Feast 0.54.0 and 0.68.0 with the patch applied to the installed package. The _write_rows_to_bt
code is identical on master.

Which issue(s) this PR fixes:

Fixes #7244

Checks

  • I've made sure the tests are passing.
  • My commits are signed off (git commit -s)
  • My PR title follows conventional commits format

Testing Strategy

  • Unit tests
  • Integration tests
  • Manual tests
  • Testing is not required for this change

Misc

Retrying is left for a follow-up because it needs a decision on cell timestamps. Passing an explicit timestamp to
set_cell (for example, one write time per batch) would make the mutations idempotent. The client would then
retry UNAVAILABLE, DEADLINE_EXCEEDED, ABORTED and INTERNAL with backoff for up to its default 120 s deadline. I
checked this against a closed port: with explicit timestamps the client kept retrying until its deadline, while
Feast's current cells returned after a single attempt. The cost is that "latest cell wins" would follow the
writer's clock instead of Bigtable's, which matters when two writers update the same entity at nearly the same
time. I can send that as a separate PR if maintainers agree with the trade-off.


Devin Review

…tore

Table.mutate_rows does not raise when rows fail. It returns one status per
row, and None for a row that never got a response on google-cloud-bigtable
< 2.45. _write_rows_to_bt ignored the result, so failed writes were dropped
and feast materialize exited 0.

Check every status after mutate_rows and raise RuntimeError with the failed
row count, the table and the first failed row key and status.

Signed-off-by: Van Anh Giang <27738449+AnhVanGiang@users.noreply.github.com>
@AnhVanGiang
AnhVanGiang requested a review from a team as a code owner November 26, 2026 10:53

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 potential issue.

2 flags not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)

Devin Review

The status message can carry the backend address, and the feature server returns exception text to the write caller. The error now reports the failed row count, the total, the table and the first status code.

Signed-off-by: Van Anh Giang <27738449+AnhVanGiang@users.noreply.github.com>
@codecov-commenter

codecov-commenter commented Nov 26, 2026 •

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 54.28%. Comparing base (f2abc7c) to head (1f4b798).
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #7245      +/-   ##
==========================================
+ Coverage   54.26%   54.28%   +0.01%     
==========================================
  Files         467      467              
  Lines       59041    59045       +4     
  Branches     8712     8713       +1     
==========================================
+ Hits        32040    32052      +12     
+ Misses      24837    24828       -9     
- Partials     2164     2165       +1     
Flag Coverage Δ
go-feature-server 30.96% <ø> (ø)
python-unit 55.89% <100.00%> (+0.01%) ⬆️
Files with missing lines Coverage Δ
sdk/python/feast/infra/online_stores/bigtable.py 78.73% <100.00%> (+3.61%) ⬆️

... and 1 file with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f2abc7c...1f4b798. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

This branch has not been deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

3 participants