Migrate Redis BufferedCounter to Redis SharedState
What does this MR do and why?
Use MultiStore
to migrate keys from Gitlab::Redis::BufferedCounter
to Gitlab::Redis::SharedState
. Migration is done by wrapping the BufferedCounter
class with Multistore, which handles dual writes and switchover read to both stores via FF toggles.
As described in gitlab-com/gl-infra/data-access/durability/team#71, we are able to sync up the buffered counters with MultiStore only because FlushCounterIncrementsWorker
isn't enabled. Without this, we'd have to implement a more complicated approach as in !140630 (closed).
References
Please include cross links to any resources that are relevant to this MR. This will give reviewers and future readers helpful context to give an efficient review of the changes introduced.
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
Before | After |
---|---|
How to set up and validate locally
- Setup Redis Cluster https://gitlab.com/gitlab-org/gitlab-development-kit/-/blob/main/doc/howto/redis_cluster.md
- Configure
config/redis.yml
:
buffered_counter:
url: unix:/Users/gregoriusmarco/gdk/redis/redis.socket?db=5 # change to your respective gdk path
shared_state:
cluster:
- redis://localhost:6001
- Enable dual write FF:
Feature.enable(:use_primary_and_secondary_stores_for_buffered_counter)
- Increment some counter:
ProjectStatistics.increment_statistic(Project.find(1), :build_artifacts_size, Gitlab::Counters::Increment.new(amount: 10))
- Check that the keys exist in both Redises:
# on redis buffered_counter
$ gdk redis-cli -n 5
redis /Users/gregoriusmarco/gdk/redis/redis.socket[5]> keys *
1) "project:{1}:counters:ProjectStatistics:1:build_artifacts_size"
redis /Users/gregoriusmarco/gdk/redis/redis.socket[5]> get project:{1}:counters:ProjectStatistics:1:build_artifacts_size
"10"
# on redis cluster shared_state
$ redis-cli -p 6001
127.0.0.1:6001> get project:{1}:counters:ProjectStatistics:1:build_artifacts_size
"10"
- Flush counters by running
FlushCounterIncrementsWorker
:
[16] pry(main)> project = Project.first
=> #<Project id:1 toolbox/gitlab-smoke-tests>>
[17] pry(main)> FlushCounterIncrementsWorker.new.perform(project.statistics.class.name, project.statistics.id, :build_artifacts_size)
# check redis
redis /Users/gregoriusmarco/gdk/redis/redis.socket[5]> keys *
(empty array)
127.0.0.1:6001> keys *
1) "gitlab:exclusive_lease:namespace:namespaces_root_statistics:61"
Merge request reports
Activity
assigned to @marcogreg
added pipelinetier-1 label
added backend label
- Resolved by Brian Williams
1 Message CHANGELOG missing: If this merge request needs a changelog entry, add the
Changelog
trailer to the commit message you want to add to the changelog.If this merge request doesn't need a CHANGELOG entry, feel free to ignore this message.
Reviewer roulette
Category Reviewer Maintainer backend @daniel-prause
(UTC+1, 7 hours behind author)
@bwill
(UTC-6, 14 hours behind author)
Please refer to documentation page for guidance on how you can benefit from the Reviewer Roulette, or use the GitLab Review Workload Dashboard to find other available reviewers.
If needed, you can retry the
danger-review
job that generated this comment.Generated by
DangerEdited by ****
- Resolved by 🤖 GitLab Bot 🤖
Proper labels assigned to this merge request. Please ignore me.
@marcogreg
- please see the following guidance and update this merge request.1 Error Please add typebug typefeature, or typemaintenance label to this merge request. Edited by 🤖 GitLab Bot 🤖
added typemaintenance label
changed milestone to %17.10
added 1 commit
- 8d20b60f - Migrate Redis BufferedCounter to Redis SharedState
added 1 commit
- 57a70062 - Migrate Redis BufferedCounter to Redis SharedState
added feature flag groupdurability labels
added devopsdata_access sectioninfrastructure platforms labels
requested review from @daniel-prause
mentioned in issue gitlab-com/gl-infra/data-access/durability/team#71
removed review request for @daniel-prause
added 1 commit
- b4d99d0a - Configure buffered_counter to use standalone redis
added feature flag groupdurability labels
added devopsdata_access sectioninfrastructure platforms labels
- Resolved by Brian Williams
requested review from @daniel-prause
- Resolved by Brian Williams
- Resolved by Brian Williams
- Resolved by Brian Williams
Hey, @marcogreg! Got two comments here for you! Please have a look
requested review from @daniel-prause
added pipeline:mr-approved label
added pipelinetier-2 label and removed pipelinetier-1 label
Before you set this MR to auto-merge
This merge request will progress on pipeline tiers until it reaches the last tier: pipelinetier-3. We will trigger a new pipeline for each transition to a higher tier.
Before you set this MR to auto-merge, please check the following:
- You are the last maintainer of this merge request
- The latest pipeline for this merge request is pipelinetier-3 (You can find which tier it is in the pipeline name)
- This pipeline is recent enough (created in the last 8 hours)
If all the criteria above apply, please set auto-merge for this merge request.
See pipeline tiers and merging a merge request for more details.
E2E Test Result Summary
allure-report-publisher
generated test report!e2e-test-on-gdk:
test report for b4d99d0aexpand test summary
+------------------------------------------------------------------+ | suites summary | +-------------+--------+--------+---------+-------+-------+--------+ | | passed | failed | skipped | flaky | total | result | +-------------+--------+--------+---------+-------+-------+--------+ | Package | 48 | 0 | 28 | 0 | 76 | ✅ | | Create | 261 | 0 | 45 | 0 | 306 | ✅ | | Govern | 152 | 0 | 26 | 0 | 178 | ✅ | | Monitor | 16 | 0 | 24 | 0 | 40 | ✅ | | Ai-powered | 0 | 0 | 4 | 0 | 4 | ➖ | | Fulfillment | 4 | 0 | 14 | 0 | 18 | ✅ | | Data Stores | 66 | 0 | 20 | 0 | 86 | ✅ | | Manage | 2 | 0 | 18 | 0 | 20 | ✅ | | Plan | 159 | 0 | 16 | 0 | 175 | ✅ | | Verify | 97 | 0 | 42 | 0 | 139 | ✅ | | Release | 10 | 0 | 2 | 0 | 12 | ✅ | | Secure | 10 | 0 | 6 | 0 | 16 | ✅ | | Configure | 0 | 0 | 6 | 0 | 6 | ➖ | | Analytics | 4 | 0 | 0 | 0 | 4 | ✅ | | ModelOps | 0 | 0 | 2 | 0 | 2 | ➖ | | Growth | 0 | 0 | 4 | 0 | 4 | ➖ | +-------------+--------+--------+---------+-------+-------+--------+ | Total | 829 | 0 | 257 | 0 | 1086 | ✅ | +-------------+--------+--------+---------+-------+-------+--------+
e2e-test-on-cng:
test report for b4d99d0aexpand test summary
+------------------------------------------------------------------+ | suites summary | +-------------+--------+--------+---------+-------+-------+--------+ | | passed | failed | skipped | flaky | total | result | +-------------+--------+--------+---------+-------+-------+--------+ | Create | 140 | 0 | 22 | 0 | 162 | ✅ | | Verify | 52 | 0 | 20 | 0 | 72 | ✅ | | Data Stores | 33 | 0 | 10 | 0 | 43 | ✅ | | Monitor | 8 | 0 | 12 | 0 | 20 | ✅ | | Package | 29 | 0 | 15 | 0 | 44 | ✅ | | Manage | 1 | 0 | 9 | 0 | 10 | ✅ | | Fulfillment | 2 | 0 | 7 | 0 | 9 | ✅ | | Govern | 84 | 0 | 10 | 0 | 94 | ✅ | | Plan | 86 | 0 | 8 | 0 | 94 | ✅ | | Analytics | 2 | 0 | 0 | 0 | 2 | ✅ | | Secure | 3 | 0 | 5 | 0 | 8 | ✅ | | Configure | 0 | 0 | 3 | 0 | 3 | ➖ | | Release | 5 | 0 | 1 | 0 | 6 | ✅ | | ModelOps | 0 | 0 | 1 | 0 | 1 | ➖ | | Growth | 0 | 0 | 2 | 0 | 2 | ➖ | | Ai-powered | 0 | 0 | 2 | 0 | 2 | ➖ | +-------------+--------+--------+---------+-------+-------+--------+ | Total | 445 | 0 | 127 | 0 | 572 | ✅ | +-------------+--------+--------+---------+-------+-------+--------+
Edited by ****requested review from @bwill
added pipelinetier-3 pipeline:run-e2e-omnibus-once labels and removed pipelinetier-2 label
started a merge train
mentioned in commit 8b0042f1
mentioned in incident gitlab-org/quality/engineering-productivity/master-broken-incidents#10587 (closed)
added workflowstaging-canary label
added workflowcanary label and removed workflowstaging-canary label
added workflowstaging label and removed workflowcanary label
added workflowproduction label and removed workflowstaging label
added workflowpost-deploy-db-production label and removed workflowproduction label