vitessio/vitess · error

register a registered key:

Error message

register a registered key: 

What it means

RegisterControllerFactory registers a schema-manager controller factory under a name in a global map. Registering the same name twice would silently overwrite the existing factory, so it panics to surface the conflict.

Source

Thrown at go/vt/schemamanager/schemamanager.go:141

		return execResult, err
	}

	execResult = executor.Execute(ctx, sqls)

	if err := controller.OnExecutorComplete(ctx, execResult); err != nil {
		return execResult, err
	}
	if execResult.ExecutorErr != "" || len(execResult.FailedShards) > 0 {
		out, _ := json.MarshalIndent(execResult, "", "  ")
		return execResult, fmt.Errorf("schema change failed, ExecuteResult: %v", string(out))
	}
	return execResult, nil
}

// RegisterControllerFactory register a control factory.
func RegisterControllerFactory(name string, factory ControllerFactory) {
	if _, ok := controllerFactories[name]; ok {
		panic("register a registered key: " + name)
	}
	controllerFactories[name] = factory
}

// GetControllerFactory gets a ControllerFactory.
func GetControllerFactory(name string) (ControllerFactory, error) {
	factory, ok := controllerFactories[name]
	if !ok {
		return nil, fmt.Errorf("there is no data sourcer factory with name: %s", name)
	}
	return factory, nil
}

View on GitHub (pinned to 01a25a7d17)

Solutions

  1. Use a unique controller name for custom factories
  2. Remove the duplicate registration or the redundant import causing the second init() to run
  3. Register built-in names only once (they are already registered by the schemamanager package init)

Example fix

// before
RegisterControllerFactory("online", myFactory) // collides with built-in
// after
RegisterControllerFactory("mycompany-online", myFactory)
Defensive patterns

Strategy: validation

Validate before calling

var registered sync.Map
func registerFactoryOnce(name string, f ControllerFactory) { registered.LoadOrStore(name, f) } // dedupe before RegisterControllerFactory

Prevention

When it happens

Trigger: Calling schemamanager.RegisterControllerFactory twice with the same controller name — typically two init() functions in different packages both registering e.g. 'online' or a custom controller under an existing name.

Common situations: Importing two packages that each register a controller factory under the same name; a plugin/library registering a name that collides with vitess built-ins.

Related errors


AI-assisted analysis of vitessio/vitess@01a25a7d17 (2026-09-01). Data as JSON: /api/errors/114ba069e2c67477. Report an issue: GitHub.