juicedata/juicefs · error

database %s is not empty

Error message

database %s is not empty

What it means

LoadMeta's safety check (checkAddr) found existing tables in the target database via DBMetas(). Loading metadata into a non-empty database is rejected to prevent mixing schemas or overwriting existing state; the addr is normalized with a scheme prefix for a clear diagnostic.

Source

Thrown at pkg/meta/sql.go:5232

		return 65535 / MaxFieldsCountOfTable
	case "postgres":
		return 1000
	default:
		return 1000
	}
}

func (m *dbMeta) checkAddr() error {
	tables, err := m.db.DBMetas()
	if err != nil {
		return err
	}
	if len(tables) > 0 {
		addr := m.addr
		if !strings.Contains(addr, "://") {
			addr = fmt.Sprintf("%s://%s", m.Name(), addr)
		}
		return fmt.Errorf("database %s is not empty", addr)
	}
	return nil
}

func (m *dbMeta) LoadMeta(r io.Reader) error {
	if err := m.checkAddr(); err != nil {
		return err
	}
	if err := m.syncAllTables(); err != nil {
		return err
	}

	batch := m.getTxnBatchNum()
	chs := make([]chan interface{}, 6) // node, edge, chunk, chunkRef, xattr, others
	insert := func(index int, beans []interface{}) error {
		return m.txn(func(s *xorm.Session) error {
			var n int64
			var err error

View on GitHub (pinned to c9a67b23e8)

Solutions

  1. Load into a brand-new/empty database
  2. Drop existing tables (or use a different DB) if overwriting is intended
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at pkg/meta/sql.go:5232 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/2f483d490c275a28. Report an issue: GitHub.