Repository navigation
fix: Raise on failed Bigtable mutate_rows statuses in BigtableOnlineStore - #7245
AnhVanGiang wants to merge 2 commits into
Conversation
…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>
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)
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 Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ 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
... and 1 file with indirect coverage changes Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
What this PR does / why we need it:
Problem
BigtableOnlineStore._write_rows_to_btcallsbt_table.mutate_rows(rows)and ignores what it returns.Table.mutate_rowsdoes not raise when rows fail. It returns onegoogle.rpc.Statusper row. A failed or partlyfailed batch therefore returns normally, and
online_write_batchandfeast materializereport success (pushand
write_to_online_storeuse the same call). The materialized window is also recorded in the registry,so
materialize_incrementalmoves 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
Nonefor 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:On master (
f2abc7c926) it prints this and exits 0, although all three writes failed:With this PR it exits 1:
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_rowsreturns ([14, 14, 14]), runs ongoogle-cloud-bigtable 2.45.0 and 2.32.0 (
[None, None, None]after about two minutes), and an end-to-end CLI runagainst the Bigtable emulator: #7244.
Change
After
mutate_rows,_write_rows_to_btcollects every row whose status isNoneor non-zero and raisesRuntimeError. The error gives the number of failed rows in that write request, the table, and the first failedstatus code. The row key and the status message are left out. Counts are per request (one
_write_rows_to_btcall), not per job. For example:online_write_batchalready waits for every write future and callstask.result(), so the error reaches thecaller. Batches that succeeded stay written, as before: Bigtable writes are not atomic across requests, and
re-running the materialization rewrites the same cells.
RuntimeErrormatches the existing "Not all batcheswere written to Bigtable" error in
online_write_batch.progressis now called only for batchesthat 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,
Nonestatuses, and the error reaching the caller throughonline_write_batch.With
bigtable.pyreverted to master and the tests kept, 3 fail. The one that passes is the all-OK control. Withthe change, all 12 tests in the file pass, and so do the 31 tests across both Bigtable unit test files. The
checks
make lint-pythonruns (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:
code=14, window not recordedThese runs used Feast 0.54.0 and 0.68.0 with the patch applied to the installed package. The
_write_rows_to_btcode is identical on master.
Which issue(s) this PR fixes:
Fixes #7244
Checks
git commit -s)Testing Strategy
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 thenretry 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.