Skip to content

gitserver: update repo sizes only for repos that changed

Administrator requested to merge mrn+es/improve-update-repo-sizes into main

Created by: mrnugget

@eseliger and I noticed that we always do a full insert of possibly 10000 repositories when updating the repo size, even if that size didn't change, only updating it on conflict.

Since repo and gitserver_repos are consistent now, thanks to the database trigger, we can use normal UPDATE calls to update the size of the repos in gitserver_repos.

So what this does is it reduces the writes-to-disk that the database does and it fixes the reporting of "these repos have been updated" by only reporting when a repo has in fact been updated in the database.

I think it's also clearer what the code does, vs. the previous use of WithInserterWithReturner where the returner* arguments where nil and the whole thing was only used because of the ON CONFLICT.

Test plan

  • Manual testing by checking log output locally, modifying database values, seeing how gitserver behaves, etc.
  • Unit tests (old and new)

Merge request reports

Loading