Improve error message for cross join/modification with unknown schema
From @engwan :
Problem
I think the new gitlab_schema thing can be confusing when adding new tables because it can cause lots of job failures with unhelpful messages.
For example, !69299 (merged).
https://gitlab.com/gitlab-org/gitlab/-/jobs/1699767126 has the correct error where it says Any new tables must be added to spec/support/database/gitlab_schemas.yml
.
But the other jobs fail with Cross-database data modification of 'gitlab_main, undefined_member_tasks' were detected within a transaction modifying the 'members, notification_settings, events, user_interacted_projects, member_tasks' tables.Please refer to https://docs.gitlab.com/ee/development/database/multiple_databases.html#removing-cross-database-transactions for details on how to resolve this exception.
.
Could we perhaps tweak the error message here if there are undefined tables?
Solution
If one of the schemas is undefined_
we should add extra detail to say Any new tables must be added to spec/support/database/gitlab_schemas.yml