ipfs/kubo · warning
batch deleting stale key %s: %w
Error message
batch deleting stale key %s: %w
What it means
Raised by deleteStaleDHTValueRecords when batch.Delete(ctx, key) fails for a specific stale DHT value record key. The wrapped message includes the offending key, pinpointing which datastore entry could not be deleted. The purge stops; already-deleted keys are counted and the operation retries on the next daemon start.
Source
Thrown at core/node/storage.go:231
var count, pending int
for result := range results.Next() {
if ctx.Err() != nil {
return count, ctx.Err()
}
if result.Error != nil {
return count, fmt.Errorf("iterating datastore keys: %w", result.Error)
}
if !isStaleDHTValueRecordKey(result.Key) {
continue
}
if batch == nil {
batch, err = ds.Batch(ctx)
if err != nil {
return count, fmt.Errorf("creating delete batch: %w", err)
}
}
if err := batch.Delete(ctx, datastore.NewKey(result.Key)); err != nil {
return count, fmt.Errorf("batch deleting stale key %s: %w", result.Key, err)
}
count++
pending++
if pending >= purgeBatchSize {
if err := batch.Commit(ctx); err != nil {
return count, fmt.Errorf("committing delete batch: %w", err)
}
batch = nil
pending = 0
}
}
if pending > 0 {
if err := batch.Commit(ctx); err != nil {
return count, fmt.Errorf("committing delete batch: %w", err)
}
}
if count > 0 {
if err := ds.Sync(ctx, datastore.NewKey("/")); err != nil {View on GitHub (pinned to 329838acdf)
Solutions
- Free disk space / fix I/O problems indicated by the wrapped error
- Note the failing key from the log message and inspect datastore health around it
- Restart the daemon to resume the purge (it retries from scratch, skipping already-deleted keys)
- Ensure the node isn't shut down mid-migration
Defensive patterns
Strategy: retry
Validate before calling
// ensure disk has space before deletion-heavy migrations
if freeSpace(repoPath) < minFreeBytes {
return fmt.Errorf("insufficient space to run datastore purge")
} Try / catch
count, err := deleteStaleDHTValueRecords(ctx, ds)
if err != nil {
// error message includes the failing key: log it for triage
log.Warnw("stale DHT purge failed", "error", err)
} Prevention
- Keep free disk headroom
- Fix failing storage devices promptly
- Do not interrupt the daemon during the startup purge
When it happens
Trigger: During the purge, a batch Delete on a matched stale key fails — typically an underlying datastore write error (disk full, I/O error, key locked by backend constraints, context cancelled).
Common situations: Disk full on the node, failing storage device, badger write errors after crash recovery, or daemon shutdown cancelling the context mid-purge.
Related errors
- creating delete batch: %w
- committing delete batch: %w
- querying datastore for stale DHT value records: %w
- iterating datastore keys: %w
- The Experimental.AcceleratedDHTClient key has been moved to
AI-assisted analysis of ipfs/kubo@329838acdf (2026-09-03).
Data as JSON: /api/errors/e736077b39bd62d0.
Report an issue: GitHub.