ipfs/kubo · warning

creating delete batch: %w

Error message

creating delete batch: %w

What it means

Raised by deleteStaleDHTValueRecords when ds.Batch(ctx) fails while preparing the batch used to delete stale DHT value records. The datastore does not support or cannot currently create a batch. The purge aborts with keys-deleted-so-far returned and is retried on the next daemon start.

Source

Thrown at core/node/storage.go:227

	}
	defer results.Close()

	var batch datastore.Batch
	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)

View on GitHub (pinned to 329838acdf)

Solutions

  1. Check the wrapped error; ensure the configured datastore supports batching (all built-in kubo datastores do)
  2. Avoid shutting the daemon down during startup migration; let the purge finish
  3. Verify datastore health and restart the daemon — the purge retries on next start
  4. Check disk space/permissions on the repo directory
Defensive patterns

Strategy: retry

Validate before calling

if _, err := ds.Batch(ctx); err != nil {
    log.Warnf("datastore batching unavailable: %v", err)
}

Try / catch

count, err := deleteStaleDHTValueRecords(ctx, ds)
if err != nil && strings.Contains(err.Error(), "creating delete batch") {
    // check datastore health; purge retries next start
}

Prevention

When it happens

Trigger: First stale key is found and ds.Batch fails — datastore backend lacks batching support, is closing, or is in an error state (e.g. after corruption or during shutdown).

Common situations: Using a datastore wrapper that doesn't implement Batching, datastore shutdown racing the migration at daemon stop, or a corrupted/failing datastore.

Related errors


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