Improve batch size
This commit is contained in:
parent
362d56e65a
commit
e2aa332504
3 changed files with 12 additions and 11 deletions
|
@ -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?
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue