vitessio/vitess · error

register a registered key:

Error message

register a registered key: 

What it means

tableacl.Register installs a named ACL factory in a global registry at init time. Registering the same factory name twice panics, because a duplicate would silently replace an existing implementation. The message embeds the offending key.

Source

Thrown at go/vt/tableacl/tableacl.go:290

}

// GetCurrentConfig returns a copy of current tableacl configuration.
func GetCurrentConfig() *tableaclpb.Config {
	return currentTableACL.Config()
}

func (tacl *tableACL) Config() *tableaclpb.Config {
	tacl.RLock()
	defer tacl.RUnlock()
	return tacl.config.CloneVT()
}

// Register registers an AclFactory.
func Register(name string, factory acl.Factory) {
	mu.Lock()
	defer mu.Unlock()
	if _, ok := acls[name]; ok {
		panic("register a registered key: " + name)
	}
	acls[name] = factory
}

// SetDefaultACL sets the default ACL implementation.
func SetDefaultACL(name string) {
	mu.Lock()
	defer mu.Unlock()
	defaultACL = name
}

// GetCurrentACLFactory returns current table acl implementation.
func GetCurrentACLFactory() (acl.Factory, error) {
	mu.Lock()
	defer mu.Unlock()
	if len(acls) == 0 {
		return nil, errors.New("no AclFactories registered")
	}

View on GitHub (pinned to 01a25a7d17)

Solutions

  1. Rename your factory to a unique string (e.g. prefix with your organization/feature name).
  2. Guard the registration with sync.Once or check tableacl's exported factory list before registering.
  3. In tests, register a distinct name per test file, or restructure so Register is only called from one init().

Example fix

// before
tableacl.Register("simpleacl", myFactory) // panics: built-in already registered
// after
tableacl.Register("myorg-simpleacl", myFactory)
Defensive patterns

Strategy: validation

Validate before calling

// Guard at init time.
var registerOnce sync.Once
func ensureRegistered(name string, f acl.Factory) {
  registerOnce.Do(func() { tableacl.Register(name, f) })
}

Try / catch

// Go panics are not recoverable errors here; validate instead.
// There is no exported registry lookup, so make the name unique:
// tableacl.Register("myorg-myfactory", f)

Prevention

When it happens

Trigger: Calling tableacl.Register(name, factory) with a name that is already registered — e.g. two init() functions in imported packages both register "simpleacl", or a custom ACL factory name collides with a built-in one.

Common situations: Importing two Vitess forks/plugins that each register the same ACL name; writing a test that calls Register for a name already registered by a package-level init; accidentally re-running Register in a helper instead of guarding with sync.Once.

Related errors


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