Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
3b04a3dc
Commit
3b04a3dc
authored
Apr 20, 2018
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Schedule pipeline stages index background migration
parent
dc89c184
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
65 additions
and
1 deletion
+65
-1
db/post_migrate/20180420080616_schedule_stages_index_migration.rb
...migrate/20180420080616_schedule_stages_index_migration.rb
+29
-0
db/schema.rb
db/schema.rb
+1
-1
spec/migrations/schedule_stages_index_migration_spec.rb
spec/migrations/schedule_stages_index_migration_spec.rb
+35
-0
No files found.
db/post_migrate/20180420080616_schedule_stages_index_migration.rb
0 → 100644
View file @
3b04a3dc
class
ScheduleStagesIndexMigration
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
MIGRATION
=
'MigrateStageIndex'
.
freeze
BATCH_SIZE
=
2000
disable_ddl_transaction!
class
Stage
<
ActiveRecord
::
Base
include
EachBatch
self
.
table_name
=
'ci_stages'
end
def
up
disable_statement_timeout
Stage
.
all
.
tap
do
|
relation
|
queue_background_migration_jobs_by_range_at_intervals
(
relation
,
MIGRATION
,
5
.
minutes
,
batch_size:
BATCH_SIZE
)
end
end
def
down
# noop
end
end
db/schema.rb
View file @
3b04a3dc
...
...
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
201804
18053107
)
do
ActiveRecord
::
Schema
.
define
(
version:
201804
20080616
)
do
# These are extensions that must be enabled in order to support this database
enable_extension
"plpgsql"
...
...
spec/migrations/schedule_stages_index_migration_spec.rb
0 → 100644
View file @
3b04a3dc
require
'spec_helper'
require
Rails
.
root
.
join
(
'db'
,
'post_migrate'
,
'20180420080616_schedule_stages_index_migration'
)
describe
ScheduleStagesIndexMigration
,
:sidekiq
,
:migration
do
let
(
:namespaces
)
{
table
(
:namespaces
)
}
let
(
:projects
)
{
table
(
:projects
)
}
let
(
:pipelines
)
{
table
(
:ci_pipelines
)
}
let
(
:stages
)
{
table
(
:ci_stages
)
}
before
do
stub_const
(
"
#{
described_class
}
::BATCH_SIZE"
,
1
)
namespaces
.
create
(
id:
12
,
name:
'gitlab-org'
,
path:
'gitlab-org'
)
projects
.
create!
(
id:
123
,
namespace_id:
12
,
name:
'gitlab'
,
path:
'gitlab'
)
pipelines
.
create!
(
id:
1
,
project_id:
123
,
ref:
'master'
,
sha:
'adf43c3a'
)
stages
.
create!
(
id:
121
,
project_id:
123
,
pipeline_id:
1
,
name:
'build'
)
stages
.
create!
(
id:
122
,
project_id:
123
,
pipeline_id:
1
,
name:
'test'
)
stages
.
create!
(
id:
123
,
project_id:
123
,
pipeline_id:
1
,
name:
'deploy'
)
end
it
'schedules delayed background migrations in batches'
do
Sidekiq
::
Testing
.
fake!
do
Timecop
.
freeze
do
expect
(
stages
.
all
).
to
all
(
have_attributes
(
index:
be_nil
))
migrate!
expect
(
described_class
::
MIGRATION
).
to
be_scheduled_delayed_migration
(
5
.
minutes
,
121
,
121
)
expect
(
described_class
::
MIGRATION
).
to
be_scheduled_delayed_migration
(
10
.
minutes
,
122
,
122
)
expect
(
described_class
::
MIGRATION
).
to
be_scheduled_delayed_migration
(
15
.
minutes
,
123
,
123
)
expect
(
BackgroundMigrationWorker
.
jobs
.
size
).
to
eq
3
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment