juicedata/juicefs · error

open lock file %s: %w

Error message

open lock file %s: %w

What it means

Reported by diskCache.createLockFile when the .lock file inside a cache directory cannot be opened. The error is recorded via checkErr; the cache dir typically gets rotated into a problematic state until the underlying permission or path issue is fixed.

Source

Thrown at pkg/chunk/disk_cache.go:195

		maxItems := "unlimited"
		if cache.maxItems != 0 {
			maxItems = strconv.FormatInt(cache.maxItems, 10)
		}
		logger.Infof("Adjusted max items based on freeratio: from %d to %s items", limit, maxItems)
	}
}

func (cache *diskCache) lockFilePath() string {
	return filepath.Join(cache.dir, ".lock")
}

func (cache *diskCache) createLockFile() {
	lockfile := cache.lockFilePath()
	err := cache.checkErr(func() error {
		f, err := os.OpenFile(lockfile, os.O_CREATE|os.O_RDWR, 0666)
		if err != nil {
			return fmt.Errorf("open lock file %s: %w", lockfile, err)
		}
		defer f.Close()
		rawId, err := io.ReadAll(f)
		if err != nil {
			return fmt.Errorf("read lock file %s: %w", lockfile, err)
		}
		if len(rawId) > 0 {
			cache.id = string(rawId)
		} else {
			cache.id = uuid.New().String()
			_, err = f.Write([]byte(cache.id))
			if err != nil {
				return fmt.Errorf("write lock file %s: %w", lockfile, err)
			}
		}
		return nil
	})
	if err != nil {

View on GitHub (pinned to c9a67b23e8)

Solutions

  1. Check ownership and write permissions of the cache directory
  2. Remove a stale/corrupt .lock file if present so it can be recreated
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at pkg/chunk/disk_cache.go:195 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of juicedata/juicefs@c9a67b23e8 (2026-09-06). Data as JSON: /api/errors/aee1dd1709fcd8d3. Report an issue: GitHub.