Introduce mechanism to prevent introduction of a new cross-joins across main and CI
Updating GitLab to use a decomposed CI is a moving target. We need to prevent introduction of new features that violate the rule of inability to do cross-join across main and CI while being able to allow some of these constructs to be there until we fix them.
Proposal
- Use
rspec
withpg_query
to discover queries joining main and CI tables - Allow to mark some methods as allowed to perform cross-join and link to issue
class User
def ci_owned_runners
::Gitlab::Database.allow_cross_joins_across_databases(url: "https://gitlab.com/gitlab-org/gitlab/-/issues/336436")
@ci_owned_runners ||= begin
...
end
end
Problems
- Ideally we would use schemas visibility for that, but we are pretty far from that
- A lot of failures today is generated by the lack of
disable_joins:
added - We cannot use
allow_cross_joins_across_databases
withyield
as the check is performed on execution of query, which is done by caller. Doing that withyield
would require all places the given method is used to be marked with the exception.
Edited by Kamil Trzciński