Trying to change Group Path for a group with 5000+ subgroups throws 502

Summary

Trying to change Group Path for a group with 5000+ subgroups having a few projects each throws 502

Steps to reproduce

  1. Login to https://gitlab.com/gitlab-org/gitlab-ce with username gitlab-qa and password from the 1password team vault
  2. Navigate to https://gitlab.com/gitlab-qa-sandbox-group-cleanup-again/-/edit
  3. Expand "Path, transfer, remove"
  4. Change group path from gitlab-qa-sandbox-group-cleanup-again to gitlab-qa-sandbox-group-cleanup-again-2

Example Project

https://gitlab.com/gitlab-qa-sandbox-group-cleanup-again

What is the current bug behavior?

The page with throws 502 when trying to change a group's path

What is the expected correct behavior?

The groups path should change successfully.

Relevant logs and/or screenshots

(Paste any relevant logs - please use code blocks (```) to format console output, logs, and code as it's very hard to read otherwise.)

Output of checks

This bug happens on GitLab.com

Edited by Sanad Liaquat