Skip to content
Snippets Groups Projects

Migrate Redis BufferedCounter to Redis SharedState

Merged Marco (Gregorius) requested to merge mg-migrate-buffered-counter-to-shared-state into master
All threads resolved!

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

  1. Setup Redis Cluster https://gitlab.com/gitlab-org/gitlab-development-kit/-/blob/main/doc/howto/redis_cluster.md
  2. 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
  1. Enable dual write FF:
Feature.enable(:use_primary_and_secondary_stores_for_buffered_counter)
  1. Increment some counter:
ProjectStatistics.increment_statistic(Project.find(1), :build_artifacts_size, Gitlab::Counters::Increment.new(amount: 10))
  1. 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"
  1. 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"
Edited by Marco (Gregorius)

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • requested review from @daniel-prause

  • Daniel P.
  • Daniel P.
  • Daniel P. requested changes

    requested changes

  • requested review from @daniel-prause

  • Daniel P. approved this merge request

    approved this merge request

  • 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: :white_check_mark: test report for b4d99d0a

    expand 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: :white_check_mark: test report for b4d99d0a

    expand 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 ****
  • Brian Williams requested review from @bwill

    requested review from @bwill

  • Brian Williams approved this merge request

    approved this merge request

  • Brian Williams resolved all threads

    resolved all threads

  • Brian Williams enabled automatic add to merge train when checks pass

    enabled automatic add to merge train when checks pass

  • merged

  • Brian Williams mentioned in commit 8b0042f1

    mentioned in commit 8b0042f1

  • added workflowstaging label and removed workflowcanary label

  • Please register or sign in to reply
    Loading