diff options
author | Rémy Coutable <remy@rymai.me> | 2017-06-19 17:44:49 +0000 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2017-06-19 17:44:49 +0000 |
commit | 8a3f886b5be0ee678b09e01b2db03b7279ee6cab (patch) | |
tree | 0625dc503bffa10b1c034cad56adaed0b9e46696 | |
parent | 5544d2b38eb7ac5cb355830aa03a7e758888eb74 (diff) | |
parent | 9a3bea6707eba7451501a1aa860791de7fbf931e (diff) | |
download | gitlab-ce-8a3f886b5be0ee678b09e01b2db03b7279ee6cab.tar.gz |
Merge branch 'update-column-in-batches-batch-size' into 'master'
Put an upper limit on update batches
See merge request !12265
-rw-r--r-- | lib/gitlab/database/migration_helpers.rb | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/gitlab/database/migration_helpers.rb b/lib/gitlab/database/migration_helpers.rb index cd85f961242..9181202a091 100644 --- a/lib/gitlab/database/migration_helpers.rb +++ b/lib/gitlab/database/migration_helpers.rb @@ -233,6 +233,12 @@ module Gitlab # Update in batches of 5% until we run out of any rows to update. batch_size = ((total / 100.0) * 5.0).ceil + max_size = 1000 + + # The upper limit is 1000 to ensure we don't lock too many rows. For + # example, for "merge_requests" even 1% of the table is around 35 000 + # rows for GitLab.com. + batch_size = max_size if batch_size > max_size start_arel = table.project(table[:id]).order(table[:id].asc).take(1) start_arel = yield table, start_arel if block_given? |