Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
989ccd71
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
989ccd71
编写于
9月 25, 2017
作者:
S
Sean McGivern
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Document manual cleanup after background migration stealing
上级
7da72a0d
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
28 addition
and
1 deletion
+28
-1
doc/development/background_migrations.md
doc/development/background_migrations.md
+28
-1
未找到文件。
doc/development/background_migrations.md
浏览文件 @
989ccd71
...
...
@@ -215,14 +215,29 @@ same time will ensure that both existing and new data is migrated.
In the next release we can remove the
`after_commit`
hooks and related code. We
will also need to add a post-deployment migration that consumes any remaining
jobs. Such a migration would look like this:
jobs and manually run on any un-migrated rows. Such a migration would look like
this:
```
ruby
class
ConsumeRemainingExtractServicesUrlJobs
<
ActiveRecord
::
Migration
disable_ddl_transaction!
class
Service
<
ActiveRecord
::
Base
include
::
EachBatch
self
.
table_name
=
'services'
end
def
up
# This must be included
Gitlab
::
BackgroundMigration
.
steal
(
'ExtractServicesUrl'
)
# This should be included, but can be skipped - see below
Service
.
where
(
url:
nil
).
each_batch
(
of:
50
)
do
|
batch
|
range
=
batch
.
pluck
(
'MIN(id)'
,
'MAX(id)'
).
first
Gitlab
::
BackgroundMigration
::
ExtractServicesUrl
.
new
.
perform
(
*
range
)
end
end
def
down
...
...
@@ -230,6 +245,15 @@ class ConsumeRemainingExtractServicesUrlJobs < ActiveRecord::Migration
end
```
The final step runs for any un-migrated rows after all of the jobs have been
processed. This is in case a Sidekiq process running the background migrations
received SIGKILL, leading to the jobs being lost. (See
[
more reliable Sidekiq queue
][
reliable-sidekiq
]
for more information.)
If the application does not depend on the data being 100% migrated (for
instance, the data is advisory, and not mission-critical), then this final step
can be skipped.
This migration will then process any jobs for the ExtractServicesUrl migration
and continue once all jobs have been processed. Once done you can safely remove
the
`services.properties`
column.
...
...
@@ -254,6 +278,9 @@ for more details.
1.
Make sure that background migration jobs are idempotent.
1.
Make sure that tests you write are not false positives.
1.
Make sure that if the data being migrated is critical and cannot be lost, the
clean-up migration also checks the final state of the data before completing.
[
migrations-readme
]:
https://gitlab.com/gitlab-org/gitlab-ce/blob/master/spec/migrations/README.md
[
issue-rspec-hooks
]:
https://gitlab.com/gitlab-org/gitlab-ce/issues/35351
[
reliable-sidekiq
]:
https://gitlab.com/gitlab-org/gitlab-ce/issues/36791
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录