Repository navigation
Description
Expected Behavior
get_historical_features() against the BigQuery offline store completes successfully after Feast uploads the entity dataframe to a temporary table.
Current Behavior
Intermittently, right after the entity dataframe upload job finishes, the subsequent call to set the temp table's expiration fails with:
google.api_core.exceptions.PreconditionFailed: 412 PATCH https://bigquery.googleapis.com/bigquery/v2/projects/<project>/datasets/<dataset>/tables/feast_entity_df_<uuid>?prettyPrint=false: Resource <project>:<dataset>.feast_entity_df_<uuid> did not meet condition IF_MATCH
This comes from _upload_entity_df in sdk/python/feast/infra/offline_stores/bigquery.py:
table = client.get_table(table=table_name)
table.expires = _utc_now() + timedelta(minutes=30)
client.update_table(table, ["expires"])get_table() reads the table along with its ETag; update_table() sends a conditional PATCH keyed on that ETag (If-Match). Shortly after the upload job (CREATE TABLE AS or load_table_from_dataframe) reports DONE, BigQuery can still be asynchronously finalizing the table's metadata (row counts, last-modified time, etc.), which changes the ETag server-side. If that happens between get_table() and update_table(), the PATCH is rejected — even though the table itself was created successfully.
This is a plain table-metadata PATCH, not a BigQuery job, so there's no failed job to find in the BigQuery Jobs Explorer — the only trace is this client-side exception, which makes the failure look spurious and is hard to diagnose from the GCP console alone.
Note: this 412 is BigQuery's ETag-based optimistic concurrency control working as designed — google.cloud.bigquery.Client.update_table's own docstring describes exactly this get_table → mutate → update_table pattern and states the write only succeeds if the server-side ETag still matches what was read. The twist here is that the ETag is being changed by BigQuery's own asynchronous metadata finalization right after the upload job completes, not by a genuine concurrent modification from another client. So there's no real conflict to resolve — refetching for a fresh ETag and retrying is the correct remedy rather than a sign the locking is broken.
Steps to reproduce
Timing-dependent on the BigQuery backend, so not reliably reproducible on demand, but observed in production: calling get_historical_features() with a pandas entity dataframe against the BigQuery offline store occasionally raises the PreconditionFailed above instead of returning results. Simply retrying the call succeeds.
Specifications
- Version: 0.66.0 (also present on
master) - Platform: Google Cloud / BigQuery
- Subsystem: offline store / bigquery
Possible Solution
Retry update_table on PreconditionFailed by refetching the table for a fresh ETag before reapplying the same field change, instead of failing the whole get_historical_features() call. I have a fix ready and will open a PR referencing this issue.
Activity