-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
WIP: Fix incorrect open issue count after commit close #10541
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
Conversation
1055dae
to
c7fbede
Compare
Codecov Report
@@ Coverage Diff @@
## master #10541 +/- ##
==========================================
+ Coverage 43.66% 43.72% +0.06%
==========================================
Files 586 586
Lines 81553 81595 +42
==========================================
+ Hits 35607 35680 +73
+ Misses 41539 41503 -36
- Partials 4407 4412 +5
Continue to review full report at Codecov.
|
This should be handled at IMHO the problem is ...... wait for it ..... a locking issue (this section also relevant). 😁 |
imo what's biting us here is the I'm not sure if the comment is still accurate (probably not quite), but To clarify, |
That's exactly my point: we read the repository.... changes occur in the middle.... we write stale information. Even if we restrict the writing to the specific columns of interest, we could still be writing stale info; for example when we update counters, statuses or info that depends on those statuses we've read before. Getting collisions on those updates is just a matter of chance and server load. Specificity would only reduce our chances of collisions. That's why statements like |
Well SELECT ... FOR UPDATE works nicely for parallel transactions, running on the same table. The As this is my first time working on this project, I am not quite sure how parallel the repository fetching from the database can be but why is it even necessary to completely recalculate the number of closed issues. Simply updating the repository structs value by either removing or adding |
This commit fixes the bug that a repositories open issue value is not updated when an issue is closed through a commit that references such issue. More specifically, creating an issue on a repository with currently 0 open bugs lead to the repository showing one open issue. Closing such issue through a commit onto the branch this issue was targetting would close the issue correctly but failed to update the issue counter in the repositories header. Hence the repository would show one open issue while the open issue list remains empty. As this commit is a response to go-gitea#10536, more information about the bug can be aquired there. Fixes go-gitea#10536.
c7fbede
to
783c11c
Compare
Well... we should fix that. 😑 |
Concerning that the repository is provided by the context and is read in its own session, we would have to forward the initial session/transaction that is used to create the repository all the way through the entire endpoint logic. Seems like a pretty big fix for such a problem. |
This bug has not been fixed in version 1.11.4 |
Is there any update on this? I'm on 1.11.3, the issue is present there, I checked the releases since then and did not see any mention of this issue. |
Closed in favour of #11310 |
This commit fixes the bug that a repositories open issue value is not
updated when an issue is closed through a commit that references such
issue.
More specifically, creating an issue on a repository with currently 0
open bugs lead to the repository showing one open issue.
Closing such issue through a commit onto the branch this issue was
targetting would close the issue correctly but failed to update the
issue counter in the repositories header. Hence the repository would
show one open issue while the open issue list remains empty.
As this commit is a response to #10536, more information about the
bug can be aquired there.
Fixes #10536.
Problem:
The issue comes from the fact that the the commit issue hooks are executed before this line, which updates the entire repository into the database.
This overwrites the calls further up in the method which updates the number of closed issues correctly.
Solution:
To solve this (and to run the solving logic as few times as possible) this commit implemented a simple flag in the CommitRepoAction method that tracks if any commit actually modifies the closed issue number.
If that is the case, we select the updated value from the database and assign it to the local repository instance so the updated value is saved to the database in line 277.