{"record":{"id":"a51ccca21d43c5f1","repo":"hashicorp/nomad","slug":"error-streaming-previous-alloc-q-for-new-alloc-q","errorCode":null,"errorMessage":"error streaming previous alloc %q for new alloc %q: %w","messagePattern":"error streaming previous alloc %q for new alloc %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/allocwatcher/alloc_watcher.go","lineNumber":592,"sourceCode":"\t\t\treturn false\n\t\t}\n\t}\n\n\t// if we see this file, there was an error on the remote side\n\terrorFilename := allocdir.SnapshotErrorFilename(p.prevAllocID)\n\n\tbuf := make([]byte, 1024)\n\tfor !canceled() {\n\t\t// Get the next header\n\t\thdr, err := tr.Next()\n\n\t\t// Snapshot has ended\n\t\tif err == io.EOF {\n\t\t\treturn nil\n\t\t}\n\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"error streaming previous alloc %q for new alloc %q: %w\",\n\t\t\t\tp.prevAllocID, p.allocID, err)\n\t\t}\n\n\t\tif escapes, err := escapingfs.PathEscapesAllocDir(dest, \"\", hdr.Name); err != nil {\n\t\t\treturn fmt.Errorf(\"error evaluating object: %w\", err)\n\t\t} else if escapes {\n\t\t\treturn fmt.Errorf(\"archive contains object that escapes alloc dir\")\n\t\t}\n\n\t\tif hdr.Name == errorFilename {\n\t\t\t// Error snapshotting on the remote side, try to read\n\t\t\t// the message out of the file and return it.\n\t\t\terrBuf := make([]byte, int(hdr.Size))\n\t\t\tif _, err := tr.Read(errBuf); err != nil && err != io.EOF {\n\t\t\t\treturn fmt.Errorf(\"error streaming previous alloc %q for new alloc %q; failed reading error message: %w\",\n\t\t\t\t\tp.prevAllocID, p.allocID, err)\n\t\t\t}\n\t\t\treturn fmt.Errorf(\"error streaming previous alloc %q for new alloc %q: %s\",","sourceCodeStart":574,"sourceCodeEnd":610,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/client/allocwatcher/alloc_watcher.go#L574-L610","documentation":"streamAllocDir reads the tar snapshot of the previous allocation directory from the HTTP response body, extracting each entry. If the tar reader or body read returns a non-EOF error mid-stream, the error is wrapped as 'error streaming previous alloc %q for new alloc %q: %w'. This means the snapshot transfer broke partway through, not that it failed to start.","triggerScenarios":"During extraction loop, reading the next tar header or entry data returns an error other than io.EOF: the HTTP response body is truncated (connection reset mid-transfer), the remote node errors while reading the snapshot stream, gzip corruption, or a malformed/incomplete tar payload.","commonSituations":"Network interruption between nodes during a large allocation migration; previous node's agent crashes or is drained mid-stream; load balancer/proxy idle-timeout cutting a long-lived response; disk errors on the source node while snapshotting.","solutions":["Check network stability between the two client nodes (packet loss, conntrack/proxy timeouts); retry the allocation so migration restarts","Inspect the previous node's agent logs for snapshot-side errors during the transfer window","Avoid draining/restarting the source node while its allocations are migrating","Retry migration during lower network load or reduce alloc dir size (large task logs/data) to shorten the transfer"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"err := p.streamAllocDir(ctx, resp, allocDirPath)\nif err != nil && !errors.Is(err, io.EOF) {\n\tif strings.Contains(err.Error(), \"error streaming previous alloc\") {\n\t\t// transfer broke mid-stream: safe to retry migration from scratch\n\t}\n\treturn err\n}","preventionTips":["Keep alloc dirs small (rotate/limit task logs) so snapshot transfers finish quickly","Use stable, low-latency network links between client nodes; tune LB/proxy idle timeouts for long streams","Never drain or kill the source agent during an in-progress migration","Retry failed migrations — the operation is restartable since the prev alloc dir is rebuilt"],"tags":["network","tar-stream","allocation-migration"],"backgroundTag":"snapshot-stream-interrupted","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"}