Defer authorization grants on archived projects to the safety net

What does this MR do and why?

In one root group's role-change burst (Oct 21 to Oct 30), 53% of the 26.4M rows that refreshes added were on archived projects.

Stacked on !267783 (merged), which finds and logs these grants as authorized_projects_refresh.archived_grants_count.

This MR defers grants (new access and access level increases) on archived projects, and lets the safety-net refresh write them at least an hour later. It applies per user, only when the new defer_archived_project_authorization_grants flag and resolve_project_access_from_memberships are both on for that user. For those users:

  • A regular refresh leaves out grants on projects that are archived or under an archived group, and queues the user for reverification. An access level increase keeps the lower row until the safety net runs.
  • Removals and access level decreases still apply at once, so the stored access level is never higher than the real one.
  • The refresh log adds authorized_projects_refresh.rows_deferred_count, so an event shows whether its archived grants were deferred or written.

This is safe because single-project permission checks (point checks) for those users read memberships, not project_authorizations, and archived projects are read-only. A user granted access to an archived project can open it right away.

Known limitations:

  • With the flag on, the safety net cannot tell a grant an earlier refresh missed on an archived project from a deferred one, so it counts both as written deferred grants and the safety-net counter stops counting those misses.
  • ProjectTeam#max_member_access_for_user_ids still reads the table and fills the same request cache as the single-project check. If it runs first in a request, for example while listing participants on an archived project's issue, the newly granted user can be denied for the rest of that request. !260994 (closed) fixes this.

Database

No new query. This MR runs the archived-project lookup from !267783 (merged) for users the deferral applies to as well; plans and timings are in that MR.

References

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.

Edited by Eugie Limpin

Merge request reports

Loading
Loading