ipfs/kubo · warning

committing delete batch: %w

Error message

committing delete batch: %w

What it means

Raised by deleteStaleDHTValueRecords when batch.Commit(ctx) fails after accumulating purgeBatchSize deletes (or the trailing partial batch). The deletes are not durably applied; the count of attempted deletions is returned and the whole purge is retried on the next daemon start. purgeStaleDHTValueRecords logs it as a warning, not a fatal error.

Source

Thrown at core/node/storage.go:237

			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 {
			return count, fmt.Errorf("syncing deletes: %w", err)
		}
	}
	return count, nil
}

View on GitHub (pinned to 329838acdf)

Solutions

  1. Check disk space and I/O health; the wrapped error names the datastore cause
  2. Restart the daemon and let the migration complete uninterrupted
  3. If a backend rejects large transactions, the periodic batching in this code already limits size — verify no custom datastore wrapper interferes
  4. Restore from backup if the datastore is consistently failing to commit
Defensive patterns

Strategy: retry

Validate before calling

// preflight: confirm the datastore can commit a trivial batch
b, err := ds.Batch(ctx)
if err == nil {
    _ = b.Put(ctx, datastore.NewKey("/health/probe"), []byte{1})
    err = b.Commit(ctx)
}
if err != nil {
    log.Warnf("datastore commits failing: %v", err)
}

Try / catch

count, err := deleteStaleDHTValueRecords(ctx, ds)
if err != nil && strings.Contains(err.Error(), "committing delete batch") {
    log.Warnw("batch commit failed, purge will retry next start", "deletedSoFar", count)
}

Prevention

When it happens

Trigger: Every purgeBatchSize (batch-sized) commits of stale-key deletions fail — datastore commit/write error: disk full, I/O failure, transaction size limits in the backend, or context cancellation.

Common situations: Disk exhaustion on busy nodes, badger transaction too large / write stalls, levelds I/O errors, or the operator stopping the daemon during startup migration.

Related errors


AI-assisted analysis of ipfs/kubo@329838acdf (2026-09-03). Data as JSON: /api/errors/9681cc61a64ab8bc. Report an issue: GitHub.