Add lease to update project statistics row and log concurrent updates
What does this MR do and why?
We need to be able to trace when there is potential concurrent update on a single project statistics row.
This MR makes the following changes:
- Refactor existing code to call a counter update method with a lock in
ProjectStatistics
. - Wrap each attempt to update a project statistics with an exclusive lease lock.
- Log a warning each time it fails to obtain the lock and continue executing the update.
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #373595
Merge request reports
Activity
added devopsverify grouppipeline security sectionops typebug labels
assigned to @alberts-gitlab
Suggested Reviewers (beta)
The individuals below may be good candidates to participate in the review based on various factors.
You can use slash commands in comments to quickly assign
/assign_reviewer @user1
.Suggested Reviewers @rspeicher
,@rymai
,@smcgivern
,@ayufan
,@tkuah
If you do not believe these suggestions are useful, please apply the label Bad Suggested Reviewer. You can also provide feedback for this feature on this issue:
https://gitlab.com/gitlab-org/gitlab/-/issues/357923
.Automatically generated by Suggested Reviewers Bot - an experimental ML-based recommendation engine created by ~"group::applied ml".
Edited by GitLab Reviewer-Recommender Bot- A deleted user
added backend label
1 Warning Please add a merge request subtype to this merge request. 1 Message CHANGELOG missing: If you want to create a changelog entry for GitLab FOSS, add the
Changelog
trailer to the commit message you want to add to the changelog.If you want to create a changelog entry for GitLab EE, also add the
EE: true
trailer to your commit message.If this merge request doesn't need a CHANGELOG entry, feel free to ignore this message.
Reviewer roulette
Changes that require review have been detected!
Please refer to the table below for assigning reviewers and maintainers suggested by Danger in the specified category:
Category Reviewer Maintainer backend Corinna Gogolok ( @cwiesner
) (UTC+2, 6 hours behind@alberts-gitlab
)Pavel Shutsin ( @pshutsin
) (UTC+2, 6 hours behind@alberts-gitlab
)To spread load more evenly across eligible reviewers, Danger has picked a candidate for each review slot, based on their timezone. Feel free to override these selections if you think someone else would be better-suited or use the GitLab Review Workload Dashboard to find other available reviewers.
To read more on how to use the reviewer roulette, please take a look at the Engineering workflow and code review guidelines. Please consider assigning a reviewer or maintainer who is a domain expert in the area of the merge request.
Once you've decided who will review this merge request, assign them as a reviewer! Danger does not automatically notify them for you.
If needed, you can retry the
danger-review
job that generated this comment.Generated by
Danger- Resolved by Albert
@alberts-gitlab - please see the following guidance and update this merge request.1 Warning Please add a subtype label to this merge request. If you have added a type label and do not feel the purpose of this merge request matches one of the subtypes labels, please resolve this discussion.
Allure report
allure-report-publisher
generated test report!e2e-review-qa-blocking:
test report for 63b34a4eexpand test summary
+-----------------------------------------------------------------------------------------+ | suites summary | +------------------------------------+--------+--------+---------+-------+-------+--------+ | | passed | failed | skipped | flaky | total | result | +------------------------------------+--------+--------+---------+-------+-------+--------+ | Plan | 47 | 0 | 1 | 46 | 48 | ❗ | | Verify | 12 | 0 | 1 | 10 | 13 | ❗ | | Create | 27 | 0 | 2 | 25 | 29 | ❗ | | Manage | 57 | 0 | 3 | 56 | 60 | ❗ | | Configure | 0 | 0 | 1 | 0 | 1 | ➖ | | Package | 0 | 0 | 1 | 0 | 1 | ➖ | | Version sanity check | 0 | 0 | 1 | 0 | 1 | ➖ | | Protect | 2 | 0 | 0 | 2 | 2 | ❗ | | Secure | 2 | 0 | 0 | 2 | 2 | ❗ | | Feature flag handler sanity checks | 9 | 0 | 0 | 0 | 9 | ✅ | +------------------------------------+--------+--------+---------+-------+-------+--------+ | Total | 156 | 0 | 10 | 141 | 166 | ❗ | +------------------------------------+--------+--------+---------+-------+-------+--------+
e2e-review-qa:
test report for 64f6a1b2expand test summary
+-----------------------------------------------------------------------------------------+ | suites summary | +------------------------------------+--------+--------+---------+-------+-------+--------+ | | passed | failed | skipped | flaky | total | result | +------------------------------------+--------+--------+---------+-------+-------+--------+ | Manage | 52 | 0 | 8 | 9 | 60 | ❗ | | Plan | 47 | 0 | 1 | 0 | 48 | ✅ | | Verify | 43 | 0 | 8 | 29 | 51 | ❗ | | Create | 30 | 0 | 1 | 2 | 31 | ❗ | | Protect | 2 | 0 | 0 | 0 | 2 | ✅ | | Secure | 2 | 0 | 0 | 0 | 2 | ✅ | | Package | 0 | 0 | 1 | 0 | 1 | ➖ | | Feature flag handler sanity checks | 9 | 0 | 0 | 0 | 9 | ✅ | | Version sanity check | 0 | 0 | 1 | 0 | 1 | ➖ | | Configure | 0 | 0 | 1 | 0 | 1 | ➖ | +------------------------------------+--------+--------+---------+-------+-------+--------+ | Total | 185 | 0 | 21 | 40 | 206 | ❗ | +------------------------------------+--------+--------+---------+-------+-------+--------+
e2e-package-and-test:
test report for 64f6a1b2expand test summary
+---------------------------------------------------------------------------+ | suites summary | +----------------------+--------+--------+---------+-------+-------+--------+ | | passed | failed | skipped | flaky | total | result | +----------------------+--------+--------+---------+-------+-------+--------+ | Create | 320 | 0 | 10 | 10 | 330 | ❗ | | Plan | 114 | 0 | 0 | 0 | 114 | ✅ | | Protect | 4 | 0 | 0 | 0 | 4 | ✅ | | Verify | 86 | 0 | 16 | 0 | 102 | ✅ | | Manage | 178 | 0 | 28 | 6 | 206 | ❗ | | Secure | 44 | 0 | 2 | 2 | 46 | ❗ | | Fulfillment | 4 | 0 | 24 | 2 | 28 | ❗ | | Package | 0 | 0 | 6 | 0 | 6 | ➖ | | Release | 8 | 0 | 0 | 0 | 8 | ✅ | | Configure | 0 | 0 | 6 | 0 | 6 | ➖ | | Version sanity check | 0 | 0 | 2 | 2 | 2 | ➖ | | Analytics | 4 | 0 | 0 | 0 | 4 | ✅ | +----------------------+--------+--------+---------+-------+-------+--------+ | Total | 762 | 0 | 94 | 22 | 856 | ❗ | +----------------------+--------+--------+---------+-------+-------+--------+
added 1 commit
- 1c6c8254 - Refactor legacy_increment_statistic to use update_counters
- Resolved by Fabio Pitino
marked the checklist item I have evaluated the MR acceptance checklist for this MR. as completed
- Resolved by Fabio Pitino
- Resolved by Fabio Pitino
@vij could you review please?
requested review from @vij
added pipeline:run-as-if-foss label
changed milestone to %15.4
- Resolved by Fabio Pitino
- Resolved by Fabio Pitino
- Resolved by Fabio Pitino
- Resolved by Fabio Pitino
- Resolved by Fabio Pitino
requested review from @fabiopitino and removed review request for @vij
@vij
, thanks for approving this merge request.This is the first time the merge request is approved. To ensure full test coverage, a new pipeline has been started.
For more info, please refer to the following links:
Reminder to self:
- Resolve conflict
- Add feature flag on logging
Edited by Albert- Resolved by Fabio Pitino
- Resolved by Fabio Pitino
added 503 commits
-
63b34a4e...f70efa51 - 498 commits from branch
master
- c9c21e05 - Lock project statistics for update
- 845b7d34 - Refactor legacy_increment_statistic to use update_counters
- 37f382d0 - Consolidate counter update with lock into one method
- d0404eba - Log a warning when unable to obtain a lock
- 778eb9d4 - Remove unused method
Toggle commit list-
63b34a4e...f70efa51 - 498 commits from branch
- A deleted user
added feature flag label
- Resolved by Fabio Pitino
- Resolved by Fabio Pitino
- Resolved by Fabio Pitino
- Resolved by Fabio Pitino
- Resolved by Bob Van Landuyt
removed review request for @fabiopitino
added 408 commits
-
cd9ef417...dc364939 - 398 commits from branch
master
- 254b7363 - Lock project statistics for update
- 82c05ffd - Refactor legacy_increment_statistic to use update_counters
- 0a0ff230 - Consolidate counter update with lock into one method
- ce709571 - Log a warning when unable to obtain a lock
- 57113949 - Remove unused method
- 711de620 - Add feature flag to logging of lock retry
- 5d1bdea7 - Rename method
- 765e713b - Define reset_counter! on CounterAttribute
- 12eba858 - Refactor to move locks into CounterAttribute
- 09034ed4 - Add feature flag to counter attribute database lock
Toggle commit list-
cd9ef417...dc364939 - 398 commits from branch