Skip to content

fix: Retry BigQuery entity table expiration on stale etag - #7239

Open
luisSilva1234 wants to merge 1 commit into
feast-dev:masterfrom
luisSilva1234:fix/bigquery-entity-table-expiration-race
Open

luisSilva1234 wants to merge 1 commit into
feast-dev:masterfrom
luisSilva1234:fix/bigquery-entity-table-expiration-race

Conversation

@luisSilva1234

@luisSilva1234 luisSilva1234 commented Nov 25, 2026 •

Copy link
Copy Markdown

What this PR does / why we need it:

The BigQuery offline store sets a 30-minute expiration on the temporary entity table it uploads via client.get_table() followed by client.update_table(table, ["expires"]). update_table sends a conditional PATCH keyed on the ETag from get_table().

Shortly after the upload job completes, BigQuery can still be asynchronously finalizing the table's metadata, which changes its ETag server-side. If that happens between the two calls, the PATCH is rejected with PreconditionFailed (412, "did not meet condition IF_MATCH") — even though the upload itself succeeded. Since this is a metadata PATCH and not a BigQuery job, the failure is invisible in the Jobs Explorer, making it confusing to diagnose.

Note: this is BigQuery's ETag-based optimistic concurrency control working as designed (see Client.update_table's own docstring: a stale table.etag causes the write to be rejected unless the server-side ETag still matches). The twist is that the ETag is being changed by BigQuery's own asynchronous metadata finalization, not a genuine concurrent modification from another client, so there's no real conflict to resolve — refetch-and-retry is the correct remedy.

This PR extracts the expiration logic into _set_table_expiration() and retries it (up to 5 attempts) on PreconditionFailed, refetching the table for a fresh ETag before each retry.

Which issue(s) this PR fixes:

Fixes #7238

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

Misc

Added TestSetTableExpiration covering: success on first attempt, recovery after a transient PreconditionFailed, and exhausting retries. Verified with black --check and ruff check on the changed files.


Devin Review

@luisSilva1234
luisSilva1234 requested review from a team and sudohainguyen as code owners November 25, 2026 11:39

@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: 5 flags

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

Devin Review

@luisSilva1234
luisSilva1234 force-pushed the fix/bigquery-entity-table-expiration-race branch from 6a982a2 to 2e14ad2 Compare November 25, 2026 11:52
@luisSilva1234 luisSilva1234 changed the title fix: retry BigQuery entity table expiration on stale etag fix: Retry BigQuery entity table expiration on stale etag Nov 25, 2026
The BigQuery offline store sets a 30-minute expiration on the temporary
entity table it uploads by calling client.get_table() followed by
client.update_table(table, ["expires"]). update_table sends a
conditional PATCH keyed on the etag returned by get_table().

Shortly after the job that creates the table completes, BigQuery can
still be asynchronously finalizing the table's metadata (e.g. row
counts, last modified time), which changes its etag server-side. If
that happens between get_table() and update_table(), the PATCH is
rejected with a PreconditionFailed (412, "did not meet condition
IF_MATCH"), even though the upload itself succeeded. Because this is
a table metadata PATCH rather than a BigQuery job, the failure leaves
no trace in the BigQuery Jobs Explorer, making it look spurious and
hard to diagnose from the GCP console.

Extract the expiration logic into _set_table_expiration() and retry
it on PreconditionFailed, refetching the table for a fresh etag
before each retry.

Signed-off-by: Luis Silva <58522514+luisSilva1234@users.noreply.github.com>
@luisSilva1234
luisSilva1234 force-pushed the fix/bigquery-entity-table-expiration-race branch from 2e14ad2 to 8bcb5aa Compare November 25, 2026 12:01
@codecov-commenter

codecov-commenter commented Nov 25, 2026 •

Copy link
Copy Markdown

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

Codecov Report

❌ Patch coverage is 90.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 54.11%. Comparing base (a291a0f) to head (8bcb5aa).

Files with missing lines Patch % Lines
sdk/python/feast/infra/offline_stores/bigquery.py 90.00% 1 Missing ⚠️
❗ 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    #7239   +/-   ##
=======================================
  Coverage   54.10%   54.11%           
=======================================
  Files         467      467           
  Lines       58940    58945    +5     
  Branches     8688     8688           
=======================================
+ Hits        31890    31897    +7     
+ Misses      24892    24890    -2     
  Partials     2158     2158           
Flag Coverage Δ
go-feature-server 30.96% <ø> (ø)
python-unit 55.71% <90.00%> (+<0.01%) ⬆️
Files with missing lines Coverage Δ
sdk/python/feast/infra/offline_stores/bigquery.py 50.15% <90.00%> (+0.70%) ⬆️

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 a291a0f...8bcb5aa. 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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BigQuery offline store: spurious 412 PreconditionFailed when setting entity table expiration

2 participants