Skip to content

Ci::RetryBuildService causes CrossDatabaseModificationAcrossUnsupportedTablesError due to `deployments`

Per https://docs.gitlab.com/ee/development/database/multiple_databases.html#removing-cross-database-transactions we do not allow you to write to 2 different databases within the context of a single transaction. This problem occurs at https://gitlab.com/gitlab-org/gitlab/-/blob/ce2742230d134220abccfe87af78b3b864883799/app/services/ci/retry_build_service.rb#L45 which writes to ["ci_builds", "ci_builds_metadata", "deployments"] in a single transaction.

Possible solutions

This is likely a similar problem with the same or similar fix as #345448 (closed) .

See https://docs.gitlab.com/ee/development/database/multiple_databases.html#removing-cross-database-transactions .

Validating a fix

This problem causes us to add (at least) ee/spec/services/ci/retry_build_service_spec.rb to the cross modification allowlist and as such a fix should allow us to remove it from the allowlist. There may be some other cross-modification failures or false positives in the spec that we need to workaround to see and fix this failure.

Edited by Kamil Trzciński