summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelipe Artur <felipefac@gmail.com>2019-02-12 16:39:56 -0200
committerFelipe Artur <felipefac@gmail.com>2019-02-12 16:39:56 -0200
commite2aa332504f6cd9eebaa30dfeb71edcea6f9495a (patch)
treeb4282d1ccd9c848ce579bb8483b580ccfe609ee2
parent362d56e65a0e23fcf4fd5bd4535d258c3659ffd5 (diff)
downloadgitlab-ce-e2aa332504f6cd9eebaa30dfeb71edcea6f9495a.tar.gz
Improve batch size
-rw-r--r--app/models/concerns/issuable_states.rb12
-rw-r--r--app/models/merge_request.rb1
-rw-r--r--db/migrate/20190211131150_add_state_id_to_issuables.rb10
3 files changed, 12 insertions, 11 deletions
diff --git a/app/models/concerns/issuable_states.rb b/app/models/concerns/issuable_states.rb
index 7feaf7e8aac..f9f5797065d 100644
--- a/app/models/concerns/issuable_states.rb
+++ b/app/models/concerns/issuable_states.rb
@@ -2,7 +2,7 @@
# == IssuableStates concern
#
-# Defines statuses shared by issuables which are persisted on state column
+# Defines states shared by issuables which are persisted on state_id column
# using the state machine.
#
# Used by EE::Epic, Issue and MergeRequest
@@ -14,10 +14,6 @@ module IssuableStates
# Check MergeRequest::AVAILABLE_STATES
AVAILABLE_STATES = { opened: 1, closed: 2 }.freeze
- included do
- before_save :set_state_id
- end
-
class_methods do
def states
@states ||= OpenStruct.new(self::AVAILABLE_STATES)
@@ -26,7 +22,11 @@ module IssuableStates
# The state:string column is being migrated to state_id:integer column
# This is a temporary hook to populate state_id column with new values
- # and can be removed after the complete migration is done.
+ # and can be removed after the state column is removed.
+ included do
+ before_save :set_state_id
+ end
+
def set_state_id
return if state.nil? || state.empty?
diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb
index 67600383cf9..ece31b359d1 100644
--- a/app/models/merge_request.rb
+++ b/app/models/merge_request.rb
@@ -22,7 +22,6 @@ class MergeRequest < ActiveRecord::Base
self.reactive_cache_lifetime = 10.minutes
SORTING_PREFERENCE_FIELD = :merge_requests_sort
- MERGE_REQUEST_STATES =
AVAILABLE_STATES = AVAILABLE_STATES.merge(merged: 3, locked: 4).freeze
ignore_column :locked_at,
diff --git a/db/migrate/20190211131150_add_state_id_to_issuables.rb b/db/migrate/20190211131150_add_state_id_to_issuables.rb
index b9d52fe63cd..d23c946cf88 100644
--- a/db/migrate/20190211131150_add_state_id_to_issuables.rb
+++ b/db/migrate/20190211131150_add_state_id_to_issuables.rb
@@ -5,10 +5,12 @@ class AddStateIdToIssuables < ActiveRecord::Migration[5.0]
DOWNTIME = false
MIGRATION = 'SyncIssuablesStateId'.freeze
- # TODO - find out how many issues and merge requests in production
- # to adapt the batch size and delay interval
- # Keep in mind that the migration will be scheduled for issues and merge requests.
- BATCH_SIZE = 5000
+ # 2019-02-12 Gitlab.com issuable numbers
+ # issues count: 13587305
+ # merge requests count: 18925274
+ # Using this 50000 as batch size should take around 13 hours
+ # to migrate both issues and merge requests
+ BATCH_SIZE = 50000
DELAY_INTERVAL = 5.minutes.to_i
class Issue < ActiveRecord::Base