Skip to content

Utility for detecting cross DB data modification

What does this MR do?

This MR adds spec helper utilities to prevent multi-database data modifications within transactions. This MR is part of the epic: &6168 (closed)

Example:

it 'test', :ci_data_modification_check do
  Issue.transaction do
    issue.touch
    Ci::Pipeline.create() # raises error
  end
end

There can be cases when we need to disable the check:

it 'test', :ci_data_modification_check do
  Gitlab::Database.allow_cross_database_modification_within_transaction(url: '...') do
    Issue.transaction do
      issue.touch
      Ci::Pipeline.create() # no errors
    end
  end
end

Note: the check is disabled by default.

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

Does this MR contain changes to processing or storing of credentials or tokens, authorization and authentication methods or other items described in the security review guidelines? If not, then delete this Security section.

  • 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

Related to #336417 (closed)

Edited by Adam Hegyi

Merge request reports