Skip to content

Revert "Merge branch 'hide-merge-requests-from-banned-users' into 'master'"

Hinam Mehra requested to merge revert-fe11d230 into master

What does this MR do and why?

  1. Follow-up from an incident gitlab-com/gl-infra/production#8160 (closed), which was resulting in 500 errors when users were trying to load the QA group in production canary
  2. Since the query where.not(author_id: Users::BannedUser.all.select(:user_id)) was moved from the Issue model to the Issuable model, it was causing SQL timeouts for MR and Project related queries, eg.
/*application:web,correlation_id:01GM9KRSJ5PDG95S5MEEQQ8C64,endpoint_id:GroupsController#show,db_config_name:main_replica*/ SELECT COUNT(*) FROM "merge_requests" INNER JOIN "projects" ON "projects"."id" = "merge_requests"."target_project_id" LEFT JOIN project_features ON projects.id = project_features.project_id WHERE "merge_requests"."author_id" NOT IN (SELECT "banned_users"."user_id" FROM "banned_users") AND "projects"."namespace_id" IN (SELECT namespaces.traversal_ids[array_length(namespaces.traversal_ids, $1)] AS id FROM "namespaces" WHERE "namespaces"."type" = $2 AND (traversal_ids @> ($3))) AND (EXISTS (SELECT $4 FROM "project_authorizations" WHERE "project_authorizations"."user_id" = $5 AND (project_authorizations.project_id = projects.id) AND (project_authorizations.access_level >= $6)) OR projects.visibility_level IN ($7,$8)) AND ("project_features"."merge_requests_access_level" IS NULL OR "project_features"."merge_requests_access_level" IN ($9,$10) OR ("project_features"."merge_requests_access_level" = $11 AND EXISTS (SELECT $12 FROM "project_authorizations" WHERE "project_authorizations"."user_id" = $13 AND (project_authorizations.project_id = project_features.project_id) AND (project_authorizations.access_level >= $14)))) AND ("merge_requests"."state_id" IN ($15)) AND "projects"."archived" = $16
  1. We noticed that when we turned off the ban_user_feature_flag, the 500s resolved themselves. I believe this is because the NOT IN query isn't very efficient and since we were looping through the banned_users table, it was causing SQL timeouts.
  2. There is also a related issue to the performance of this query, #383552 (closed)

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

How to set up and validate locally

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

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Hinam Mehra

Merge request reports