Skip to content

Make admin git gc tasks run in background #10629

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

Closed

Conversation

zeripath
Copy link
Contributor

@zeripath zeripath commented Mar 6, 2020

The admin git gc and git fsck tasks should run in the background rather than run on the request scope.

Any errors should then be put in to the notices.

Fix #10299

@zeripath zeripath added the type/enhancement An improvement of existing functionality label Mar 6, 2020
@zeripath zeripath added this to the 1.12.0 milestone Mar 6, 2020
@zeripath zeripath force-pushed the background-admin-git-gc-task branch from b727957 to 334df6a Compare March 6, 2020 05:36
Copy link
Member

@guillep2k guillep2k left a comment

Choose a reason for hiding this comment

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

A couple of comments, just in case they're relevant

@GiteaBot GiteaBot added the lgtm/need 1 This PR needs approval from one additional maintainer to be merged. label Mar 6, 2020
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Mar 6, 2020
@zeripath
Copy link
Contributor Author

zeripath commented Mar 6, 2020

Now should we be putting a system notice to say that we've completed the gc/fsck?

@zeripath
Copy link
Contributor Author

zeripath commented Mar 6, 2020

None of the other tasks seem to do this. So perhaps it would be better to do it as another PR

@lunny
Copy link
Member

lunny commented Mar 6, 2020

@zeripath I would like to create a record on task table with a new type and track the status of them.

@zeripath
Copy link
Contributor Author

zeripath commented Mar 6, 2020

You could leverage the process table - there's nothing that requires that to be an actual running external process

@silverwind
Copy link
Member

Now should we be putting a system notice to say that we've completed the gc/fsck?

I'd go for it. Given that it can only be started manually, a notice would not be unexpected.

Copy link
Member

@lunny lunny left a comment

Choose a reason for hiding this comment

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

I think we should use a unique queue to keep only one gc once for a repository.

@zeripath
Copy link
Contributor Author

zeripath commented Mar 6, 2020

We can just run it with WithUnique(...) like we do for Cronable events.

@silverwind
Copy link
Member

silverwind commented Mar 6, 2020

Tried this locally, UI showed GC was started but in the log I see this error (no stack or anything):

2020/03/06 19:21:35 ...uters/admin/admin.go:186:func1() [E] Error whilst running git gc: 0x1c97a40

Any way to show more error detail?

@codecov-io
Copy link

Codecov Report

❗ No coverage uploaded for pull request base (master@345515a). Click here to learn what that means.
The diff coverage is 41.3%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master   #10629   +/-   ##
=========================================
  Coverage          ?   43.61%           
=========================================
  Files             ?      588           
  Lines             ?    82502           
  Branches          ?        0           
=========================================
  Hits              ?    35980           
  Misses            ?    42060           
  Partials          ?     4462
Impacted Files Coverage Δ
routers/admin/admin.go 10.21% <0%> (ø)
modules/repository/check.go 0% <0%> (ø)
modules/cron/cron.go 50.49% <61.29%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 345515a...9af8901. Read the comment docs.

@zeripath
Copy link
Contributor Author

zeripath commented Mar 6, 2020

@silverwind There was a bug in the previous version try now

@@ -72,13 +72,18 @@ func GitGcRepos(ctx context.Context) error {
if err := repo.GetOwner(); err != nil {
return err
}
log.Trace("Running git gc on %v", repo)
Copy link
Member

@silverwind silverwind Mar 6, 2020

Choose a reason for hiding this comment

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

What logging config do I need to see these? I have LEVEL = Trace and tried both file/stdout logging. Also, I'd suggest raising this and similar ones to Info.

@zeripath
Copy link
Contributor Author

zeripath commented Mar 7, 2020

OK. We have two options - keep this a simple just background the GC tasks PR - or properly sort out these admin and cron tasks.

That is:

  • Admin and cron task should appear in Processes - with cancellable contexts
  • They should report when they're done - presumably into system notices?

As an extension cron tasks need restructuring - they should probably be merged with the admin tasks - and their config moved to the db?

@silverwind
Copy link
Member

They should report when they're done - presumably into system notices?

Yes, please. I don't feel like one should have to dig into logs for this. I'd say also report when admin actions start in the system notices.

Additional "nicities" I could see:

  • Add the username who started it to the start notice
  • Add either a report that lists repo size before/after gc or just the raw CLI output to the finish notice.

@zeripath
Copy link
Contributor Author

I'm going to close this in favour of an all singing all dancing refactor...

@zeripath zeripath closed this Mar 16, 2020
@zeripath
Copy link
Contributor Author

See #10745

@somera
Copy link

somera commented Jun 18, 2020

How is the status here? My hope was to get this in 1.12.0.

@zeripath zeripath deleted the background-admin-git-gc-task branch September 13, 2020 12:34
@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/enhancement An improvement of existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Garbage-Collection not working
9 participants