{"record":{"id":"9d684634633e705a","repo":"dgraph-io/dgraph","slug":"runrestore-failed-to-write-group-id-file","errorCode":null,"errorMessage":"RunRestore failed to write group id file","messagePattern":"RunRestore failed to write group id file","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"worker/online_restore.go","lineNumber":609,"sourceCode":"\t\t\tWithEncryptionKey(key).\n\t\t\tWithNamespaceOffset(x.NamespaceOffset))\n\t\tif err != nil {\n\t\t\treturn LoadResult{Err: errors.Wrap(err, \"RunRestore failed to open DB\")}\n\t\t}\n\t\tdefer db.Close()\n\n\t\tsw := db.NewStreamWriter()\n\t\tif err := sw.Prepare(); err != nil {\n\t\t\treturn LoadResult{Err: errors.Wrap(err, \"while preparing DB\")}\n\t\t}\n\t\tif err := RunReducer(sw, mapDir); err != nil {\n\t\t\treturn LoadResult{Err: errors.Wrap(err, \"RunRestore failed to reduce\")}\n\t\t}\n\t\tif err := sw.Flush(); err != nil {\n\t\t\treturn LoadResult{Err: errors.Wrap(err, \"while stream writer flush\")}\n\t\t}\n\t\tif err := x.WriteGroupIdFile(pdir, gid); err != nil {\n\t\t\treturn LoadResult{Err: errors.Wrap(err, \"RunRestore failed to write group id file\")}\n\t\t}\n\t}\n\t// TODO: Fix this return value.\n\treturn LoadResult{Version: manifest.ValidReadTs()}\n}\n\nfunc buildPredsForDefaultNamespace(restorePreds []string, fromNamespace uint64) []string {\n\tfiltered := restorePreds[:0]\n\tfor _, pred := range restorePreds {\n\t\tns, attr := x.ParseNamespaceAttr(pred)\n\t\tif fromNamespace == ns {\n\t\t\t// update namespace value to 0\n\t\t\tpred = x.NamespaceAttr(0, attr)\n\t\t\tfiltered = append(filtered, pred)\n\t\t}\n\t}\n\treturn filtered\n}","sourceCodeStart":591,"sourceCodeEnd":627,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/worker/online_restore.go#L591-L627","documentation":"After successfully flushing the restored DB into the post directory, offline restore writes a GROUP_ID file inside p<gid> identifying which group this posting directory belongs to. If x.WriteGroupIdFile fails (I/O error writing the file), the restore result is rejected because the Alpha would later fail to load the directory without the group marker.","triggerScenarios":"RunOfflineRestore reaches x.WriteGroupIdFile(pdir, gid) and the file write fails: read-only filesystem, no write permission on the post directory, disk full, or the directory was removed/moved mid-restore.","commonSituations":"Restoring into a directory owned by a different user than the dgraph process; running the restore in a container whose volume switched to read-only; filesystem quota exceeded.","solutions":["Check write permissions/ownership of the target postings directory for the process user (chown/chmod).","Verify the filesystem is not read-only or full.","Ensure the p<gid> directory still exists at the end of restore (no external cleanup jobs).","Retry the restore; if only the group file is missing from an otherwise complete restore, it can be created manually with the group id content before starting Alpha."],"exampleFix":"// before\n$ dgraph restore -p /data/postings  # permission denied writing p1/GROUP_ID\n// after\n$ sudo chown -R dgraph:dgraph /data/postings\n$ dgraph restore -p /data/postings","handlingStrategy":"validation","validationCode":"fi, err := os.Stat(dir)\nif err != nil {\n\treturn err\n}\nif err := syscall.Access(dir, syscall.O_RDWR); err != nil {\n\treturn fmt.Errorf(\"no write permission on %s\", dir)\n}","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"failed to write group id file\") {\n\t// fix permissions/ownership or free space, then re-run restore\n}","preventionTips":["Run restore as the same user that owns the postings directory","Avoid read-only or quota-limited volumes for postings","Keep external cleanup jobs from touching the post dir during restore","Chown the directory to the dgraph user before restoring"],"tags":["dgraph","restore","filesystem","permissions"],"backgroundTag":"permission-denied-write","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}