[Cherry 5.1.x]: Fix mender-update hanging when long-term network issues happen during Artifact download #1996
Merged
vpodzime merged 8 commits intoJul 24, 2026
Conversation
…erAsyncReader The last_read_ struct records information about the last call of AsyncRead() which is a DownloadResumerAsyncReader's function. It makes more sense to record this information inside that class then. The strange `friend` declaration allowing a DownloadResumerAsyncReader instance contained inside DownloadResumerClient to access DownloadResumerClient's private members can now be dropped and the hierarchy makes more sense. Ticket: MEN-9954 Changelog: None Signed-off-by: Vratislav Podzimek <vratislav.podzimek+auto-signed@northern.tech> (cherry picked from commit f493b88)
…stream When there are network issues during Artifact download and the HTTP download resumer exhausts its retry backoff, the only way to deliver the error to the state machine is through the HTTP **body reader's** handler because the **body handler** passed to the DownloadResumerClient is only called when all body data is fetched which normally happens in a completely different state than the one that starts the download and thus the UpdateDownloadState doesn't handle any errors in it. Add a Fail() function to the body reader and use it to make sure it calls its handler with the respective error. Also add a comment about how the DownloadResumerClient is used. Ticket: MEN-9954 Changelog: Fixed mender-update hanging indefinitely (never reporting a deployment failure and never returning to the poll loop) when a network outage during artifact download lasted long enough for the download resumer to give up on resuming. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Vratislav Podzimek <vratislav.podzimek+auto-signed@northern.tech> (cherry picked from commit a9263bd)
Unlike the basic http::Client which constructs the reader and returns it, leaving the API user code to manage the reader's lifetime, the DownloadResumerClient needs to keep a reference (shared pointer) to the reader too and thus manage its lifetime. The reason for this is that while the http::Client's reader (and its lifetime) is bound to a socket that gets closed on an error or completion, only the DownloadResumerClient itself knows when the body reader (providing data from multiple HTTP requests/responses) won't produce more data, i.e. when no more (re)tries will be performed. Tests that were exercising the reader ownership by the API user code were adjusted to test cancellation of the reader instead. Ticket: MEN-9954 Changelog: None Signed-off-by: Vratislav Podzimek <vratislav.podzimek+auto-signed@northern.tech> (cherry picked from commit c722497)
…omAsyncReader::Read() The handler passed to the asynchronous reader can be called with a different stack (frame) than that of the ReaderFromAsyncReader::Read() function and then those references (pointers) lead to random unrelated places. We need to use shared pointers to make sure the referenced data is valid independently on the stack. Ticket: MEN-9954 Changelog: None Signed-off-by: Vratislav Podzimek <vratislav.podzimek+auto-signed@northern.tech> (cherry picked from commit 877de62)
…:Read() The handler passed to the asynchronous reader can be called multiple times after adding a call to `AsyncRead()` to the event loop, not only once when there is data available, but also if the asynchronous reader encounters an error. Since the event loop is only run recursively **once** per ReaderFromAsyncReader::Read() call, we need to make sure it's also stopped only once. Otherwise it may stop the event loop for good. Ticket: MEN-9954 Changelog: None Signed-off-by: Vratislav Podzimek <vratislav.podzimek+auto-signed@northern.tech> (cherry picked from commit 4c2c524)
Author
|
@mender-test-bot, start a full client pipeline with:
my commands and optionsYou can prevent me from automatically starting CI pipelines:
You can trigger a client pipeline on multiple prs with:
You can trigger a client pipeline for a specific Mender Client release with:
You can trigger GitHub->GitLab branch sync with:
You can print PR statistics for a repository with:
You can deploy a review app with:
You can run e2e tests against a deployed review app with:
You can cherry pick to a given branch or branches with:
|
Ticket: QA-1517 Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Lluis Campos <lluis.campos@northern.tech> (cherry picked from commit bc42303)
Ticket: QA-1517 Signed-off-by: Lluis Campos <lluis.campos@northern.tech> (cherry picked from commit 151d64a)
To remove custom extensions of conventional commits standard. Ticket: QA-1517 Signed-off-by: Lluis Campos <lluis.campos@northern.tech> (cherry picked from commit d6987de)
Author
|
Merging these commits will result in the following changelog entries: Changelogsmender (cherry-5.1.x-master-resumer-giveup-hangs-async-reader)New changes in mender since 5.1.x: Bug Fixes
|
Contributor
tested on master and the cherry-pick was clean, not running this through the full pipeline |
vpodzime
deleted the
cherry-5.1.x-master-resumer-giveup-hangs-async-reader
branch
July 24, 2026 09:34
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.
Cherry pick of PR: #1992
For you :)