dgraph-io/dgraph · error
while copying value
Error message
while copying value
What it means
During backup stream iteration, each badger item's value is copied into a freshly allocated KV. If item.Value's callback fails (badger read error, corrupted value log, I/O failure reading the value), the error is wrapped with this message, aborting the backup.
Source
Thrown at worker/backup.go:666
if item.IsDeletedOrExpired() {
continue
}
parsedKey, err := x.Parse(item.Key())
if err != nil {
glog.Errorf("error %v while parsing key %v during backup. Skipping...",
err, hex.EncodeToString(item.Key()))
continue
}
// This check makes sense only for the schema keys. The types are not stored in it.
if _, ok := predMap[parsedKey.Attr]; !parsedKey.IsType() && !ok {
continue
}
kv := y.NewKV(tl.alloc)
if err := item.Value(func(val []byte) error {
kv.Value = append(kv.Value, val...)
return nil
}); err != nil {
return errors.Wrapf(err, "while copying value")
}
backupKey, err := tl.toBackupKey(item.Key())
if err != nil {
return err
}
kv.Key = backupKey
kv.UserMeta = tl.alloc.Copy([]byte{item.UserMeta()})
kv.Version = item.Version()
kv.ExpiresAt = item.ExpiresAt()
list.Kv = append(list.Kv, kv)
}
return writeKVList(list, cWriter)
}
for _, prefix := range []byte{x.ByteSchema, x.ByteType} {
if err := writePrefix(prefix); err != nil {
glog.Errorf("While writing prefix %d to backup: %v", prefix, err)View on GitHub (pinned to 759e242be6)
Solutions
- Inspect the wrapped inner error to identify the failing badger item/key
- Run badger value-log recovery or restore from a known-good backup
- Check disk health and free space on the pstore mount
- If corruption is limited, drop-and-replay affected tablets, then re-run the backup
Defensive patterns
Strategy: try-catch
Validate before calling
// before backup, check pstore disk health and free space
if free, err := diskFree(pstoreDir); err != nil || free < minRequiredBytes {
return errors.New("insufficient disk space or unreadable pstore; aborting backup")
} Try / catch
resp, err := BackupGroup(ctx, req)
if err != nil && strings.Contains(err.Error(), "while copying value") {
glog.Errorf("badger value read failed during backup: %v", errors.Cause(err))
// run badger recovery / restore from good backup before retrying
} Prevention
- Monitor pstore disk health (SMART) and free space
- Run badger integrity checks after unclean shutdowns
- Avoid deleting/truncating DB files while a backup runs
- Keep regular verified backups so corruption can be recovered from
When it happens
Trigger: WriteBackup iterating a badger iterator hits an item whose value cannot be read — corrupted value log file, disk read error, or item truncated/expired mid-scan on the pstore.
Common situations: Badger value log corruption after a crash; disk failure or full disk on the pstore; backing up while the DB files are being deleted/truncated; running backup on a corrupted post-restore pstore.
Related errors
- could not read list part with key %s
- cannot unmarshal list part with key %s
- cannot export data inside DB at %s
- failed to read master manifest:
- while Getting latest manifest:
AI-assisted analysis of dgraph-io/dgraph@759e242be6 (2026-09-01).
Data as JSON: /api/errors/5f754c7b639a9104.
Report an issue: GitHub.