Skip to content

Reduce queries to user_custom_attributes table

What does this MR do and why?

Related to https://gitlab.com/gitlab-org/modelops/anti-abuse/team-tasks/-/issues/503

Context

When User#active_for_authentication? -> User#signup_identity_verified? is executed user_custom_attributes table is queries 5 times.

Screenshot_2024-09-03_at_4.10.33_PM

This contributes to db_duration_s of sign-up (POST RegistrationsController#create) requests which is affecting our SLOs as shown in https://log.gprd.gitlab.net/app/r/s/RfycH:

Screenshot_2024-08-29_at_2.58.53_PM

Change

This MR updates how relevant UserCustomAttribute records are fetched when identity_verification_exempt?, exempt_from_phone_number_verification?, assumed_high_risk?, high_risk?, and medium_risk? methods are called as part of execution of User#active_for_authentication? -> User#signup_identity_verified?.

With this change, user_custom_attributes is only queried once.

Screenshot_2024-09-03_at_5.17.12_PM

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

Numbered steps to set up and validate the change are strongly suggested.

Edited by Eugie Limpin

Merge request reports

Loading