Skip to content

source-mysql v10: preserve saved schema history so column additions don't break CDC - #131

Open
tanishq171 wants to merge 1 commit into
source-mysql-gtid-patch-v9from
source-mysql-gtid-patch-v10
Open

source-mysql v10: preserve saved schema history so column additions don't break CDC#131
tanishq171 wants to merge 1 commit into
source-mysql-gtid-patch-v9from
source-mysql-gtid-patch-v10

Conversation

@tanishq171

Copy link
Copy Markdown
Collaborator

What

v10 of the patched source-mysql connector: preserve the saved Debezium schema history instead of unconditionally rebuilding it, so adding a column to a source table no longer breaks CDC. Built on v9 (source-mysql-gtid-patch-v9, the PR base) — this is the single schema-history commit on top of it.

Why

The v7 schema-history rebuild replaces the saved history with a fresh snapshot from live SHOW CREATE TABLE on every warm start. When a column is added on the source, that seeds the connector with the current (post-ALTER, N-column) shape, but the connector resumes from a saved binlog offset that predates the ALTER. Debezium then validates old, pre-ALTER row events (N-1 columns) against the rebuilt N-column schema and aborts:

Error processing row in <table>, internal schema size N, but row size N-1, restart connector with schema recovery mode.

Observed on testhub-015 → btcer (build_test_case_execution_results), job 18847: the rebuild jumped btcer to 83 columns while the connector was ~620 binlog files behind, so the first pre-ALTER 82-column row killed the sync — instead of Airbyte's normal auto-propagation of the new column.

The change

MySqlSourceDebeziumOperations.validate(): keep debeziumState.schemaHistory when non-empty; fall back to the SHOW CREATE TABLE rebuild only when there is no saved history to resume from. This lets Debezium replay the ALTER … ADD COLUMN from the binlog at its correct position and evolve the schema in lockstep — the stock behavior the v7 rebuild was clobbering.

Verification

  • Compiles clean.
  • Image boots clean (spec): tanishq171/source-mysql:3.52.3-gtid-patch-v10 (linux/amd64), digest sha256:ab2d029b392c9f062566f5970e658dab6c2279b98e81ecf4e22eaaebb0a11bcf.

Trade-off

The rebuild now runs only for empty history, so a non-empty-but-incomplete history (a table missing after a master/replica swap + retention gap — v7's original target) is no longer force-rebuilt. Accepted here in favor of not breaking column additions; revisit with a per-table merge if the swap case resurfaces.

🤖 Generated with Claude Code

…on't break CDC

The v7 schema-history rebuild unconditionally replaced the saved history with a fresh
snapshot from live SHOW CREATE TABLE. That breaks in-place schema evolution: when a
column is added on the source, the rebuild seeds the connector with the current
(post-ALTER) N-column shape, but the connector resumes from a saved binlog offset that
predates the ALTER. Debezium then validates old, pre-ALTER row events (N-1 columns)
against the rebuilt N-column schema and aborts with 'internal schema size N, but row
size N-1, restart connector with schema recovery mode' instead of auto-propagating the
new column.

v10 keeps the saved schema history whenever it is non-empty, letting Debezium replay the
ALTER DDL from the binlog at its correct position and evolve the schema in lockstep
(stock behavior). The SHOW CREATE TABLE rebuild now runs only when there is no saved
history to resume from. Trade-off: a non-empty-but-incomplete history (a table missing
after a swap + retention gap) is no longer force-rebuilt.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

👋 Welcome to Airbyte!

Thank you for your contribution from browserstack/airbyte! We're excited to have you in the Airbyte community.

If you have any questions, feel free to ask in the PR comments or join our Slack community.

💡 Show Tips and Tricks

PR Slash Commands

As needed or by request, Airbyte Maintainers can execute the following slash commands on your PR:

  • /format-fix - Fixes most formatting issues.
  • /bump-version - Bumps connector versions.
  • /run-connector-tests - Runs connector tests.
  • /run-cat-tests - Runs CAT tests.
  • /run-regression-tests - Runs regression tests for the modified connector(s).
  • /build-connector-images - Builds and publishes a pre-release docker image for the modified connector(s).
  • /publish-connectors-prerelease - Publishes pre-release connector builds (tagged as {version}-preview.{git-sha}) for all modified connectors in the PR.
  • /ai-review - AI-powered PR review for connector safety and quality gates.
  • /force-merge reason="<A_GOOD_REASON>" - Force merges the PR using admin privileges, bypassing CI checks. Requires a reason.

Tips for Working with CI

  1. Pre-Release Checks. Please pay attention to these, as they contain standard checks on the metadata.yaml file, docs requirements, etc. If you need help resolving a pre-release check, please ask a maintainer.
    • Note: If you are creating a new connector, please be sure to replace the default logo.svg file with a suitable icon.
  2. Connector CI Tests. Some failures here may be expected if your tests require credentials. Please review these results to ensure (1) unit tests are passing, if applicable, and (2) integration tests pass to the degree possible and expected.
  3. (Optional.) BYO Connector Credentials for tests in your fork. You can optionally set up your fork with BYO credentials for your connector. This can significantly speed up your review, ensuring your changes are fully tested before the maintainers begin their review.
📚 Show Repo Guidance

Helpful Resources

📝 Edit this welcome message.

@github-actions

Copy link
Copy Markdown

⚠️ PR Configuration Issue Detected

Hi @tanishq171, thank you for your contribution from browserstack/airbyte!

We've detected an issue with your PR configuration that is a barrier to effective and efficient review. To streamline your PR review and acceptance, Airbyte maintainers require the ability to push commits directly to your PR branch to apply formatting fixes, dependency updates, security patches, and other minor changes.

Specific details of the issue detected in your PR:

🏢 Organization Fork Detected

We have detected that your PR is from an organization fork rather than a personal fork. GitHub does not allow maintainers to commit directly to branches in organization forks. Learn more about allowing changes to a pull request branch created from a fork.

How to Fix:

  1. Fork the Airbyte repository under your personal GitHub account (not your organization).
  2. Push your branch to your personal fork.
  3. Create a new PR from your personal fork.

This will allow Airbyte maintainers to push any necessary fixes directly to your branch, significantly speeding up the review process.

Need Help?

If you have questions or need assistance, please:

Thank you for your understanding and for contributing to Airbyte! 🙏

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.

1 participant