{"record":{"id":"7d2ca7980bd80152","repo":"juicedata/juicefs","slug":"database-s-s-is-not-empty","errorCode":null,"errorMessage":"Database %s://%s is not empty","messagePattern":"Database (.+?)://(.+?) is not empty","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/meta/tkv.go","lineNumber":4326,"sourceCode":"\t\tkv <- &pair{m.xattrKey(inode, x.Name), []byte(unescape(x.Value))}\n\t}\n\n\tattr.AccessACL = m.saveACL(loadACL(e.AccessACL), aclMaxId)\n\tattr.DefaultACL = m.saveACL(loadACL(e.DefaultACL), aclMaxId)\n\tkv <- &pair{m.inodeKey(inode), m.marshal(attr)}\n}\n\nfunc (m *kvMeta) LoadMeta(r io.Reader) error {\n\tvar exist bool\n\terr := m.txn(Background(), func(tx *kvTxn) error {\n\t\texist = tx.exist(m.fmtKey())\n\t\treturn nil\n\t})\n\tif err != nil {\n\t\treturn err\n\t}\n\tif exist {\n\t\treturn fmt.Errorf(\"Database %s://%s is not empty\", m.Name(), m.addr)\n\t}\n\n\tkv := make(chan *pair, 10000)\n\tbatch := 10000\n\tif m.Name() == \"etcd\" {\n\t\tbatch = 128\n\t}\n\tvar wg sync.WaitGroup\n\tfor i := 0; i < 10; i++ {\n\t\twg.Add(1)\n\t\tgo func() {\n\t\t\tdefer wg.Done()\n\t\t\tvar buffer []*pair\n\t\t\tvar total int\n\t\t\tfor p := range kv {\n\t\t\t\tbuffer = append(buffer, p)\n\t\t\t\ttotal += len(p.key) + len(p.value)\n\t\t\t\tif len(buffer) >= batch || total > 5<<20 {","sourceCodeStart":4308,"sourceCodeEnd":4344,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/pkg/meta/tkv.go#L4308-L4344","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Point load at a fresh, empty database (create a new sqlite3 file / new Redis DB index / new TiKV namespace)","Clear the existing keys in the target store before retrying the load","If you truly want to overwrite, back up then purge the target DB's JuiceFS key space first","Check the metadata URL for typos (wrong DB number, path, or prefix) that hit an existing database"],"exampleFix":"// before (loads into existing DB)\njuicefs load redis://127.0.0.1:6379/0 dump.json\n// after (load into a fresh DB)\njuicefs load redis://127.0.0.1:6379/1 dump.json","handlingStrategy":"validation","validationCode":"// before load, ensure target DB is empty\njuicefs status <meta-url> 2>/dev/null && echo \"DB not empty - choose a fresh DB\" || echo \"OK to load\"","typeGuard":null,"tryCatchPattern":"if err := loadMeta(dst, dumpFile); err != nil {\n\tif strings.Contains(err.Error(), \"is not empty\") {\n\t\t// switch to a fresh database URL or purge the target\n\t}\n}","preventionTips":["Always load into a newly created, empty metadata database","Double-check the metadata URL (DB index, path, prefix) before load","Never point load at a live volume's metadata engine","After a failed/partial load, clear the store before retrying"],"tags":["load","metadata","non-empty","kv-store"],"backgroundTag":"file-already-exists","analyzedSha":"c9a67b23e8e08ec23ec331aa6f1675e2319e921c","analyzedAt":"2026-09-06T17:55:48.476Z","contentChangedAt":"2026-09-06T17:55:48.476Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}