Commit e828ba69 authored by Dylan Griffith's avatar Dylan Griffith Committed by Adam Hegyi

Ignore plans and gitlab_subscriptions in cross modification check

Read more at https://gitlab.com/gitlab-org/gitlab/-/issues/343394 .

We are regularly seeing
CrossDatabaseModificationAcrossUnsupportedTablesError failures when we
call
[`Plan.default`](https://gitlab.com/gitlab-org/gitlab/-/blob/ad0085ce21be8d39b7598cb124adee7c75405922/app/models/plan.rb#L13)
and/or
[`Namespace#actual_plan`](https://gitlab.com/gitlab-org/gitlab/blob/master/ee/app/models/ee/namespace.rb#L180)
because both of these methods are lazily creating records.

At present we believe this is not strictly a problem that we need to
solve since it will is likely totally OK that creating a `plans` record
in the middle of a transaction related to `ci_pipelines` is not
important to rollback. Even more these lazy creations likely never need
to be rolled back anyway so we probably don't need to push these outside
the transactions.
parent 6878d092
......@@ -378,7 +378,6 @@
- "./ee/spec/models/ci/build_spec.rb"
- "./ee/spec/models/ci/minutes/additional_pack_spec.rb"
- "./ee/spec/models/ci/pipeline_spec.rb"
- "./ee/spec/models/ci/subscriptions/project_spec.rb"
- "./ee/spec/models/concerns/approval_rule_like_spec.rb"
- "./ee/spec/models/concerns/approver_migrate_hook_spec.rb"
- "./ee/spec/models/dora/daily_metrics_spec.rb"
......
......@@ -84,6 +84,11 @@ module Database
parsed_query = PgQuery.parse(sql)
tables = sql.downcase.include?(' for update') ? parsed_query.tables : parsed_query.dml_tables
# We have some code where plans and gitlab_subscriptions are lazily
# created and this causes lots of spec failures
# https://gitlab.com/gitlab-org/gitlab/-/issues/343394
tables -= %w[plans gitlab_subscriptions]
return if tables.empty?
cross_database_context[:modified_tables_by_db][database].merge(tables)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment