juicedata/juicefs · error

Database %s://%s is not empty

Error message

Database %s://%s is not empty

What it means

juicefs load (LoadMeta) refuses to import a metadata dump into a TKV database that already contains data ('exist' was detected during a scan of the first key). Loading into a non-empty store would merge/conflict with existing records, so it fails fast.

Source

Thrown at pkg/meta/tkv.go:4326

		kv <- &pair{m.xattrKey(inode, x.Name), []byte(unescape(x.Value))}
	}

	attr.AccessACL = m.saveACL(loadACL(e.AccessACL), aclMaxId)
	attr.DefaultACL = m.saveACL(loadACL(e.DefaultACL), aclMaxId)
	kv <- &pair{m.inodeKey(inode), m.marshal(attr)}
}

func (m *kvMeta) LoadMeta(r io.Reader) error {
	var exist bool
	err := m.txn(Background(), func(tx *kvTxn) error {
		exist = tx.exist(m.fmtKey())
		return nil
	})
	if err != nil {
		return err
	}
	if exist {
		return fmt.Errorf("Database %s://%s is not empty", m.Name(), m.addr)
	}

	kv := make(chan *pair, 10000)
	batch := 10000
	if m.Name() == "etcd" {
		batch = 128
	}
	var wg sync.WaitGroup
	for i := 0; i < 10; i++ {
		wg.Add(1)
		go func() {
			defer wg.Done()
			var buffer []*pair
			var total int
			for p := range kv {
				buffer = append(buffer, p)
				total += len(p.key) + len(p.value)
				if len(buffer) >= batch || total > 5<<20 {

View on GitHub (pinned to c9a67b23e8)

Solutions

  1. Point load at a fresh, empty database (create a new sqlite3 file / new Redis DB index / new TiKV namespace)
  2. Clear the existing keys in the target store before retrying the load
  3. If you truly want to overwrite, back up then purge the target DB's JuiceFS key space first
  4. Check the metadata URL for typos (wrong DB number, path, or prefix) that hit an existing database

Example fix

// before (loads into existing DB)
juicefs load redis://127.0.0.1:6379/0 dump.json
// after (load into a fresh DB)
juicefs load redis://127.0.0.1:6379/1 dump.json
Defensive patterns

Strategy: validation

Validate before calling

// before load, ensure target DB is empty
juicefs status <meta-url> 2>/dev/null && echo "DB not empty - choose a fresh DB" || echo "OK to load"

Try / catch

if err := loadMeta(dst, dumpFile); err != nil {
	if strings.Contains(err.Error(), "is not empty") {
		// switch to a fresh database URL or purge the target
	}
}

Prevention

When it happens

Trigger: Running 'juicefs load' against a metadata URL that already has keys — loading into a live volume's database, or re-running load after a previous partial load.

Common situations: Accidentally pointing load at the production metadata engine instead of a fresh/empty database; retrying a failed load without clearing the store; DB reused from another volume.

Understand the failure class

Background: "already exists" / EEXIST / FileAlreadyExistsException: what the 'file already exists' error means and how to fix it — this error's family across 37 libraries.

Related errors


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