Skip to content

fix(destination-bigquery): retry typing+deduping queries on concurrent-update aborts - #76440

Draft
devin-ai-integration[bot] wants to merge 2 commits into
masterfrom
devin/1776426862-bq-retry-concurrent-update
Draft

fix(destination-bigquery): retry typing+deduping queries on concurrent-update aborts#76440
devin-ai-integration[bot] wants to merge 2 commits into
masterfrom
devin/1776426862-bq-retry-concurrent-update

Conversation

@devin-ai-integration

Copy link
Copy Markdown
Contributor

What

Resolves https://github.com/airbytehq/oncall/issues/11993:

BigQuery uses optimistic concurrency control for DML. When two transactions modify the same table in overlapping windows, BigQuery aborts one of them with:

Query error: Transaction is aborted due to concurrent update against table <project>:<dataset>.<table>.
Transaction ID: ... Blocking job: ...

The destination-bigquery connector's typing+deduping path wraps its MERGE / CREATE OR REPLACE TABLE statements in BEGIN TRANSACTION ... COMMIT TRANSACTION, which makes them eligible for this abort whenever another writer (a second sync, a dbt job, a scheduled query, an analyst query, etc.) touches the same final table. Because Sentry sees a unique transaction ID + table name on every occurrence, each hit groups as a new issue and generates oncall noise even though the canonical mitigation, per BigQuery docs on concurrent DML statements, is simply to retry the aborted transaction.

The typing+deduping operations we run here are idempotent, so retrying is safe.

How

In BigQueryDatabaseHandler.execute(sql):

  • Factor the BigQuery job submission + polling loop into runQueryWithConcurrentUpdateRetries.
  • On job.status.error, if the error (or any of its executionErrors) contains "Transaction is aborted due to concurrent update", retry with exponential backoff + jitter. Up to 5 total attempts, starting at 1s delay, capped at 60s.
  • All other errors propagate immediately, preserving today's behavior (including the existing ConfigErrorException wrapping for billing errors).

This keeps the fix scoped to the destination connector; no CDK changes are needed. Callers from the CDK's TypingDedupingFinalTableOperations (createFinalTable, softResetFinalTable, overwriteFinalTable, typeAndDedupe) transparently benefit because they all go through databaseHandler.execute(...).

Review guide

  1. airbyte-integrations/connectors/destination-bigquery/src/main/kotlin/io/airbyte/integrations/destination/bigquery/write/typing_deduping/BigQueryDatabaseHandler.kt — retry logic.
  2. airbyte-integrations/connectors/destination-bigquery/src/test/kotlin/io/airbyte/integrations/destination/bigquery/BigQueryDatabaseHandlerTest.kt — new unit tests for the retry path and error matcher.
  3. airbyte-integrations/connectors/destination-bigquery/metadata.yaml — version bump to 3.0.19.
  4. docs/integrations/destinations/bigquery.md — changelog entry.

Test Coverage

Unit tests added to BigQueryDatabaseHandlerTest:

  • isConcurrentUpdateError matches by top-level message
  • isConcurrentUpdateError matches by nested error message
  • isConcurrentUpdateError does not match unrelated errors
  • execute retries on concurrent-update error then succeeds — verifies the job is submitted 3 times when the first two attempts abort and the third succeeds.
  • execute rethrows concurrent-update error after exhausting retries — verifies the job is submitted exactly CONCURRENT_UPDATE_MAX_ATTEMPTS (5) times when every attempt aborts, and that the final exception is re-thrown.
  • execute does not retry on non-concurrent-update errors — regression guard so unrelated BigQuery errors still fail fast.

These tests fail against the prior execute() implementation (which did not retry) and pass with the new implementation.

Breaking Change Evaluation Gate:

  • No schema change, spec change, stream removal, PK/cursor change, or state-format change.
  • Result: not breaking. Applied PATCH version bump: 3.0.183.0.19.
  • enableProgressiveRollout: false — no -rc.x suffix needed.

User Impact

  • Syncs that previously failed with Transaction is aborted due to concurrent update during typing+deduping will now automatically retry up to 5 times before surfacing the error. In the common case (a transient concurrent write from a dbt job, another sync, or an analyst query), the retry will succeed and the sync will complete normally instead of failing.
  • If the concurrent writer is persistent and all 5 attempts are aborted, the sync still fails with the same BigQuery error as before — no behavioral regression.
  • The fix adds up to approximately 1 + 2 + 4 + 8 = 15 seconds of backoff before giving up in the worst case, plus jitter. For any single successful attempt, overhead is negligible.
  • No config changes required from customers.

Can this PR be safely reverted and rolled back?

  • YES 💚
  • NO ❌

Link to Devin session: https://app.devin.ai/sessions/8af8f94c618c4117b2cb6690605305c2

…t-update aborts

BigQuery uses optimistic concurrency control for DML. When two transactions
modify the same table in overlapping windows, BigQuery aborts one of them with
"Transaction is aborted due to concurrent update". The typing+deduping SQL
executed by the destination (MERGE, CREATE OR REPLACE TABLE) is idempotent, so
the canonical mitigation is to retry.

Retry up to 5 times with exponential backoff and jitter when we detect the
concurrent-update error text. Other errors continue to surface immediately.

Resolves airbytehq/oncall#11993.

Co-Authored-By: bot_apk <apk@cognition.ai>
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@github-actions

Copy link
Copy Markdown
Contributor

👋 Greetings, Airbyte Team Member!

Here are some helpful tips and reminders for your convenience.

💡 Show Tips and Tricks

PR Slash Commands

Airbyte Maintainers (that's you!) can execute the following slash commands on your PR:

  • 🛠️ Quick Fixes
    • /format-fix - Fixes most formatting issues.
    • /bump-version - Bumps connector versions, scraping changelog description from the PR title.
      • Bump types: patch (default), minor, major, major_rc, rc, promote.
      • The rc type is a smart default: applies minor_rc if stable, or bumps the RC number if already RC.
      • The promote type strips the RC suffix to finalize a release.
      • Example: /bump-version type=rc or /bump-version type=minor
    • /bump-progressive-rollout-version - Alias for /bump-version type=rc. Bumps with an RC suffix and enables progressive rollout.
  • ❇️ AI Testing and Review (internal link: AI-SDLC Docs):
    • /ai-prove-fix - Runs prerelease readiness checks, including testing against customer connections.
    • /ai-canary-prerelease - Rolls out prerelease to 5-10 connections for canary testing.
    • /ai-review - AI-powered PR review for connector safety and quality gates.
  • 🚀 Connector Releases:
    • /publish-connectors-prerelease - Publishes pre-release connector builds (tagged as {version}-preview.{git-sha}) for all modified connectors in the PR.
  • ☕️ JVM connectors:
    • /update-connector-cdk-version connector=<CONNECTOR_NAME> - Updates the specified connector to the latest CDK version.
      Example: /update-connector-cdk-version connector=destination-bigquery
  • 🐍 Python connectors:
    • /poe connector source-example lock - Run the Poe lock task on the source-example connector, committing the results back to the branch.
    • /poe source example lock - Alias for /poe connector source-example lock.
    • /poe source example use-cdk-branch my/branch - Pin the source-example CDK reference to the branch name specified.
    • /poe source example use-cdk-latest - Update the source-example CDK dependency to the latest available version.
  • ⚙️ Admin commands:
    • /force-merge reason="<REASON>" - Force merges the PR using admin privileges, bypassing CI checks. Requires a reason.
      Example: /force-merge reason="CI is flaky, tests pass locally"
📚 Show Repo Guidance

Helpful Resources

📝 Edit this welcome message.

Co-Authored-By: bot_apk <apk@cognition.ai>
@github-actions

github-actions Bot commented Apr 17, 2026

Copy link
Copy Markdown
Contributor

Deploy preview for airbyte-docs ready!

Project:airbyte-docs
Status: ✅  Deploy successful!
Preview URL:https://airbyte-docs-km3u7mc5p-airbyte-growth.vercel.app
Latest Commit:32ca95a

Deployed with vercel-action

@github-actions

Copy link
Copy Markdown
Contributor

destination-bigquery Connector Test Results

 22 files   22 suites   2h 3m 20s ⏱️
469 tests 418 ✅ 51 💤 0 ❌
470 runs  418 ✅ 51 💤 1 ❌

Results for commit 32ca95a.

@airbyte-support-bot

Copy link
Copy Markdown
Contributor

↪️ Triggering /ai-prove-fix per Hands-Free AI Triage Project triage next step.

Reason: Draft PR with CI green, no prior /ai-prove-fix, linked to sentry oncall issue:

Devin session

@octavia-bot

octavia-bot Bot commented Apr 18, 2026

Copy link
Copy Markdown
Contributor

🔍 AI Prove Fix session starting... Running readiness checks and testing against customer connections. View playbook

Devin AI session created successfully!

@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

Fix Validation Evidence — In Progress

Starting /ai-prove-fix workflow for this PR.

Status: Investigating

Current phase: Context gathering and pre-flight checks

I will update this same comment as I progress through:

  1. Pre-flight checks (viability, safety, breaking change, reversibility)
  2. Publishing a pre-release build
  3. Posting an evidence plan
  4. Gathering evidence (unit tests, regression tests where applicable, and/or live connection tests)
  5. Final evidence report

Devin session

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.

2 participants