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

Add a bit of randomness to the wait time after source update failure #3661

Merged
merged 1 commit into from
Sep 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/AppInstallerRepositoryCore/RepositorySource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,12 @@ namespace AppInstaller::Repository
CATCH_LOG();

AICLI_LOG(Repo, Info, << "Source add/update failed, waiting a bit and retrying: " << details.Name);
std::this_thread::sleep_for(2s);

// Add a bit of randomness to the retry wait time
std::default_random_engine randomEngine(std::random_device{}());
std::uniform_int_distribution<long long> distribution(2000, 10000);

std::this_thread::sleep_for(std::chrono::milliseconds(distribution(randomEngine)));

// If this one fails, maybe the problem is persistent.
result = (factory.get()->*member)(details, progress);
Expand Down
1 change: 1 addition & 0 deletions src/AppInstallerRepositoryCore/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
#include <map>
#include <memory>
#include <optional>
#include <random>
#include <set>
#include <string>
#include <string_view>
Expand Down