Commit b37b191c authored by Krasimir Angelov's avatar Krasimir Angelov

Merge branch 'ab/lock-retries-exception' into 'master'

Raise early and with more helpful message

See merge request gitlab-org/gitlab!70393
parents 2240587d 180b1e93
...@@ -100,6 +100,14 @@ module Gitlab ...@@ -100,6 +100,14 @@ module Gitlab
# * +logger+ - [Gitlab::JsonLogger] # * +logger+ - [Gitlab::JsonLogger]
# * +env+ - [Hash] custom environment hash, see the example with `DISABLE_LOCK_RETRIES` # * +env+ - [Hash] custom environment hash, see the example with `DISABLE_LOCK_RETRIES`
def with_lock_retries(*args, **kwargs, &block) def with_lock_retries(*args, **kwargs, &block)
if transaction_open?
raise <<~EOF
#{__callee__} can not be run inside an already open transaction
Use migration-level lock retries instead, see https://docs.gitlab.com/ee/development/migration_style_guide.html#retry-mechanism-when-acquiring-database-locks
EOF
end
super(*args, **kwargs.merge(allow_savepoints: false), &block) super(*args, **kwargs.merge(allow_savepoints: false), &block)
end end
......
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