Repository navigation
NAR: a failed withNarSource pull stays failed, as the codec sources' do - #105
Merged
Merged
Conversation
aoinoikaz
force-pushed
the
nar-stream-latch
branch
from
November 16, 2026 05:18
cfbea54 to
76d9b45
Compare
A pull that found a file shorter than the size it had read marked the source drained before it threw, so the next pull returned the empty chunk that marks a clean end, and a consumer that caught the failure and pulled again took a truncated archive for a complete one. Any other failure left the state where it was, so the next pull carried on from there. Any exception raised while a pull runs now latches as SourceFailed and is rethrown by every later pull, as NovaCache.Xz, NovaCache.Zstd and NovaCache.Bzip2 latch theirs. It is held at SomeException, as theirs are, because a pull interrupted after its read consumed bytes it never returned leaves the archive as torn as a failed one. The latch closes the file the state held, and only the pull itself runs unmasked, so no asynchronous exception can fall between a failure and its latch or leave the file open. One that arrives as a successful pull returns is not latched, since the state has already moved past the chunk it loses, so the documentation tells a consumer not to pull again after an asynchronous exception. The shrink path no longer closes the file or writes the state itself; the latch does both. One test cuts a file short after its size is read and checks the failing pull and the two after it; another fails a file's open, makes the file readable again and pulls once more. Both run on POSIX.
aoinoikaz
force-pushed
the
nar-stream-latch
branch
from
November 16, 2026 05:29
76d9b45 to
8353b2f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A NAR source stream that failed because a file shrank mid-read marked itself drained, so the next pull returned the empty chunk, the clean-end signal, and a consumer that caught the failure and pulled again took a truncated archive for a complete one. Any exception a pull lets escape is now latched and rethrown by every later pull, as the zstd, xz and bzip2 sources do, and the latch closes the stream's open handle. An exception raised while a pull runs is latched; an asynchronous exception delivered after a pull has returned can still escape unlatched, so a consumer must not resume a source after one. A pull after a failed open, which used to retry the file, rethrows the failure too, the same rule for every failure.
Closes #103.