juicedata/juicefs · error

database %s is used by volume %s

Error message

database %s is used by volume %s

What it means

Before importing a backup, `load` calls meta.NewClient(metaUri).Load(false) to probe the target metadata engine. If the probe succeeds (a volume format is found), the database already belongs to a volume, and load refuses with `database <uri> is used by volume <name>` to avoid overwriting existing metadata. The URI is shown with its password removed.

Source

Thrown at cmd/load.go:223

	}

	metaUri := ctx.Args().Get(0)
	removePassword(metaUri)
	var r io.ReadCloser
	if ctx.Args().Len() == 1 {
		r = os.Stdin
		src = "STDIN"
	} else {
		r, err = open(src, key, algo)
		if err != nil {
			return err
		}
		defer r.Close()
	}

	m := meta.NewClient(metaUri, nil)
	if format, err := m.Load(false); err == nil {
		return fmt.Errorf("database %s is used by volume %s", utils.RemovePassword(metaUri), format.Name)
	}

	if ctx.Bool("binary") {
		progress := utils.NewProgress(false)
		bars := make(map[string]*utils.Bar)
		for _, name := range meta.SegType2Name {
			bars[name] = progress.AddCountSpinner(name)
		}

		opt := &meta.LoadOption{
			Threads: ctx.Int("threads"),
			Progress: func(name string, cnt int) {
				bars[name].IncrBy(cnt)
			},
		}
		if err := m.LoadMetaV2(meta.WrapContext(ctx.Context), r, opt); err != nil {
			return err
		}

View on GitHub (pinned to c9a67b23e8)

Solutions

  1. Use a fresh/empty metadata URL (new SQLite file, unused Redis DB index) for the restore
  2. If the target data is disposable, wipe it first (delete the sqlite file, FLUSHDB the Redis DB) and re-run load
  3. Confirm you are not targeting the production volume's metadata URL — the volume name in the message tells you which one it is
  4. If the same volume legitimately needs re-import, drop the old metadata engine before loading

Example fix

// before
juicefs load redis://10.0.0.1/1 backup.json   # DB 1 already has volume 'myjfs'
// after
juicefs load redis://10.0.0.1/2 backup.json   # empty DB index
Defensive patterns

Strategy: validation

Validate before calling

out, err := exec.Command("juicefs", "status", metaUri).CombinedOutput()
if err == nil {
    return fmt.Errorf("meta engine already in use: %s", out)
}

Try / catch

if err := loadCmd.Run(); err != nil {
    if strings.Contains(err.Error(), "is used by volume") {
        log.Fatalf("choose a fresh metadata URL: %v", err)
    }
}

Prevention

When it happens

Trigger: Running `juicefs load <META-URL> <backup>` against a metadata URL that already contains a formatted JuiceFS volume, e.g. re-restoring into a non-empty Redis DB or an existing SQLite file instead of a fresh/empty one.

Common situations: Re-running load after a partial restore; pointing at the live volume's metadata URL by mistake; leftover SQLite test.db from earlier experiments; reusing a Redis DB index that another volume occupies.

Related errors


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