Skip to content

test(migration): re-enable FixDifferences in TestCutoverAtomicityWithConcurrentWrites#824

Merged
morgo merged 1 commit into
block:mainfrom
morgo:fix-746-test-allow-fixdifferences
May 6, 2026
Merged

test(migration): re-enable FixDifferences in TestCutoverAtomicityWithConcurrentWrites#824
morgo merged 1 commit into
block:mainfrom
morgo:fix-746-test-allow-fixdifferences

Conversation

@morgo
Copy link
Copy Markdown
Collaborator

@morgo morgo commented May 6, 2026

Summary

In #746 we discovered that MySQL has a read-after-write violation where some changes are not immediately visible. This was proved in a reproduction script in #820 which requires no spirit code.

Spirit is now safe from this bug.

Why this it test was flaky

This test contained a different case of the same problem. There is a race where the repl client may ignore a row because it is above the high watermark knowing the copier will copy the up to date version when it gets to it. But the copier copies too soon after, and MySQL violates read-after-write.

The 'fix' for this is that we need to disable key above watermark before we start the checksum (which we already do) and fix any of the read-after-write races introduced during copying (which we already do in production, we just disabled for this test intentionally to catch algorithmic issues).

So the fix for this test is just to allow FixDifferences for this test.

To spell it out

  • KeyAboveWatermark is not safe without a checksum that fixes differences. While it is algorithmically correct, there is a MySQL read-after-write violation that breaks this (we no longer permit disabling the checksum, so this is OK).
  • We need to disable this optimization after the copier is complete, which we currently do.

…ConcurrentWrites

The `useTestCutover` hook had a side effect of disabling FixDifferences on
the checksum, so any copy-phase / applier-path row loss surfaced as a
"checksum mismatch" error before partial cutover ran. The intent was to
turn the test into a strict probe of issue block#746.

That stricter invariant is not what spirit actually offers in production:
the `KeyAboveHighWatermark` optimization in HasChanged silently drops
events whose key is above the chunker's high watermark, on the assumption
that the chunker's later `SELECT FROM original` will pick them up. The
binlog/visibility race documented in block#746 means that SELECT can miss
recently-committed rows under sufficient parallel-commit load on Linux
Docker. In production this is harmless because the checksum's repair pass
(FixDifferences=true, the default) re-copies any missed rows before
cutover. In the test it surfaced as the well-known flake on
composite_unbuffered (and intermittently the other variants).

This change decouples FixDifferences from useTestCutover so the test
runs the production checksum behaviour. useTestCutover still routes
cutover through `partialRenameForTest` so the _old/_new comparison
remains a real probe of the cutover protocol's atomicity guarantees.
The accompanying test docstring documents why we no longer probe
without FixDifferences and what we lose by that.

Further test-only fix for issue block#746
(block#746).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@morgo morgo merged commit 184f678 into block:main May 6, 2026
11 of 12 checks passed
@morgo morgo deleted the fix-746-test-allow-fixdifferences branch May 13, 2026 21:17
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