Fix lookup of namespace by pages host
What does this MR do?
With !25585 (merged) we tried to optimize lookup for namespace domains by using Namespace.find_by_path
instead of Namespace.find_by_full_path
with the assumption we only deal with top level domains for Pages subdomains.
Unfortunately if you have subgroup with same path as top level group it may be picked up instead - if we look for bar.gitlab.io
we'll query for path='bar'
and it can return subgroup foo/bar
.
This MR updates find_by_full_path to where("parent_id is null")
.find_by_path(name)to ensure we returnonly top-level domains. Alternatively we can go back to
find_by_full_pathbut there really no need to join with
routes`.
Execution plan for the query before - https://explain.depesz.com/s/VECi.
Execution plan for the query after - https://explain.depesz.com/s/KxUW.
I think at this point we do not need specialized index on (path) WHERE parent_id IS NULL
but will keep an eye to the endpoint once we rollback the Pages API again.
Screenshots
Does this MR meet the acceptance criteria?
Conformity
-
Changelog entry -
Documentation (if required) -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers -
Informed Infrastructure department of a default or new setting change, if applicable per definition of done
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
-
Label as security and @ mention @gitlab-com/gl-security/appsec
-
The MR includes necessary changes to maintain consistency between UI, API, email, or other methods -
Security reports checked/validated by a reviewer from the AppSec team