File tree 1 file changed +15
-5
lines changed
1 file changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -23,13 +23,23 @@ def record_upload(_tempfile = nil)
23
23
return unless model
24
24
return unless file && file . exists?
25
25
26
- Upload . transaction do
27
- uploads . where ( path : upload_path ) . delete_all
28
- upload . delete if upload
29
-
30
- self . upload = build_upload . tap ( &:save! )
26
+ # MySQL InnoDB may encounter a deadlock if a deletion and an
27
+ # insert is in the same transaction due to its next-key locking
28
+ # algorithm, so we need to skip the transaction.
29
+ # https://gitlab.com/gitlab-org/gitlab-ce/issues/55161#note_131556351
30
+ if Gitlab ::Database . mysql?
31
+ readd_upload
32
+ else
33
+ Upload . transaction { readd_upload }
31
34
end
32
35
end
36
+
37
+ def readd_upload
38
+ uploads . where ( path : upload_path ) . delete_all
39
+ upload . delete if upload
40
+
41
+ self . upload = build_upload . tap ( &:save! )
42
+ end
33
43
# rubocop: enable CodeReuse/ActiveRecord
34
44
35
45
def upload_path
You can’t perform that action at this time.
0 commit comments