Documentation
¶
Overview ¶
Package checksum provides online checksum functionality. Two tables on the same MySQL server can be compared with only an initial lock. It is not in the row/ package because it requires a replClient to be passed in, which would cause a circular dependency.
Package checksum provides online checksum functionality. Two tables on the same MySQL server can be compared with only an initial lock. It is not in the row/ package because it requires a replClient to be passed in, which would cause a circular dependency.
Index ¶
- Variables
- type Checker
- type CheckerConfig
- type DistributedChecker
- func (c *DistributedChecker) ChecksumChunk(ctx context.Context, chunk *table.Chunk) error
- func (c *DistributedChecker) DifferencesFound() uint64
- func (c *DistributedChecker) ExecTime() time.Duration
- func (c *DistributedChecker) GetProgress() string
- func (c *DistributedChecker) Run(ctx context.Context) error
- func (c *DistributedChecker) StartTime() time.Time
- type SingleChecker
- func (c *SingleChecker) ChecksumChunk(ctx context.Context, trxPool *dbconn.TrxPool, chunk *table.Chunk) error
- func (c *SingleChecker) DifferencesFound() uint64
- func (c *SingleChecker) ExecTime() time.Duration
- func (c *SingleChecker) GetProgress() string
- func (c *SingleChecker) Run(ctx context.Context) error
- func (c *SingleChecker) StartTime() time.Time
Constants ¶
This section is empty.
Variables ¶
var ( // ErrYieldTimeout is returned by runChecksum when the yield timeout expires. // This is distinct from the parent context being canceled, and signals that // the checksum should resume from the current watermark after releasing // long-running transactions to reduce HLL (history list length) growth. ErrYieldTimeout = errors.New("checksum yield timeout") // DefaultYieldTimeout is the default maximum duration for a single checksum // pass before yielding to release long-running REPEATABLE READ transactions. DefaultYieldTimeout = 24 * time.Hour )
Functions ¶
This section is empty.
Types ¶
type Checker ¶
type Checker interface {
// Run performs the checksum operation.
Run(ctx context.Context) error
GetProgress() string
StartTime() time.Time
ExecTime() time.Duration
// DifferencesFound returns the number of chunks where a source/target
// mismatch was detected during the most recent (or in-flight) pass.
// Useful for callers that need to distinguish "clean cancellation" from
// "cancellation while a fix may have been mid-flight" — the continuous-
// checksum loop uses it to decide whether a sentinel-drop swallow is
// safe.
DifferencesFound() uint64
}
func NewChecker ¶
func NewChecker(sourceDBs []*sql.DB, chunker table.Chunker, feeds []*repl.Client, config *CheckerConfig) (Checker, error)
NewChecker creates a new checksum object. sourceDBs contains the source database connections (one for single-source migrations, multiple for N:M moves). The distributed checker aggregates checksums across all sources. The single checker uses sourceDBs[0].
type CheckerConfig ¶
type CheckerConfig struct {
Concurrency int
TargetChunkTime time.Duration
DBConfig *dbconn.DBConfig
Logger *slog.Logger
FixDifferences bool
Watermark string // optional; defines a watermark to start from
MaxRetries int
Applier applier.Applier // optional; indicates it is a distributed checker
YieldTimeout time.Duration // maximum duration for a single checksum pass before yielding to release long-running transactions
}
func NewCheckerDefaultConfig ¶
func NewCheckerDefaultConfig() *CheckerConfig
type DistributedChecker ¶ added in v0.10.1
func (*DistributedChecker) ChecksumChunk ¶ added in v0.10.1
func (*DistributedChecker) DifferencesFound ¶ added in v0.14.0
func (c *DistributedChecker) DifferencesFound() uint64
DifferencesFound returns the number of chunks where a source/target mismatch was detected in the most recent (or in-flight) pass. Used by the continuous-checksum loop to decide whether a cancellation swallow is safe.
func (*DistributedChecker) ExecTime ¶ added in v0.10.1
func (c *DistributedChecker) ExecTime() time.Duration
func (*DistributedChecker) GetProgress ¶ added in v0.10.1
func (c *DistributedChecker) GetProgress() string
GetProgress returns the progress of the checker this is really just a proxy to the chunker progress.
func (*DistributedChecker) Run ¶ added in v0.10.1
func (c *DistributedChecker) Run(ctx context.Context) error
func (*DistributedChecker) StartTime ¶ added in v0.10.1
func (c *DistributedChecker) StartTime() time.Time
type SingleChecker ¶ added in v0.10.1
func (*SingleChecker) ChecksumChunk ¶ added in v0.10.1
func (*SingleChecker) DifferencesFound ¶ added in v0.14.0
func (c *SingleChecker) DifferencesFound() uint64
DifferencesFound returns the number of chunks where a source/target mismatch was detected in the most recent (or in-flight) pass. Used by the continuous-checksum loop to decide whether a cancellation swallow is safe.
func (*SingleChecker) ExecTime ¶ added in v0.10.1
func (c *SingleChecker) ExecTime() time.Duration
func (*SingleChecker) GetProgress ¶ added in v0.10.1
func (c *SingleChecker) GetProgress() string
GetProgress returns the progress of the checker this is really just a proxy to the chunker progress.
func (*SingleChecker) StartTime ¶ added in v0.10.1
func (c *SingleChecker) StartTime() time.Time