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

More verbosity and delayed retries #11

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Stef-33560
Copy link

@Stef-33560 Stef-33560 commented Jun 10, 2021

This PR adds

  • more retries, with delay
    For a reason that I can't explain when has_v1_mirror is true, some downloads fails, it seems that retrying immediately doesn't helps to recover everytime the things. Adding a fixed pause (i.e. : 1 second in commit 1066162) does not seems to be always sufficient. Calming more and more down the little 🐰 forces him to gather things much better ! 😜
  • verbosity (while using -v)

Output show between between brackets show the number of retries.

  • time ./mirror --v2 -v, from empty folder, started 2021-06-12T09:29PM UTC,

Seen at the end of the process :

....MMR[1]R[1]R[1]R[1]R[1]R[1]R[2]R[2]R[2]R[2]R[2]R[2]R[3]R[3]R[3]R[3]R[3]R[3]R[4]R[4]R[4]R[4]R[4]R[4]R[5]R[5]R[5]R[5]R[5]R[5]R[6]R[6]R[6]R[6]R[6]R[6]R[7]R[7]R[7]R[7]R[7]R[7]R[8]R[8]R[8]R[8]R[8]R[8]R[9]R[9]R[9]R[9]R[9]R[9]R[10]R[10]R[10]R[10]R[10]R[10]??????
Downloaded 611665 files
real 33m23,535s
user 9m41,809s
sys 2m5,659s

  • time ./mirror.php --resync -v started at 2021-06-1210:16PMUTC
    Seen at the end of the process :

---R[1]R[1]R[1]R[1]R[1]R[1]R[2]R[2]R[2]R[2]R[2]R[2]R[3]R[3]R[3]R[3]R[3]R[3]R[4]R[4]R[4]R[4]R[4]R[4]R[5]R[5]R[5]R[5]R[5]R[5]R[6]R[6]R[6]R[6]R[6]R[6]R[7]R[7]R[7]R[7]R[7]R[7]R[8]R[8]R[8]
R[8]R[8]R[8]R[9]R[9]R[9]R[9]R[9]R[9]R[10]R[10]R[10]R[10]R[10]R[10]??????
Downloaded 611667 files

real 27m6,411s
user 7m5,421s
sys 1m5,743s

The mirror is fully operationnal

composer config repos.packagist composer https://mirror-composer.lan/
composer require drush/drush

[...]
14 package suggestions were added by new dependencies, use composer suggest to see details.

@Stef-33560 Stef-33560 changed the title DRAFT : Packages.json missing on root (V2 update) - error "origin server returns an older file" Error "origin server returns an older file" Jun 12, 2021
@Stef-33560 Stef-33560 changed the title Error "origin server returns an older file" More verbosity and delayed retries Jun 12, 2021
@Stef-33560 Stef-33560 marked this pull request as ready for review June 12, 2021 09:07
mirror.php Show resolved Hide resolved
@@ -270,15 +283,16 @@ private function downloadV2Files(array $requests)

// got an outdated file, possibly fetched from a mirror which was not yet up to date, so retry after 2sec
if ($is404 || $mtime < $userData['minimumFilemtime']) {
if ($userData['retries'] > 2) {
// 404s after 3 retries should be deemed to have really been deleted, so we stop retrying
sleep($userData['retries']);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not necessary IMO. It adds longer sleep but with the addition of 10 retries we anyway get 10x2sec sleep which should really be more than enough for everything to sync up upstream.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without this exponentiel timeout time, even with 10 times, my mirror fails.
I don't know why, maybe an issue with my ISP, with CloudFlare or something like that ?

I retried with another ISP ; results :

git clone https://github.com/composer/mirror/
cat mirror.config.php
<?php

return [
    // directory where metadata files will get saved
    'target_dir' => './mymirror',
    // user agent describing your mirror node, if possible include domain name of mirror, and a contact email address
    'user_agent' => 'Just testing mirror script'/* TODO Mirror for foo.com ([email protected]) */,
    // source repository URL
    'repo_url' => 'https://repo.packagist.org',
    // source repository hostname (optional, will guess from repo_url)
    //'repo_hostname' => 'repo.packagist.org',
    // source API URL
    'api_url' => 'https://repo.packagist.org',
    // how many times the script will run the mirroring step before exiting
    'iterations' => 1,
    // how many seconds to wait between mirror runs
    'iteration_interval' => 5,
    // set this to false if you do not run the --v1 mirror job, to ensure that the v2 will then take care of syncing packages.json
    'has_v1_mirror' => false,
];
./mirror.php --v2 -v

[...] lots of M [...]
[...] plenty of EEEEEEE [...]
Fatal error: Uncaught Symfony\Component\HttpClient\Exception\TransportException: Timeout was reached for "https://repo.packagist.org/p2/muxtor/yii2-pkk5-component.json". in /home/steph/composer-mirror/vendor/symfony/http-client/Response/CurlResponse.php:317

Result : 3.6Gb

With my PR, with the same config, no EEEE:

[...] lots of M [...]
[1]R[1]R[1]R[1]R[1]R[1]R[1]R[1]R[2]R[2]R[2]R[2]R[2]R[2]R[2]R[2]R[3]R[3]R[3]R[3]R[3]R[3]R[3]R[3]R[4]R[4]R[4]R[4]R[4]R[4]R[4]R[4]R[5]R[5]R[5]R[5]R[5]R[5]R[5]R[5]R[6]R[6]R[6]R[6]R[6]R[6]R[6]R[6]R[7]R[7]R[7]R[7]R[7]R[7]R[7]R[7]R[8]R[8]R[8]R[8]R[8]R[8]R[8]R[8]R[9]R[9]R[9]R[9]R[9]R[9]R[9]R[9]R[10]R[10]R[10]R[10]R[10]R[10]R[10]R[10]????????

Result : 6.2Gb

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