{"record":{"id":"fee3fe002372919e","repo":"SigNoz/signoz","slug":"errcodeinvalidsqlmigratorconfig","errorCode":"ErrCodeInvalidSQLMigratorConfig","errorMessage":"lock::timeout must be greater than lock::interval","messagePattern":"lock::timeout must be greater than lock::interval","errorType":"error_code","errorClass":null,"httpStatus":400,"severity":"error","filePath":"pkg/sqlmigrator/config.go","lineNumber":43,"sourceCode":"\tInterval time.Duration `mapstructure:\"interval\"`\n}\n\nfunc NewConfigFactory() factory.ConfigFactory {\n\treturn factory.NewConfigFactory(factory.MustNewName(\"sqlmigrator\"), newConfig)\n}\n\nfunc newConfig() factory.Config {\n\treturn Config{\n\t\tLock: Lock{\n\t\t\tTimeout:  2 * time.Minute,\n\t\t\tInterval: 10 * time.Second,\n\t\t},\n\t}\n}\n\nfunc (c Config) Validate() error {\n\tif c.Lock.Timeout <= c.Lock.Interval {\n\t\treturn errors.New(errors.TypeInvalidInput, ErrCodeInvalidSQLMigratorConfig, \"lock::timeout must be greater than lock::interval\")\n\t}\n\n\treturn nil\n}\n","sourceCodeStart":25,"sourceCodeEnd":48,"githubUrl":"https://github.com/SigNoz/signoz/blob/5069bf80b08f1f00d7e014eccc09902f9871004f/pkg/sqlmigrator/config.go#L25-L48","documentation":"sqlmigrator's Config.Validate enforces that the migration advisory lock timeout is strictly greater than the lock polling interval. If timeout <= interval, migrations would effectively get at most one (or zero) retry attempts, so the config is rejected as invalid.","triggerScenarios":"Building a sqlmigrator with Lock.Timeout <= Lock.Interval, e.g. timeout=10s and interval=10s, or interval unset/zero combined with timeout zero.","commonSituations":"Copying defaults from another project, setting interval in milliseconds while timeout in seconds, or zero-valuing both fields which fails the <= check.","solutions":["Set Lock.Timeout strictly greater than Lock.Interval (e.g. interval=5s, timeout=1m)","Call Config.Validate() at startup or in tests to catch misconfiguration early","Double-check unit consistency of both fields (both are time.Duration)"],"exampleFix":"// before\ncfg := sqlmigrator.Config{Lock: sqlmigrator.LockConfig{Timeout: 10 * time.Second, Interval: 10 * time.Second}}\n\n// after\ncfg := sqlmigrator.Config{Lock: sqlmigrator.LockConfig{Timeout: 1 * time.Minute, Interval: 5 * time.Second}}","handlingStrategy":"validation","validationCode":"if err := cfg.Validate(); err != nil {\n    log.Fatal(err)\n}","typeGuard":null,"tryCatchPattern":"if err := cfg.Validate(); err != nil {\n    return fmt.Errorf(\"invalid migrator config: %w\", err)\n}","preventionTips":["Call Validate() in unit tests for every config construction site","Centralize lock defaults in one constructor so timeout/interval stay consistent"],"tags":["go","sql-migrator","config-validation","locking"],"backgroundTag":"config-validation-failed","analyzedSha":"5069bf80b08f1f00d7e014eccc09902f9871004f","analyzedAt":"2026-08-28T06:22:12.824Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}