weaviate/weaviate · error

writing chunks to file %q: %w

Error message

writing chunks to file %q: %w

What it means

eg.Wait() returned an error after all chunk-writer goroutines finished: at least one WriteAt failed inside the error group. This is the aggregate reporting point for per-chunk write failures (see error 3166 for the underlying write).

Source

Thrown at cluster/replication/copier/copier.go:377

						// Test-only: forces a deterministic WriteAt-after-Close window.
						if sleep := os.Getenv("WEAVIATE_TEST_DOWNLOAD_WRITE_SLEEP"); sleep != "" {
							if d, err := time.ParseDuration(sleep); err == nil {
								time.Sleep(d)
							}
						}
						if _, err := f.WriteAt(chunk.Data, chunk.Offset); err != nil {
							return fmt.Errorf("writing chunk to file %q: %w", tmpPath, err)
						}
						return nil
					})
				}
				if chunk.Eof {
					break
				}
			}

			if err = eg.Wait(); err != nil {
				return fmt.Errorf("writing chunks to file %q: %w", tmpPath, err)
			}

			err = f.Sync()
			if err != nil {
				return fmt.Errorf("fsyncing file %q for writing: %w", tmpPath, err)
			}

			err = f.Close()
			f = nil // prevent deferred close
			if err != nil {
				return fmt.Errorf("closing file: %w", err)
			}

			_, checksum, err = integrity.CRC32(tmpPath)
			if err != nil {
				return fmt.Errorf("calculating checksum for file %q: %w", tmpPath, err)
			}

View on GitHub (pinned to 75aa4b6d11)

Solutions

  1. Look at the wrapped error for the concrete errno; treat ENOSPC as a disk-space problem and EBADF/EIO as a storage problem.
  2. Free disk space or enlarge the data volume, then retry replication.
  3. If it recurs with no disk-pressure, check host storage health (dmesg, smartctl, cloud disk metrics).
  4. Retry the operation — partially written .tmp files are cleaned up automatically.
Defensive patterns

Strategy: retry

Validate before calling

// pre-flight: confirm volume can absorb the full snapshot
if freeBytes(dataPath) < snapshotTotalBytes*2 { return errors.New("not enough space for replication") }

Try / catch

if err := copySnapshot(ctx, op); err != nil {
    var pathErr *os.PathError
    if errors.As(err, &pathErr) && errors.Is(pathErr.Err, syscall.ENOSPC) {
        return retryAfterFreeingSpace(ctx, op)
    }
    return err
}

Prevention

When it happens

Trigger: Any writer goroutine's WriteAt returned non-nil (ENOSPC, EBADF, device I/O error); eg.Wait propagates that first error, wrapped as 'writing chunks to file'.

Common situations: Same as per-chunk write failures: disk exhaustion during transfer, storage device errors, transient fd problems under heavy parallelism.

Related errors


AI-assisted analysis of weaviate/weaviate@75aa4b6d11 (2026-09-04). Data as JSON: /api/errors/ff5b0ab1e0d36abc. Report an issue: GitHub.