{"record":{"id":"690db8ddfbb07fa7","repo":"hashicorp/nomad","slug":"failed-to-compress-snapshot-file-v","errorCode":null,"errorMessage":"failed to compress snapshot file: %v","messagePattern":"failed to compress snapshot file: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"helper/snapshot/snapshot.go","lineNumber":129,"sourceCode":"\t\tif err := os.Remove(archive.Name()); err != nil {\n\t\t\tlogger.Error(\"Failed to clean up temp snapshot\", \"error\", err)\n\t\t}\n\t}()\n\n\thash := sha256.New()\n\tout := io.MultiWriter(hash, archive)\n\n\t// Wrap the file writer in a gzip compressor.\n\tcompressor := gzip.NewWriter(out)\n\n\t// Write the archive.\n\tif err := write(compressor, metadata, snap); err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to write snapshot file: %v\", err)\n\t}\n\n\t// Finish the compressed stream.\n\tif err := compressor.Close(); err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to compress snapshot file: %v\", err)\n\t}\n\n\t// Sync the compressed file and rewind it so it's ready to be streamed\n\t// out by the caller.\n\tif err := archive.Sync(); err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to sync snapshot: %v\", err)\n\t}\n\tif _, err := archive.Seek(0, 0); err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to rewind snapshot: %v\", err)\n\t}\n\n\tchecksum := \"sha-256=\" + base64.StdEncoding.EncodeToString(hash.Sum(nil))\n\n\tkeep = true\n\treturn &Snapshot{archive, metadata.Index, checksum}, nil\n}\n\n// Index returns the index of the snapshot. This is safe to call on a nil","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/helper/snapshot/snapshot.go#L111-L147","documentation":"After writing the archive data, writeSnapshot closes the gzip.Writer to flush the final compressed stream. If closing the compressor fails (which surfaces any pending gzip checksum/write errors buffered in the stream), the snapshot is abandoned with this error.","triggerScenarios":"New or NewFromFSM where compressor.Close() returns an error: typically an underlying write failure flushed during close (disk full, I/O error on the temp file), or the gzip stream already being in a bad state from an earlier write error.","commonSituations":"Disk ran out exactly at the point of flushing the gzip footer; the temp file's file descriptor hit an I/O error (e.g. ENOSPC, EIO) that only surfaces on the final flush/close.","solutions":["Check disk space — the most common cause is ENOSPC on the final flush of the compressed stream.","Read the wrapped %v cause to identify the underlying write error (gzip will report checksum or writer errors).","If gzip reports checksum/corruption errors, ensure the archive data written by write() wasn't modified concurrently.","Retry snapshot creation once storage is healthy; a later successful New/NewFromFSM call is safe."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"snap, err := snapshot.New(...)\nif err != nil && strings.Contains(err.Error(), \"failed to compress snapshot file\") {\n\tif isTransient(err) { time.Sleep(backoff); return retry() }\n\treturn err\n}","preventionTips":["Free disk space first — ENOSPC at final flush is the dominant cause.","Treat this as transient only after verifying storage health; don't blind-retry on EIO.","Run SMART/filesystem checks on nodes that repeat this error.","Avoid writing snapshot temp files to compressed or quota-limited filesystems."],"tags":["gzip","compression","io","snapshot"],"backgroundTag":"gzip-close-failed","analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}