Compute refresh events behind the compute flags

What does this MR do and why?

The project authorizations refresh queue has only logged and dropped project and user events so far. This lets it recalculate them instead, so it can start taking over from the Sidekiq refreshes, which can lose updates.

Two flags control which events are recalculated, so each can roll out gradually and be turned off quickly:

  • authz_refresh_compute_projects: project changes, checked per project.
  • authz_refresh_compute_memberships: membership and user changes, checked per user. It only applies once the projects flag is on for every project, so the two roll out one after the other.

Neither does anything until authz_refresh_write_path is fully on. That flag moves the old Sidekiq refreshes onto the same row locks, so the old and new writers can't overwrite each other with stale results. Its per-project part is still in !269367 (merged), so these flags must not be enabled before that merges and is fully rolled out.

A recalculation that runs out of time puts its events back with the position it reached, and the next run carries on from there. The old Sidekiq refreshes keep running alongside this until their producers are switched off in later work.

References

Screenshots or screen recordings

Not applicable, no UI change.

How to set up and validate locally

  1. In the Rails console, enable the flags and queue an event for a project:
    Feature.enable(:authz_refresh_write_path)
    Feature.enable(:authz_refresh_compute_projects)
    project = Project.first
    ProjectAuthorization.where(project: project).delete_all
    Authz::ProjectAuthorizations::RefreshEvent.enqueue(:project, [project.id])
    Authz::ProjectAuthorizations::RefreshService.new(Gitlab::Metrics::RuntimeLimiter.new(5.minutes)).execute.payload
  2. The payload shows the event under finished_counts, the project's authorizations are back, and log/application_json.log has a Recalculated project authorization refresh events line with the rows written.

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

🤖 Generated with Claude Code

Merge request reports

Loading
Loading