Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check interrupts even when download stalled #7793

Merged
merged 3 commits into from
Feb 28, 2023

Conversation

layus
Copy link
Member

@layus layus commented Feb 9, 2023

Motivation

Under bad network, downloads can stall forever. This leaves a running nix-daemon fork behind, even when the client disconnects. Even worse, that daemon keeps a lock in the path, preventing other attempts at downloading it.

/cc @thufschmitt

Context

Checklist for maintainers

Maintainers: tick if completed or explain if not relevant

  • agreed on idea
  • agreed on implementation strategy
  • tests, as appropriate
    • functional tests - tests/**.sh
    • unit tests - src/*/tests
    • integration tests - tests/nixos/*
  • documentation in the manual
  • code and comments are self-explanatory
  • commit message explains why the change was made
  • new feature or incompatible change: updated release notes

@edolstra
Copy link
Member

edolstra commented Feb 9, 2023

Looks good to me, but it seems to cause a test failure in fetchurl.sh ("coroutine has finished"). Another fix is to move the checkInterrupt() into the inner while loop, though the inner loop does seem superfluous.

@layus
Copy link
Member Author

layus commented Feb 9, 2023

Yes, I think it stops writing to the sink, and the sink ends up with a partial, incomplete download.
I wonder if there is a proper way to signal that the download failed, or if this is exactly what the FIXME was about.

@layus
Copy link
Member Author

layus commented Feb 9, 2023

Oh, right, the "coroutine has finished" is the error that happens when the sink ends abruptly.
So some code path fails to catch it, or I need a cleaner close.

@layus
Copy link
Member Author

layus commented Feb 9, 2023

This definitely deserves a squash before merge, but I like how the diff looks now. An unrolled while loop :-D.

@layus
Copy link
Member Author

layus commented Feb 10, 2023

I also do not want to checkInterrupt() while holding the lock. I understand that it throws, and the lock should be properly released, but... Well, I do not think it changes anything in the end.

@layus layus marked this pull request as ready for review February 10, 2023 14:26
@layus
Copy link
Member Author

layus commented Feb 10, 2023

I think this is ready for merge/review

@edolstra edolstra merged commit a4a5d82 into NixOS:master Feb 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants