Enable cross-database query check
Hello developers,
If you can encounter this CrossJoinAcrossUnsupportedTablesError
exception in your specs, see the docs on how to remove the join https://docs.gitlab.com/ee/development/database/multiple_databases.html#removing-joins-between-ci_-and-non-ci_-tables
Additionally, for feature specs, you may need to check log/test.log
if asynchronous requests fail with 500 to see if you can spot CrossJoinAcrossUnsupportedTablesError
errors.
What does this MR do?
Enable cross-database query check, while allowing existing cross-database queries to pass. For any new SQL queries that cross databases, specs will now raise a CrossJoinAcrossUnsupportedTablesError
exception
Related issue : #337077 (closed)
The allowlist was generated from CI data with this patch:
config.around do |example|
example.run
capybara_error = Capybara.current_session && Capybara.current_session.server && Capybara.current_session.server.error
has_capybara_error = capybara_error && capybara_error.message.include?("Unsupported cross-join")
has_exception = example.exception && example.exception.message.include?("Unsupported cross-join")
if Thread.current[:has_cross_join_exception] || has_exception || has_capybara_error
# example.location contains location and lineno
File.open(Rails.root.join("log/ci-cross-join-allowlist.log"), 'a') { |f| f.puts(example.location) }
end
end
We then download the CI artifacts using !69032 (closed), and:
mkdir allowlists
cd allowlists
../scripts/api/download_pipeline_artifact.rb -p 278964 --pipeline_id 357551673 -a log/ci-cross-join-allowlist.log
cat *.log | cut -d ":" -f 1 | sort | uniq | ruby -e 'require "yaml"; list=ARGF.read.split("\n"); puts YAML.dump(list)' > unique_files.yml
Screenshots or Screencasts (strongly suggested)
How to setup and validate locally (strongly suggested)
Does this MR meet the acceptance criteria?
Conformity
-
I have included changelog trailers, or none are needed. (Does this MR need a changelog?) -
I have added/updated documentation, or it's not needed. (Is documentation required?) -
I have properly separated EE content from FOSS, or this MR is FOSS only. (Where should EE code go?) -
I have added information for database reviewers in the MR description, or it's not needed. (Does this MR have database related changes?) -
I have self-reviewed this MR per code review guidelines. -
This MR does not harm performance, or I have asked a reviewer to help assess the performance impact. (Merge request performance guidelines) -
I have followed the style guides. -
This change is backwards compatible across updates, or this does not apply.
Availability and Testing
-
I have added/updated tests following the Testing Guide, or it's not needed. (Consider all test levels. See the Test Planning Process.)