Skip to content

checksum: honor yield timeout in distributed checker - #1022

Merged
morgo merged 1 commit into
block:mainfrom
aouxwoux:distributed-checksum-yield-timeout
Jun 30, 2026
Merged

morgo merged 1 commit into
block:mainfrom
aouxwoux:distributed-checksum-yield-timeout

Conversation

@aouxwoux

Copy link
Copy Markdown
Contributor

Closes #993.

Summary

  • pass CheckerConfig.YieldTimeout through to DistributedChecker
  • add distributed checksum yield/resume handling that mirrors SingleChecker
  • bound each distributed checksum pass with a yield context so source/target transaction pools are closed and recreated from the low watermark
  • add a regression test for the config path that previously dropped YieldTimeout

Tests

  • go test ./pkg/checksum -run '^TestDistributedCheckerHonorsYieldTimeoutConfig$' -count=1
  • go test ./pkg/checksum -run '^$' -count=1
  • go test ./... -run '^$' -count=1

I also tried go test ./pkg/checksum -run 'TestYieldTimeout|TestDistributedChecksum' -count=1, but this local machine has no MySQL service at 127.0.0.1:3306, so the existing integration tests fail immediately with connection refused before exercising the checksum logic.

@aouxwoux
aouxwoux force-pushed the distributed-checksum-yield-timeout branch from c96e6ff to cf0a50c Compare June 30, 2026 11:50
@morgo
morgo requested a review from Copilot June 30, 2026 12:10

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.

Pull request overview

This PR updates the checksum subsystem so CheckerConfig.YieldTimeout is honored by DistributedChecker (used by move / applier-backed checksums), enabling periodic yield/resume to release long-lived REPEATABLE READ snapshots and reduce InnoDB history list growth during long checksum passes.

Changes:

  • Plumbs CheckerConfig.YieldTimeout into DistributedChecker.
  • Adds yield-timeout bounding + yield/resume loop to distributed checksum passes (mirroring SingleChecker’s behavior).
  • Adds a regression test to ensure the config path no longer drops YieldTimeout.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
pkg/checksum/distributed.go Adds yield-timeout context bounding to distributed checksum passes and a yield/resume loop based on low-watermark.
pkg/checksum/distributed_test.go Adds a regression test verifying YieldTimeout is propagated into DistributedChecker.
pkg/checksum/checksum.go Passes YieldTimeout through when constructing a DistributedChecker.

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

Comment thread pkg/checksum/checksum.go Resolved
Comment on lines +64 to +84
func TestDistributedCheckerHonorsYieldTimeoutConfig(t *testing.T) {
db, err := sql.Open("mysql", testutils.DSN())
require.NoError(t, err)
defer utils.CloseAndLog(db)

config := NewCheckerDefaultConfig()
config.Applier = &noopDistributedApplier{}
config.YieldTimeout = 137 * time.Millisecond

checker, err := NewChecker(
[]*sql.DB{db},
table.NewMockChunker("yield_config", 1),
[]change.Source{&noopChangeSource{}},
config,
)
require.NoError(t, err)

distributedChecker, ok := checker.(*DistributedChecker)
require.True(t, ok)
require.Equal(t, config.YieldTimeout, distributedChecker.yieldTimeout)
}
@morgo
morgo merged commit a9bac7b into block:main Jun 30, 2026
13 checks passed
@morgo

morgo commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

Awesome, thank you!

morgo added a commit that referenced this pull request Jun 30, 2026
…lure

The yield/resume path (added for the distributed checker in #1022, and
pre-existing in the single checker) detected a yield with
`!chunker.IsRead()`. That misses the case where the yield timeout fires on
the *final* chunk: once all chunks are dispatched IsRead() is already true,
so the deadline-induced context error from the in-flight query (and, for the
single checker, the trx-pool rollback) was not recognized as a yield. It fell
through to the error path and surfaced as a spurious
"checksum failed: ... context deadline exceeded".

This is fatal for the DistributedChecker because its Run() returns on the
first runChecksumWithYield error. The SingleChecker happens to mask it via its
retry loop (Run() continues up to maxRetries), so it only wasted a retry — but
the detection was wrong in both. Fix both: also treat a deadline-induced
in-flight error (err1, or closeErr for the single checker) as a yield when the
yield context expired and the parent context is still healthy.

Add TestDistributedCheckerYieldTimeout, the distributed analog of
TestYieldTimeout: it drives real yield/resume cycles and asserts the run
passes and yieldsPerformed > 0. This exercises the resume path (which
TestDistributedCheckerHonorsYieldTimeoutConfig did not) and gives the
distributed yieldsPerformed counter a reader. Before this fix the new test
failed ~2/3 of runs; after it, 8/8.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
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.

checksum: DistributedChecker ignores CheckerConfig.YieldTimeout (move never yields long checksum transactions)

3 participants