vitessio/vitess · error

can't access file ${myidFile}: ${statErr.Error()}

Error message

can't access file ${myidFile}: ${statErr.Error()}

What it means

Zkd.Inited() checks for the existence of the zookeeper myid file to determine if zookeeper has been initialized. It stats the myid file; if stat fails with anything other than ENOENT (file-not-found), it panics because it cannot safely determine initialization state. This is a defensive panic for unexpected filesystem errors like permission denial.

Source

Thrown at go/vt/zkctl/zkctl.go:254

	}
	var removalErr error
	for _, dir := range zkd.config.DirectoryList() {
		if err := os.RemoveAll(dir); err != nil {
			log.Error(fmt.Sprintf("failed removing %v: %v", dir, err.Error()))
			removalErr = err
		}
	}
	return removalErr
}

// Inited returns true if the server config has been initialized.
func (zkd *Zkd) Inited() bool {
	myidFile := zkd.config.MyidFile()
	_, statErr := os.Stat(myidFile)
	if statErr == nil {
		return true
	} else if statErr.(*os.PathError).Err != syscall.ENOENT {
		panic("can't access file " + myidFile + ": " + statErr.Error())
	}
	return false
}

View on GitHub (pinned to 01a25a7d17)

Solutions

  1. Fix permissions on the directory containing the myid file so the process user can stat it (chown/chmod).
  2. Check that the myid file path in the zk config is valid and not a broken symlink (ls -la the path).
  3. Verify the filesystem hosting the zookeeper data dir is mounted and healthy (df / mount output).
  4. If the panic is undesirable, patch Inited() to return false with a logged error instead of panicking on non-ENOENT stat errors.

Example fix

// before
} else if statErr.(*os.PathError).Err != syscall.ENOENT {
	panic("can't access file " + myidFile + ": " + statErr.Error())
}
// after
} else if statErr.(*os.PathError).Err != syscall.ENOENT {
	log.Warningf("can't access file %s: %v; treating as not inited", myidFile, statErr)
	return false
}
Defensive patterns

Strategy: validation

Validate before calling

myidFile := zkd.config.MyidFile()
if _, err := os.Stat(myidFile); err != nil {
	if pe, ok := err.(*os.PathError); ok && pe.Err == syscall.ENOENT {
		// not inited, safe to proceed with Init
	} else {
		// fix permissions/mount before calling Inited/Init
		log.Warningf("myid file inaccessible: %v", err)
	}
}

Type guard

func isENOENT(err error) bool {
	var pe *os.PathError
	return errors.As(err, &pe) && errors.Is(pe.Err, syscall.ENOENT)
}

Prevention

When it happens

Trigger: Calling zkd.Inited() (directly or via zkd.Init()) when os.Stat on the myid file path (zkd.config.MyidFile()) fails with an error other than syscall.ENOENT — e.g. EACCES on a directory the process cannot read, ELOOP on a symlink cycle, or the path being on a broken/unavailable mount.

Common situations: Zookeeper data directory owned by a different user than the vtctld/vtcombo process; myid file path pointing through a symlink loop; NFS mount down when zookeeper runs remotely; misconfigured ZK config dir after a container image change.

Related errors


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