{"record":{"id":"72167d579b78119f","repo":"juicedata/juicefs","slug":"create-s-s","errorCode":null,"errorMessage":"create %s: %s","messagePattern":"create (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/mdtest.go","lineNumber":71,"sourceCode":"\t}\n\tif d > 0 {\n\t\tfor i := 0; i < width; i++ {\n\t\t\tdn := path.Join(root, fmt.Sprintf(\"mdtest_tree.%d\", i))\n\t\t\tif err := createDir(jfs, dn, d-1, width); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc createFile(jfs *fs.FileSystem, bar *utils.Bar, np int, root string, d int, width, files, bytes int) error {\n\tm := jfs.Meta()\n\tfor i := 0; i < files; i++ {\n\t\tfn := path.Join(root, fmt.Sprintf(\"file.mdtest.%d.%d\", np, i))\n\t\tf, err := jfs.Create(ctx, fn, 0666, umask)\n\t\tif err != 0 {\n\t\t\treturn fmt.Errorf(\"create %s: %s\", fn, err)\n\t\t}\n\t\tif bytes > 0 {\n\t\t\tfor indx := 0; indx*meta.ChunkSize < bytes; indx++ {\n\t\t\t\tvar id uint64\n\t\t\t\tif st := m.NewSlice(ctx, &id); st != 0 {\n\t\t\t\t\treturn fmt.Errorf(\"writechunk %s: %s\", fn, st)\n\t\t\t\t}\n\t\t\t\tsize := meta.ChunkSize\n\t\t\t\tif bytes < (indx+1)*meta.ChunkSize {\n\t\t\t\t\tsize = bytes - indx*meta.ChunkSize\n\t\t\t\t}\n\t\t\t\tif st := m.Write(ctx, f.Inode(), uint32(indx), 0, meta.Slice{Id: id, Size: uint32(size), Len: uint32(size)}, time.Now()); st != 0 {\n\t\t\t\t\treturn fmt.Errorf(\"writeend %s: %s\", fn, st)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tf.Close(ctx)\n\t\tbar.Increment()","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/cmd/mdtest.go#L53-L89","documentation":"Wraps the syscall.Errno returned by jfs.Create() when the mdtest benchmark tries to create file.mdtest.<thread>.<i> inside a test directory. Any metadata-engine create failure (EACCES, ENOENT for a missing parent, ENOSPC/quota, or backend outage) surfaces as `create <path>: <errno>`. The parent directory is expected to exist from the earlier createDir phase, so failures are usually permission or backend errors.","triggerScenarios":"`juicefs mdtest` with -threads N where worker np creates files under a test dir that was deleted/moved concurrently; parent directory permissions reject the client's uid; metadata engine write failure (connection dropped, quota exceeded, ENOSPC on SQLite); running read-only against the volume.","commonSituations":"Concurrent mdtest runs sharing the same PATH so workers race on the same tree; volume root owned by another user; disk full on the metadata backend (e.g. SQLite file on a full disk); transient Redis connection loss under load.","solutions":["Re-run mdtest on a clean PATH so createDir has definitely created all parent dirs before createFile starts","Confirm the client's uid/gid has write permission on the test directories (check ctx uid setup vs volume root owner)","Verify the metadata backend is healthy and has space (`juicefs status`, backend logs); fix connectivity or free capacity","Avoid running two mdtest instances against the same META-URL/PATH simultaneously","If using --subdir, ensure it points to an existing writable directory"],"exampleFix":"// before\n$ juicefs mdtest --threads 8 redis://localhost /shared   # workers race, create fails\n// after\n$ juicefs mdtest --threads 8 redis://localhost /run1-$RANDOM","handlingStrategy":"try-catch","validationCode":"// ensure parent dirs were created and are writable before createFile phase\nif st := jfs.Stat(ctx, root); st != 0 {\n    return fmt.Errorf(\"test dir %s missing before file phase\", root)\n}","typeGuard":null,"tryCatchPattern":"// the error is returned up the stack; catch at the runTest boundary\nif err := createFile(jfs, bar, np, root, depth, width, files, bytes); err != nil {\n    if errors.Is(err, syscall.EACCES) || errors.Is(err, syscall.ENOSPC) {\n        logger.Errorf(\"Create: %s (check permissions/quota)\", err)\n        return\n    }\n    logger.Errorf(\"Create: %s\", err)\n}","preventionTips":["Never share one test PATH across concurrent mdtest invocations","Check volume quota and backend capacity before long runs","Keep the meta backend connection stable for the run duration","Use unique per-run roots (e.g. embed a timestamp) to avoid EEXIST/races"],"tags":["filesystem","create","metadata","mdtest"],"backgroundTag":"file-write-failed","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"}