提交 11d6c7e2 编写于 作者: R Rémy Coutable

Merge branch 'sh-fix-issue-55161' into 'master'

Fix failing MySQL spec due to deadlock condition

Closes #55161

See merge request gitlab-org/gitlab-ce!24378
...@@ -23,13 +23,23 @@ module RecordsUploads ...@@ -23,13 +23,23 @@ module RecordsUploads
return unless model return unless model
return unless file && file.exists? return unless file && file.exists?
Upload.transaction do # MySQL InnoDB may encounter a deadlock if a deletion and an
uploads.where(path: upload_path).delete_all # insert is in the same transaction due to its next-key locking
upload.delete if upload # algorithm, so we need to skip the transaction.
# https://gitlab.com/gitlab-org/gitlab-ce/issues/55161#note_131556351
self.upload = build_upload.tap(&:save!) if Gitlab::Database.mysql?
readd_upload
else
Upload.transaction { readd_upload }
end end
end end
def readd_upload
uploads.where(path: upload_path).delete_all
upload.delete if upload
self.upload = build_upload.tap(&:save!)
end
# rubocop: enable CodeReuse/ActiveRecord # rubocop: enable CodeReuse/ActiveRecord
def upload_path def upload_path
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册