{"record":{"id":"ff5b0ab1e0d36abc","repo":"weaviate/weaviate","slug":"writing-chunks-to-file-q-w","errorCode":null,"errorMessage":"writing chunks to file %q: %w","messagePattern":"writing chunks to file %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cluster/replication/copier/copier.go","lineNumber":377,"sourceCode":"\t\t\t\t\t\t// Test-only: forces a deterministic WriteAt-after-Close window.\n\t\t\t\t\t\tif sleep := os.Getenv(\"WEAVIATE_TEST_DOWNLOAD_WRITE_SLEEP\"); sleep != \"\" {\n\t\t\t\t\t\t\tif d, err := time.ParseDuration(sleep); err == nil {\n\t\t\t\t\t\t\t\ttime.Sleep(d)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif _, err := f.WriteAt(chunk.Data, chunk.Offset); err != nil {\n\t\t\t\t\t\t\treturn fmt.Errorf(\"writing chunk to file %q: %w\", tmpPath, err)\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn nil\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t\tif chunk.Eof {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif err = eg.Wait(); err != nil {\n\t\t\t\treturn fmt.Errorf(\"writing chunks to file %q: %w\", tmpPath, err)\n\t\t\t}\n\n\t\t\terr = f.Sync()\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"fsyncing file %q for writing: %w\", tmpPath, err)\n\t\t\t}\n\n\t\t\terr = f.Close()\n\t\t\tf = nil // prevent deferred close\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"closing file: %w\", err)\n\t\t\t}\n\n\t\t\t_, checksum, err = integrity.CRC32(tmpPath)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"calculating checksum for file %q: %w\", tmpPath, err)\n\t\t\t}\n","sourceCodeStart":359,"sourceCodeEnd":395,"githubUrl":"https://github.com/weaviate/weaviate/blob/75aa4b6d11f8818305aafd4440b4e32794f7ca04/cluster/replication/copier/copier.go#L359-L395","documentation":"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).","triggerScenarios":"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'.","commonSituations":"Same as per-chunk write failures: disk exhaustion during transfer, storage device errors, transient fd problems under heavy parallelism.","solutions":["Look at the wrapped error for the concrete errno; treat ENOSPC as a disk-space problem and EBADF/EIO as a storage problem.","Free disk space or enlarge the data volume, then retry replication.","If it recurs with no disk-pressure, check host storage health (dmesg, smartctl, cloud disk metrics).","Retry the operation — partially written .tmp files are cleaned up automatically."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// pre-flight: confirm volume can absorb the full snapshot\nif freeBytes(dataPath) < snapshotTotalBytes*2 { return errors.New(\"not enough space for replication\") }","typeGuard":null,"tryCatchPattern":"if err := copySnapshot(ctx, op); err != nil {\n    var pathErr *os.PathError\n    if errors.As(err, &pathErr) && errors.Is(pathErr.Err, syscall.ENOSPC) {\n        return retryAfterFreeingSpace(ctx, op)\n    }\n    return err\n}","preventionTips":["Plan capacity: replication transiently needs extra space for .tmp copies.","Investigate the first per-chunk write error in the wrapped chain, not just the aggregate.","Set disk alerts well before full so replication never races into ENOSPC.","Retry replication after cleanup — it is resumable by design via CRC32 skip."],"tags":["filesystem","concurrency","replication","disk"],"backgroundTag":"disk-full-enospc","analyzedSha":"75aa4b6d11f8818305aafd4440b4e32794f7ca04","analyzedAt":"2026-09-04T14:58:20.392Z","contentChangedAt":"2026-09-04T14:58:20.392Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}