mirror of
https://github.com/go-gitea/gitea.git
synced 2026-03-22 14:34:54 -05:00
cron.update_mirrors broken in Gitea 1.16.0 #8497
Closed
opened 2025-11-02 08:08:42 -06:00 by GiteaMirror
·
48 comments
No Branch/Tag Specified
main
release/v1.25
release/v1.24
release/v1.23
release/v1.22
release/v1.21
release/v1.20
release/v1.19
release/v1.18
release/v1.17
release/v1.16
release/v1.15
release/v1.14
release/v1.13
release/v1.12
release/v1.11
release/v1.10
release/v1.9
release/v1.8
v1.25.3
v1.25.2
v1.25.1
v1.25.0
v1.24.7
v1.25.0-rc0
v1.26.0-dev
v1.24.6
v1.24.5
v1.24.4
v1.24.3
v1.24.2
v1.24.1
v1.24.0
v1.23.8
v1.24.0-rc0
v1.25.0-dev
v1.23.7
v1.23.6
v1.23.5
v1.23.4
v1.23.3
v1.23.2
v1.23.1
v1.23.0
v1.23.0-rc0
v1.24.0-dev
v1.22.6
v1.22.5
v1.22.4
v1.22.3
v1.22.2
v1.22.1
v1.22.0
v1.23.0-dev
v1.22.0-rc1
v1.21.11
v1.22.0-rc0
v1.21.10
v1.21.9
v1.21.8
v1.21.7
v1.21.6
v1.21.5
v1.21.4
v1.21.3
v1.21.2
v1.20.6
v1.21.1
v1.21.0
v1.21.0-rc2
v1.21.0-rc1
v1.20.5
v1.22.0-dev
v1.21.0-rc0
v1.20.4
v1.20.3
v1.20.2
v1.20.1
v1.20.0
v1.19.4
v1.21.0-dev
v1.20.0-rc2
v1.20.0-rc1
v1.20.0-rc0
v1.19.3
v1.19.2
v1.19.1
v1.19.0
v1.19.0-rc1
v1.20.0-dev
v1.19.0-rc0
v1.18.5
v1.18.4
v1.18.3
v1.18.2
v1.18.1
v1.18.0
v1.17.4
v1.18.0-rc1
v1.19.0-dev
v1.18.0-rc0
v1.17.3
v1.17.2
v1.17.1
v1.17.0
v1.17.0-rc2
v1.16.9
v1.17.0-rc1
v1.18.0-dev
v1.16.8
v1.16.7
v1.16.6
v1.16.5
v1.16.4
v1.16.3
v1.16.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
v1.4.0-rc1
v1.3.2
v1.3.1
v1.3.0
v1.3.0-rc2
v1.3.0-rc1
v1.2.3
v1.2.2
v1.2.1
v1.2.0
v1.2.0-rc3
v1.2.0-rc2
v1.1.4
v1.2.0-rc1
v1.1.3
v1.1.2
v1.1.1
v1.1.0
v1.0.2
v1.0.1
v1.0.0
v0.9.99
Labels
Clear labels
$20
$250
$50
$500
backport/done
💎 Bounty
docs-update-needed
good first issue
hacktoberfest
issue/bounty
issue/confirmed
issue/critical
issue/duplicate
issue/needs-feedback
issue/not-a-bug
issue/regression
issue/stale
issue/workaround
lgtm/need 2
modifies/api
modifies/translation
outdated/backport/v1.18
outdated/theme/markdown
outdated/theme/timetracker
performance/bigrepo
performance/cpu
performance/memory
performance/speed
pr/breaking
proposal/accepted
proposal/rejected
pr/wip
pull-request
reviewed/wontfix
💰 Rewarded
skip-changelog
status/blocked
topic/accessibility
topic/api
topic/authentication
topic/build
topic/code-linting
topic/commit-signing
topic/content-rendering
topic/deployment
topic/distribution
topic/federation
topic/gitea-actions
topic/issues
topic/lfs
topic/mobile
topic/moderation
topic/packages
topic/pr
topic/projects
topic/repo
topic/repo-migration
topic/security
topic/theme
topic/ui
topic/ui-interaction
topic/ux
topic/webhooks
topic/wiki
type/bug
type/deprecation
type/docs
type/enhancement
type/feature
type/miscellaneous
type/proposal
type/question
type/refactoring
type/summary
type/testing
type/upstream
Mirrored from GitHub Pull Request
No Label
Milestone
No items
No Milestone
Projects
Clear projects
No project
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/gitea#8497
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @somera on GitHub (Feb 4, 2022).
Gitea Version
1.16.0
Git Version
2.25.1
Operating System
Ubuntu 20.04.3
How are you running Gitea?
Precompiled gitea-1.16.0-linux-amd64
Database
PostgreSQL
Can you reproduce the bug on the Gitea demo site?
No
Log Gist
No response
Description
I'm hosting a lot of mirrors on my Gitea instance. Some days ago I updated to 1.16.0.
I see -> it started at 04:00 AM, but ...
Last run with Gitea 1.15.x:
cron.update_mirrors needed with Gitea 1.15.x ~3h to update all mirrors. The cron runs fridays at 04:00 AM. And today was the first run.
I saw in gitea that the cron runs -> run count was 1. But the monitoring data shows no activity (RAM usage, CPU usage, Disk usage) between 04:00 and 07:00 AM.
Than I started (4-6x times) the cron in Gitea admin web console. It runs for some seconds. and I saw some activity.
But there is no date for the last run of the cron
After the 4-6 runs the sorting by last update time isn't showing any changes
All the projects with Feb 04 date are created today. But I can't see the updated mirrors when I change the sort order.
Why cron.update_mirrors is not updating all my mirrors? I can't see any errors in the Gitea logs.
Screenshots
No response
@somera commented on GitHub (Feb 4, 2022):
@zeripath should I set now the new parameters from #16982?
Cause I added now
PULL_LIMIT = 100and it runs longer.
After an update (1.15.x -> 1.16.0) I rather expect the old behavior.
@somera commented on GitHub (Feb 4, 2022):
I increased it to
PULL_LIMIT = 2000and the cron.update_mirrors run's ~8-10 minutes. Second time ~12 minutes. Means for me: 2 runns -> 4000 updated 2000 mirrors.
but ~20 minutes for 4000 mirrors it's to fast for me.
Questions:
Sometimes I see what Gitea is doing
and sometimes not
Just missing the git call for a lot projects.
And it will be good to know that this cron was running (start date, finish date) and how many repos was updated.
You are showing some infos for some crons. But not for the mirror cron.
I just have to know: is the process working fine or not? Can I lost data?
@somera commented on GitHub (Feb 4, 2022):
I run the cron 4x manually.
1 time with PULL_LIMIT = 100 and 3 times with PULL_LIMIT = 2000
And in the DB I see
I expected ~6100 repos with update_unix = 2022-02-04. But there are only 1675.
@somera commented on GitHub (Feb 4, 2022):
Now I'm sure. The new process is broken.
6 runs: 1 time with PULL_LIMIT = 100 and 5 times with PULL_LIMIT = 2000
But
And if I start the cron again -> nothing happens.
And in the mirror table (next_update_unix column) I see, how many mirrors can be updated
@somera commented on GitHub (Feb 5, 2022):
Since yesterday klicked x times on "Now sync" -> nothing happens
@somera commented on GitHub (Feb 5, 2022):
I run today manually the cron. Gitea updated run some mirror updates. But the mirror.updated_unix column hasn't after the run ZERO changes.
Now I call the curl
curl -X 'POST' 'http://nuc-mini-celeron:3000/api/v1/repos/gaphor/in-app-notification-demo/mirror-sync' -H 'accept: application/json' -H 'Authorization: token xxxxx' -d ''call for evry mirror again and the mirror.updated_unix is changing
But the whole mirror update process looks brocken.
@somera commented on GitHub (Feb 5, 2022):
After spending some hours with Gitea 1.16.0 I'm disapointed. Disapointed cause Gitea is not working like in 1.15.x for mirror sync. Yes, there was changes. But the changes shouldn't change the existing behavior.
I sended ~40.000 curl calls (4x for all mirrors) to get this mirror_update status
1785 mirrors are not up2date.
This is my current config:
If I now start the update_mirrors cron manually, the oldest mirrors don't be updated. Nothing happens. Why?
If I open the repo with the oldest sync date
and I click on sync. It's not syncing. Why not? How long have I to wait?
@somera commented on GitHub (Feb 6, 2022):
Same status after the very short cron run today at 04:00AM
@lunny commented on GitHub (Feb 6, 2022):
Are there any logs?
@somera commented on GitHub (Feb 6, 2022):
Hm ... if I switch TO DEUBUG I see a lot of SQL's.
Or this: https://github.com/go-gitea/gitea/issues/16982#issuecomment-1030449782
I think, the "problem" is the new feature implemented in #16982. Or you did other big changes.
@somera commented on GitHub (Feb 6, 2022):
I added
and than
./gitea manager flush-queuesand restart gitea. After I run mirror-cron manually I see no changes.
And I can bet, that if I would do my ~9000 curl calls, some of the mirrors will be synced.
The 1 repo with mirror.updated_unix = 2022-02-06 is a new repo which I added today.
@zeripath commented on GitHub (Feb 6, 2022):
I've held off replying to this issue because I'm struggling to completely understand what is the problem and what is actually happening.
This is despite you having posted 11 comments...
So can we please have a succinct three line description as to what is happening, what you want to happen and what your configuration is? (that includes cron configuration.)
I will also remind you that you SPECIFICALLY asked for LIMIT_SIZE - I checked with you as to how it was supposed to work and I wrote a very long explanation as to what it was doing.
There have been many changes to mirroring this is not the only thing.
@somera commented on GitHub (Feb 6, 2022):
Sorry ... I was tested and I posted every try. And there are some problems now.
Started two times after gitea restart. But no last start date set
Yes, this was a wish. But this implementation should not change the "normal process". This should be only for small optimization for people with a lot of mirrors on the gitea instance.
Short version on my problem.
I have 9000+ mirrors. The mirror sync cron was running one time a week and needed 3h to update all mirrors. And after update to gitea 1.16.0 it's not working anymore. The cron runs only for 8-10 seconds.
To update ~90% of the repos I sended yesterday 4 times 9000+ curl calls
curl -X 'POST' 'http://nuc-mini-celeron:3000/api/v1/repos/gaphor/in-app-notification-demo/mirror-sync' -H 'accept: application/json' -H 'Authorization: token xxxxx' -d ''In this case the sync worked.
And now after flush-queue (cause it could be corrupt) if I start the mirror cron manually no one mirror will be updated. I tryied this 3 times.
My config now:
@somera commented on GitHub (Feb 6, 2022):
@zeripath when I change the loglevel to
than I see 9000+ (each for every mirror) select statements in the log
2022/02/06 20:24:32 models/repo/repo.go:635:getRepositoryByID() [I] [SQL] SELECT "id", "owner_id", "owner_name", "lower_name", "name", "description", "website", "original_service_type", "original_url", "default_branch", "num_watches", "num_stars", "num_forks", "num_issues", "num_closed_issues", "num_pulls", "num_closed_pulls", "num_milestones", "num_closed_milestones", "num_projects", "num_closed_projects", "is_private", "is_empty", "is_archived", "is_mirror", "status", "is_fork", "fork_id", "is_template", "template_id", "size", "is_fsck_enabled", "close_issues_via_commit_in_any_branch", "topics", "trust_model", "avatar", "created_unix", "updated_unix" FROM "repository" WHERE "id"=$1 LIMIT 1 [4445] - 848.612µsand than this
2022/02/06 20:24:32 ...s/repo/pushmirror.go:111:PushMirrorsIterate() [I] [SQL] SELECT "id", "repo_id", "remote_name", "interval", "created_unix", "last_update", "last_error" FROM "push_mirror" WHERE (last_update + ("interval" / $1) <= $2) AND ("interval" != 0) ORDER BY last_update ASC [1s 1644175472] - 1.891748msselect. and no one mirror will be updated.
This are the 8-10 seconds the cron.update_mirrors needs to run and finish.
@zeripath commented on GitHub (Feb 6, 2022):
OK let's look at that configuration first.
You have way too many mirrors to for a persistable-channel queue to ever be the correct queue for you.
Therefore change your update_checker queue to use a level queue and get rid of the channel queue related things.
Next I think we need address what the
update_mirrorscron task does,update_mirrorslooks through the list of mirrors which are due to be updated - (e.g.next_update_unix<= Now &next_update_unix != 0) and sorts them into a last_updated order. It will then iterate through them.It will then queue PULL_LIMIT pull mirrors and PUSH_LIMIT push mirrors for update.
The updates will be done by the workers on the other end of the queue. This will depend on your general queue configuration but often this is a scaling worker pool up to a maximum of 10 workers.
So ... If you are finding that nothing is being queued ... It would be useful to check the values of
next_update_unixin the mirror table.The PULL_LIMIT and PUSH_LIMIT code is working perfectly as described and so your problem is elsewhere.
Now to explain why we changed the default PULL_LIMIT and PUSH_LIMIT.
The vast majority of installs will benefit from this change as most people do not:
Your situation represents an edgecase of edgecases.
But I personally have tried to provide you with ways to make your personal situation easier.
The change to use a normal queue for mirrors (#17326) allows you the option to use a level queue for your underlying queue thus prevent gitea from seizing up due to a blocked queue. The PULL_LIMIT and PUSH_LIMIT options were requested by you gives you other options to consider changing your cron configuration back to /10 minutes (but you might actually need a PULL_LIMIT/PUSH_LIMIT to be percentages of the total number of mirrors (not sure here.))
You're not running Gitea in a normal way and that means you will always need to carefully think about things. In your situation you need to tune things properly and that is what we have provided for you.
@somera commented on GitHub (Feb 6, 2022):
This is not defined in
https://github.com/go-gitea/gitea/blob/main/custom/conf/app.example.ini
and
https://docs.gitea.io/en-us/config-cheat-sheet/#mirror-mirror
My current status for the mirrors
This means, that all 9000+ mirrors should be synced now.
;)
Thx!
I added
and restarted my Gitea. But the cron do the same: nothing.
The sync update with curl and directly in repo settings is working.
@zeripath commented on GitHub (Feb 6, 2022):
Change from what? Info is one of the lowest log levels and it will not be giving us any special information.
Would be more useful.
OR even whilst gitea is running you can simply run:
And it will add trace level console logger that will emit TRACE level logs from events in the services/mirror files
That is your 9000 repositories being loaded and then added to the update queue.
These are push mirrors and it is clear that you have none.
Yes this is correct because the cron.update_mirrors task is simply adding mirrors to the queue to be updated - that is all it has ever done. It has never represented the actual work of doing the updating.
The work of updating a mirror will be done by workers on the queue. The mirror queue will scale its workers to do account for the amount of things in the queue.
I've tried to explain this to you before - the cron task update_mirrors DOES NOT represent the actual work of doing the updating. It has never done that. Previously you've had a proxy of this because in your situation you've been blocking the whole queue due to the number of mirrors you have.
@somera commented on GitHub (Feb 6, 2022):
What do you mean with "You're not running Gitea in a normal way"? ;)
If someone (not I) is running Gitea which is used by a lot of people with a lot of repos and mirrors. Than that person get the same problems.
Is this an design "problem"?
Understand or not. I'm not understand what exactly is blocked? The workes for the mirrors queue?
It works with Gitea 1.15.x. -> is the old way isn't implemented anymore?
And the solution now is? At the moment I can send one a week the curl calls to update the mirrors.
@zeripath commented on GitHub (Feb 6, 2022):
f393bc82cb/models/repo/mirror.go (L124-L128)f393bc82cb/services/mirror/mirror.go (L115)Happens for each repo
Thus you get a
f393bc82cb/services/mirror/mirror.go (L67-L70)This will get pushed to the queue unless it is already in the queue.
f393bc82cb/services/mirror/mirror.go (L92-L99)f393bc82cb/services/mirror/mirror.go (L101-L104)Now you assert that calling sync with curl works.
So let's follow what that does:
f393bc82cb/routers/api/v1/repo/mirror.go (L17)f393bc82cb/routers/api/v1/repo/mirror.go (L51)f393bc82cb/services/mirror/mirror.go (L151-L165)Which pushes to the same queue
Now you might argue that that push doesn't have a Has wrapped around it but... There's a Has internally in the push.
So what have we found:
I guess the question I have is what is making you think this isn't working?
So... One thing you could do is simply change the next_update_unix for a mirror manually. Put the tracer logger I suggested above on. And then click the Cron task button and follow what the logs do.
@somera commented on GitHub (Feb 6, 2022):
Results for next_update_unix
If I use curl, that do something, but not for all curl calls.
I made 547 curl calls for 547 repos. And after gitea was ready, 266 repos still was not updated. Than I made second run for the 266 repos.
And this show me, that the sync mirror process isn't working. Cause in this case the manual cron start will update all my mirrors.
Before new manual start
Manual start ...
And this are the changes
Can you explain this? Gitea updates only 4 mirrors with mirror_next_update_unix = '2022-02-06'
And if I start the cron 2nd time ... no one repo will be updated.
@zeripath commented on GitHub (Feb 6, 2022):
Go to monitor and tell me how many workers you have in your mirror queue right now. (Not initial configuration)
@somera commented on GitHub (Feb 6, 2022):
But the number of workers it not important. If I put 1000 items into the queue and I have only 10 workers, that it need longer. And Gitea is not updating more than 1 repo in a row.
@zeripath commented on GitHub (Feb 6, 2022):
That is initial configuration
@somera commented on GitHub (Feb 6, 2022):
If I refresh the config side for the mirror queue I don't see any changes.
@somera commented on GitHub (Feb 6, 2022):
"This queue surrounds other queues and has no worker pool itself."
@zeripath commented on GitHub (Feb 6, 2022):
So... Mirror-channel?
@somera commented on GitHub (Feb 6, 2022):
@somera commented on GitHub (Feb 7, 2022):
I made 48 curl calls and saw this
@zeripath commented on GitHub (Feb 7, 2022):
Hmm... I wonder... Is it possible that the queue worker is timing out and then not being replaced?
@zeripath commented on GitHub (Feb 7, 2022):
I guess a trick for that is to wait until that worker was due to timeout and then add another worker manually yourself and see if that finishes off the work
@zeripath commented on GitHub (Feb 7, 2022):
Actually a flush worker would be better
@zeripath commented on GitHub (Feb 7, 2022):
Yup I bet this is this problem. When the zero worker times out unless there's a push the lack of worker won't be noticed.
Workaround just set workers=1 in [Queue.mirrors] or flush the queue. I'll have a think - likely when the managedQueue loses its final worker and if there's something in the queue it should zeroboost again.
@somera commented on GitHub (Feb 7, 2022):
I added this
and set the limits to 100 (only for testing)
Than restart gitea
And start the cron manually ... no repo was synced.
I see this
and no other activity. after 8-10 seconds this task is finished.
I made 4 tests
@somera commented on GitHub (Feb 7, 2022):
But what is the difference to curl?
curl is an external call which put the mirror into the queue. And it works.
What is the difference between the cron call? If you try to explain this, you will find the "problem". ;)
@lunny commented on GitHub (Feb 7, 2022):
OK. I found something. It seems the mirror address is not right. Which may caused by #15157 . PR #18649
@somera commented on GitHub (Feb 7, 2022):
What does it mean?
Should cron.update_mirrors be disabled? And can something go wrong here?
@somera commented on GitHub (Feb 11, 2022):
After
Run:
gitea manager flush-queuesWait for it to finish.
Shutdown Gitea and delete the /data/queues/common folder.
Restart.
Gitea is syncing only ~220 mirrors.
@zeripath commented on GitHub (Feb 11, 2022):
Are you running 1.16-head?
@somera commented on GitHub (Feb 11, 2022):
No. I can't run this on my instance.
@zeripath commented on GitHub (Feb 11, 2022):
I'm not suggesting that you run 1.17/main - I am simply suggesting that you move the 1.16-dev or 1.16 which tracks the backports and bug fixes that will become 1.16.2 in future in the next week.
Are you at least running with
WORKERS=1so that there is a permanent worker for the mirror queue?@somera commented on GitHub (Feb 11, 2022):
Powered by Gitea Version: 1.16.1
@somera commented on GitHub (Feb 11, 2022):
Yes.
I restarted repeated flush-queues ... and started the mirror process again.
@somera commented on GitHub (Feb 11, 2022):
It looks better now. And Gitea is syncing the mirrors.
@somera commented on GitHub (Feb 11, 2022):
It's possible to stop the whole sync mirror process?
If I press on yellow marked trash. Will this stop only for the one mirror or whole cron?
@zeripath commented on GitHub (Feb 11, 2022):
Just one mirror - if you want to stop all mirroring you'll need to stop the queue worker.
@somera commented on GitHub (Feb 12, 2022):
Thx. I will try this other time.
Some update ...
After last try:
with manual cron start I could update all mirrors in one row. Good. Looks like this helps. But ...
About 16-18 hours (DEFAULT_INTERVAL = 8h) later I wanted see what happens, if I start the cron again.
My actual configuration is:
But "nothing" happens. Gite updates ~10 mirrors.
@somera commented on GitHub (Feb 18, 2022):
Only ~50 mirrors are updated every day on the 04:00AM run
With the configuration which I postet in the comment above.
@somera commented on GitHub (Feb 24, 2022):
@zeripath I opened #18895