Skip to content

Fix handling of warnings on DML batches#1643

Open
ggilder wants to merge 13 commits intogithub:masterfrom
ggilder:fix-dml-batch-issue
Open

Fix handling of warnings on DML batches#1643
ggilder wants to merge 13 commits intogithub:masterfrom
ggilder:fix-dml-batch-issue

Conversation

@ggilder
Copy link
Contributor

@ggilder ggilder commented Mar 10, 2026

Related issue: #1636

Description

This is a follow-up to #1633 — this was actually an incomplete fix for the data loss issue described there, because any DML events that would cause data loss that happened in the middle of a batch could be masked by success of the final statement in the batch. This code change now runs SHOW WARNINGS after each statement in a batch so that we collect all warnings.

  • contributed code is using same conventions as original code
  • script/cibuild returns with no formatting errors, build errors or unit test errors.

ggilder added 2 commits March 9, 2026 15:45
- Regex meta characters in index names should not break warning
  detection (required code fix)
- Improve tests that only checked number of rows (need to validate data
  as well)
- Test positive case allowing ignored duplicates on migration key
- Test behavior with PanicOnWarnings disabled
Copilot AI review requested due to automatic review settings March 10, 2026 17:33
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Improves --panic-on-warnings safety during binlog replay by ensuring warnings emitted by any statement inside a batched DML multi-statement are detected (not just the last statement), addressing the masking/data-loss scenario from #1636 / follow-up to #1633.

Changes:

  • Add executeBatchWithWarningChecking() to interleave SHOW WARNINGS after each DML in a batch when PanicOnWarnings is enabled.
  • Update ApplyDMLEventQueries() to use the new warning-checking execution path only for PanicOnWarnings (keep existing fast path otherwise).
  • Add a new unit test and a new local integration test case to validate “warning in the middle of a batch” behavior.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
localtests/panic-on-warnings-batch-middle/extra_args Adds localtest arguments enabling --panic-on-warnings with a unique index alter.
localtests/panic-on-warnings-batch-middle/expect_failure Asserts failure output contains warning-detection text.
localtests/panic-on-warnings-batch-middle/create.sql Sets up event-driven DML to reproduce a batched replay scenario.
go/logic/applier_test.go Adds unit test asserting mid-batch warning causes rollback of entire batch.
go/logic/applier.go Implements per-statement warning detection for batched DML execution under PanicOnWarnings.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

@ggilder
Copy link
Contributor Author

ggilder commented Mar 10, 2026

@meiji163 important correction to earlier data loss fix — lmk if you have questions

- Print log excerpt on failure
- Upload full log artifacts on failure
@ggilder
Copy link
Contributor Author

ggilder commented Mar 11, 2026

Working on fixing test flake issues here — will update when I have a passing build on my fork

ggilder added 8 commits March 11, 2026 13:38
Removed the `wait.ForExposedPort()` override from test files. The tests
will now use the MySQL module's default wait strategy
(`wait.ForLog("port: 3306  MySQL Community Server")`), which properly
waits for MySQL to be ready to accept connections. Otherwise the port
may be exposed, but MySQL is still initializing and not ready to accept
connections.
Add support for test-specific execution so that we can guarantee that
we're specifically testing the DML apply phase
@ggilder ggilder force-pushed the fix-dml-batch-issue branch 2 times, most recently from 2b7f7d9 to 47a5977 Compare March 12, 2026 00:44
@ggilder
Copy link
Contributor Author

ggilder commented Mar 12, 2026

I have a passing build now: ggilder#4
I rebased this on top of the improve-tests branch #1642 because I needed to use the same strategy to test DML handling in integration tests. So, that one should be merged first and then I can rebase back onto master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants