-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
Storing branch commits count in db rather than caching them in memory or redis #33954
base: main
Are you sure you want to change the base?
Conversation
modules/gitrepo/commit.go
Outdated
return nil, err | ||
} | ||
defer gitRepo.Close() | ||
return gitRepo.GetCommit(commitID) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can not do this! You can not close the gitRepo then then access the returned "commit"!!!!
That's I said many times: I do not see how you could make the "gitrepo" package work correctly, but introducing more bugs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
998f9ff
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really questionable whether it should be that complex
Branch commit counts are cached in memory or Redis after the first access. However, the initial page load is still slow because the commit count needs to be computed.
This PR introduces a new field in the database to store commit counts for branches. The commit count is updated automatically when branches are pushed or mirrored. Additionally, a background task periodically checks and corrects any discrepancies in the commit count to handle unexpected situations.
With this change, even if the commit count is not updated in time, a number will still be displayed in the UI. This prevents the UI from blocking the user, as commit counts are generally not critical for the user’s experience when visiting the page.
Note: The
release
table has a columnnum_commits
which stored the commit count of a tag. So that we just need to cache a commit's commit count in the cache.