fix(google-cloud): a BigQuery table created by a concurrent run is not an error - #330
Merged
Merged
Conversation
…t an error Two runs writing different partitions of the same new table race on its creation, and the loser got a 409 Conflict that failed its whole run under fail-fast. Dataset creation already tolerated that; table creation now does too and loads into the table that just appeared. By Digitl
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
BigQueryDestination._create_tableraised on a 409 Conflict from BigQuery. Two runs writingdifferent partitions of the same asset whose table does not exist yet (a backfill, or a queue burst
after downtime, or two runs queued back to back on a fresh destination) both see no table, both create
it, and the loser fails with
Already Exists, which fail-fast turns into a failed run with everyother asset canceled.
_ensure_datasetalready tolerated the same race for datasets;_create_tablenow does the same and loads into the table that just appeared, which has the schema it wanted.
Found while materializing a fresh destination locally: two job runs for consecutive days executed in
parallel and the second failed on
facebook_ads.campaigns__<account>. Production schedules one runper job per day, which is why it has not shown there.
Verification
get_tablereports no table,create_tableraisesConflict, the rows still load.uv run --frozen pytest packages/interloper-google-cloud: 124 passed. ruff and ty clean.By Digitl