{"record":{"id":"6e5a7737a1ac98b9","repo":"vitessio/vitess","slug":"invalid-newmaxreplicationlagmoduleconfig-v","errorCode":null,"errorMessage":"invalid NewMaxReplicationLagModuleConfig: %v","messagePattern":"invalid NewMaxReplicationLagModuleConfig: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/throttler/max_replication_lag_module.go","lineNumber":130,"sourceCode":"\n\t// rateUpdateChan is the notification channel to tell the throttler when our\n\t// max rate calculation has changed. The field is immutable (set in Start().)\n\trateUpdateChan chan<- struct{}\n\n\t// lagRecords buffers the replication lag records received by the HealthCheck\n\t// subscriber. ProcessRecords() will process them.\n\tlagRecords chan replicationLagRecord\n\twg         sync.WaitGroup\n\n\t// results caches the results of the latest processed replication lag records.\n\tresults *resultRing\n}\n\n// NewMaxReplicationLagModule will create a new module instance and set the\n// initial max replication lag limit to maxReplicationLag.\nfunc NewMaxReplicationLagModule(config MaxReplicationLagModuleConfig, actualRatesHistory *aggregatedIntervalHistory, nowFunc func() time.Time) (*MaxReplicationLagModule, error) {\n\tif err := config.Verify(); err != nil {\n\t\treturn nil, fmt.Errorf(\"invalid NewMaxReplicationLagModuleConfig: %v\", err)\n\t}\n\trate := int64(ReplicationLagModuleDisabled)\n\tif config.MaxReplicationLagSec != ReplicationLagModuleDisabled {\n\t\trate = config.InitialRate\n\t}\n\n\tm := &MaxReplicationLagModule{\n\t\tinitialMaxReplicationLagSec: config.MaxReplicationLagSec,\n\t\t// Register \"config\" for a future config update.\n\t\tmutableConfig:      config,\n\t\tapplyMutableConfig: true,\n\t\tcurrentState:       stateIncreaseRate,\n\t\tlastRateChange:     nowFunc(),\n\t\tmemory:             newMemory(memoryGranularity, config.AgeBadRateAfter(), config.BadRateIncrease),\n\t\tlagRecords:         make(chan replicationLagRecord, 10),\n\t\t// Prevent an immediate increase of the initial rate.\n\t\tnextAllowedChangeAfterInit: nowFunc().Add(config.MaxDurationBetweenIncreases()),\n\t\tactualRatesHistory:         actualRatesHistory,","sourceCodeStart":112,"sourceCodeEnd":148,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/throttler/max_replication_lag_module.go#L112-L148","documentation":"NewMaxReplicationLagModule wraps any validation failure returned by MaxReplicationLagModuleConfig.Verify() with this message. It means the supplied throttler replication-lag config failed structural validation (bad limits, rates, or increase/decrease parameters). The module cannot be constructed until the config is fixed.","triggerScenarios":"Calling NewMaxReplicationLagModule (directly, or via newThrottlerFromConfig/newThrottler) with a MaxReplicationLagModuleConfig that fails Verify(): e.g. MaxReplicationLagSec < 2, TargetReplicationLagSec < 1, InitialRate < 1, MaxIncrease <= 0, or target > max lag.","commonSituations":"Hand-writing throttler configs in vtctld/vreplication (e.g. vstreamer throttler settings), YAML/JSON with zero-valued fields because only some fields were set, copy-pasted configs from older Vitess versions where limits differed.","solutions":["Read the wrapped %v error to see which specific field failed Verify().","Set max_replication_lag_sec >= 2 and target_replication_lag_sec >= 1 with target <= max.","Ensure initial_rate >= 1 and max-increase/max-decrease values are positive per config docs.","If replication-lag throttling is unwanted, set MaxReplicationLagSec to ReplicationLagModuleDisabled instead of an invalid value."],"exampleFix":"// before\nconfig := throttler.MaxReplicationLagModuleConfig{\n  MaxReplicationLagSec: 1, // invalid: must be >= 2\n  TargetReplicationLagSec: 1,\n  InitialRate: 1000000,\n}\n// after\nconfig := throttler.MaxReplicationLagModuleConfig{\n  MaxReplicationLagSec: 10,\n  TargetReplicationLagSec: 5,\n  InitialRate: 1000000,\n}","handlingStrategy":"validation","validationCode":"if err := config.Verify(); err != nil {\n    return fmt.Errorf(\"config rejected before construction: %w\", err)\n}\n_ = throttler.NewMaxReplicationLagModule(config, history, nowFunc)","typeGuard":null,"tryCatchPattern":"mod, err := throttler.NewMaxReplicationLagModule(config, history, nowFunc)\nif err != nil {\n    log.Warn(\"replication lag module disabled\", slog.Any(\"error\", err))\n    return nil // fall back to no lag throttling\n}","preventionTips":["Always call Verify() on MaxReplicationLagModuleConfig when loading from flags/files.","Encode constraint checks (target <= max, rates >= 1) in your config loader.","Test config parsing with the zero-value struct to catch unset fields."],"tags":["go","throttler","config-validation"],"backgroundTag":"throttler-config-invalid","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}