Skip to content

[release-23.0] VReplication: reload the schema at a DDL only once MySQL has committed it (#21887) - #22142

Merged
mattlord merged 2 commits into
release-23.0from
backport-21887-to-release-23.0
Nov 23, 2026
Merged

mattlord merged 2 commits into
release-23.0from
backport-21887-to-release-23.0

Conversation

@vitess-bot

@vitess-bot vitess-bot Bot commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Description

This is a backport of #21887

Copilot AI balanced review requested due to automatic review settings November 23, 2026 16:32
@vitess-bot

vitess-bot Bot commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Hello @mattlord, there are conflicts in this backport.

Please address them in order to merge this Pull Request. You can execute the snippet below to reset your branch and resolve the conflict manually.

Make sure you replace origin by the name of the vitessio/vitess remote

git fetch --all
gh pr checkout 22142
git reset --hard origin/release-23.0
git cherry-pick -m 1 1e5ae1ac842184e23c973bef2d4194c448bb5b9a

Copilot AI 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.

🟡 Changes recommended

Unresolved merge conflicts, incompatible logging, and missing test helpers prevent compilation, while incorrect DDL GTID wiring leaves the schema-visibility race unfixed.

6 open issues
What changed in this PR

Backports #21887 to release-23.0 to prevent VReplication and schema tracking from loading stale schemas before MySQL commits a DDL.

Changes:

  • Adds shared, GTID-specific commit waits with timeout handling and DDLCommitWait metrics.
  • Updates vstreamer DDL reload handling and adds unit and semi-sync regression tests.
  • Expands timeout flag help and adds release-summary documentation.
File Description
go/​vt/​vttablet/​tabletserver/​vstreamer/​vstreamer.go Adapts DDL reload handling to wait for commit and propagate errors.
go/​vt/​vttablet/​tabletserver/​vstreamer/​vstreamer_test.go Adds a semi-sync regression test and historian tests/helpers.
go/​vt/​vttablet/​tabletserver/​tabletenv/​config.go Documents the timeout’s separate commit-wait bound.
go/​vt/​vttablet/​tabletserver/​schema/​engine.go Implements shared DDL commit waits, cancellation, logging, and metrics.
go/​vt/​vttablet/​tabletserver/​schema/​engine_test.go Covers wait sharing, failures, cancellation, and metrics.
go/​flags/​endtoend/​vttablet.txt Updates expected vttablet timeout help text.
go/​flags/​endtoend/​vtcombo.txt Updates expected vtcombo timeout help text.
changelog/​25.0/​25.0.0/​summary.md Adds the v25 release summary, including DDL-wait metrics.

Review effort: Balanced

In vstreamer.go, release-23.0 keeps eventGTID as a replication.GTID, set and cleared at the same binlog events as main's new gtid field, so the gtid field and the setEventGTID change are dropped and the DDL handler passes vs.eventGTID to ReloadAtDDL. The reload at a DDL is best effort on release-23.0 (main's error check and rebuildPlans come from #19204), so the error is still not returned; it is logged unless the stream was cancelled. The call uses the stream's context rather than context.Background(), so that a stream cancel does not wait out the DDL commit wait.

In engine.go, log.Warningf replaces the slog-style log.Warn, which release-23.0 does not have.

In engine_test.go, the imports keep release-23.0's strings and add sync and sync/atomic.

In vstreamer_test.go, only TestSchemaReloadWaitsForDDLCommit and the four helpers it uses are kept (createSchemaVersionTable as #21887 changed it, isolateSchemaVersionTable, insertSchemaVersionRow and makeHistorianMinimalTable). The historian startup tests and helpers from #19697, which is not on release-23.0, are dropped. The replication and schema imports are added, and one comment is reworded, since release-23.0's tracker streams from the current position.

The 25.0.0 changelog summary is dropped, since release-23.0 does not have it.

Signed-off-by: Matt Lord <mattalord@gmail.com>
@mattlord mattlord removed Skip CI Skip CI actions from running Merge Conflict labels Nov 23, 2026
Copilot AI balanced review requested due to automatic review settings November 23, 2026 17:08
@mattlord mattlord self-assigned this Nov 23, 2026
@mattlord

Copy link
Copy Markdown
Member

Resolved the conflicts. release-23.0 hadn't moved since the cherry-pick, so there was nothing to merge in.

Conflicts and how they were resolved

  • vstreamer.go: on release-23.0, eventGTID is still a replication.GTID (vstreamer: format EventGtid once per GTID event #21289's string form and setEventGTID aren't on this branch). It's set and cleared at the same binlog events as the gtid field that VReplication: reload the schema at a DDL only once MySQL has committed it #21887 added on main, so I dropped that field and the setEventGTID change, and the DDL handler passes vs.eventGTID to ReloadAtDDL. This also fixes the conflict commit's DDL handler, which passed the unset vs.gtid.
  • DDL reload error handling: on this branch the reload at a DDL is best effort. Its error is ignored and there's no rebuildPlans, since both come from VStream: move vstream schema change handling from best effort to reliable #19204, which isn't on release-23.0. I kept that: the error still isn't returned, but it's now logged unless the stream was cancelled, so a commit wait that times out is visible. The call now uses the stream's context instead of context.Background(), so a cancelled stream (for example on vstreamer.Engine.Close or a tracker disable during a demotion) doesn't wait out the commit wait, which is bounded by --schema-change-reload-timeout. If the wait fails, the stream goes on as it did before this change.
  • engine.go: log.Warn with slog attributes became log.Warningf, since this branch's log package has no structured Warn and the file doesn't import slog.
  • engine_test.go: imports are this branch's strings plus sync and sync/atomic. strconv is dropped because nothing uses it.
  • vstreamer_test.go: the conflict block also held the historian startup tests and helpers from VReplication: Improve historian / schema tracker #19697, which isn't on this branch. I kept only TestSchemaReloadWaitsForDDLCommit and the four helpers it uses (createSchemaVersionTable as VReplication: reload the schema at a DDL only once MySQL has committed it #21887 changed it, isolateSchemaVersionTable, insertSchemaVersionRow, makeHistorianMinimalTable), and added the replication and schema imports. One comment is reworded, since on this branch the tracker streams from the current position rather than resuming from the last saved version.
  • changelog/25.0/25.0.0/summary.md: the cherry-pick added the whole 25.0 summary, which doesn't belong on release-23.0, so I dropped it.

The flag help changes in vttablet.txt, vtcombo.txt and tabletenv/config.go applied cleanly.

Testing (Go 1.25.13, MySQL 8.0.46)

  • TestOpenAndReload with -race, and the full schema and tabletenv packages with -race: pass.
  • TestSchemaReloadWaitsForDDLCommit against real MySQL: passes. With the fix's non-test changes reverted, it fails (the tracker saves the pre-RENAME schema), and so does TestOpenAndReload.
  • Full vstreamer package once: pass.
  • TestHelpOutput for vttablet and vtcombo: pass.
  • NOVTADMINBUILD=1 make build, and this branch's pinned golangci-lint on the changed packages: clean.

Copilot AI 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.

🟡 Changes recommended

A failed or timed-out schema reload still allows the DDL event to advance, causing the schema tracker to persist pre-DDL columns as the new schema version.

1 open issue
6 resolved since last review

Review effort: Balanced

@mattlord
mattlord merged commit e8f3f96 into release-23.0 Nov 23, 2026
153 of 154 checks passed
@mattlord
mattlord deleted the backport-21887-to-release-23.0 branch November 23, 2026 20:07
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.

3 participants