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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
e11ba41a
Commit
e11ba41a
authored
Sep 06, 2021
by
Thong Kuah
Committed by
Yorick Peterse
Sep 06, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix migrate_in not working within a transaction
Co-Authored-By:
Yorick Peterse
<
yorick@yorickpeterse.com
>
parent
05dced7b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
23 deletions
+27
-23
db/post_migrate/20210901153324_slice_merge_request_diff_commit_migrations.rb
...10901153324_slice_merge_request_diff_commit_migrations.rb
+27
-23
No files found.
db/post_migrate/20210901153324_slice_merge_request_diff_commit_migrations.rb
View file @
e11ba41a
...
@@ -3,6 +3,8 @@
...
@@ -3,6 +3,8 @@
class
SliceMergeRequestDiffCommitMigrations
<
ActiveRecord
::
Migration
[
6.1
]
class
SliceMergeRequestDiffCommitMigrations
<
ActiveRecord
::
Migration
[
6.1
]
include
Gitlab
::
Database
::
MigrationHelpers
include
Gitlab
::
Database
::
MigrationHelpers
disable_ddl_transaction!
BATCH_SIZE
=
5_000
BATCH_SIZE
=
5_000
MIGRATION_CLASS
=
'MigrateMergeRequestDiffCommitUsers'
MIGRATION_CLASS
=
'MigrateMergeRequestDiffCommitUsers'
STEAL_MIGRATION_CLASS
=
'StealMigrateMergeRequestDiffCommitUsers'
STEAL_MIGRATION_CLASS
=
'StealMigrateMergeRequestDiffCommitUsers'
...
@@ -15,31 +17,33 @@ class SliceMergeRequestDiffCommitMigrations < ActiveRecord::Migration[6.1]
...
@@ -15,31 +17,33 @@ class SliceMergeRequestDiffCommitMigrations < ActiveRecord::Migration[6.1]
return
if
old_jobs
.
empty?
return
if
old_jobs
.
empty?
# This ensures we stop processing the old ranges, as the background
transaction
do
# migrations skip already processed jobs.
# This ensures we stop processing the old ranges, as the background
Gitlab
::
Database
::
BackgroundMigrationJob
# migrations skip already processed jobs.
.
for_migration_class
(
MIGRATION_CLASS
)
Gitlab
::
Database
::
BackgroundMigrationJob
.
pending
.
for_migration_class
(
MIGRATION_CLASS
)
.
update_all
(
status: :succeeded
)
.
pending
.
update_all
(
status: :succeeded
)
rows
=
[]
rows
=
[]
old_jobs
.
each
do
|
job
|
min
,
max
=
job
.
arguments
old_jobs
.
each
do
|
job
|
min
,
max
=
job
.
arguments
while
min
<
max
rows
<<
{
while
min
<
max
class_name:
MIGRATION_CLASS
,
rows
<<
{
arguments:
[
min
,
min
+
BATCH_SIZE
],
class_name:
MIGRATION_CLASS
,
created_at:
Time
.
now
.
utc
,
arguments:
[
min
,
min
+
BATCH_SIZE
],
updated_at:
Time
.
now
.
utc
created_at:
Time
.
now
.
utc
,
}
updated_at:
Time
.
now
.
utc
}
min
+=
BATCH_SIZE
min
+=
BATCH_SIZE
end
end
end
end
Gitlab
::
Database
::
BackgroundMigrationJob
.
insert_all!
(
rows
)
Gitlab
::
Database
::
BackgroundMigrationJob
.
insert_all!
(
rows
)
end
job
=
Gitlab
::
Database
::
BackgroundMigrationJob
job
=
Gitlab
::
Database
::
BackgroundMigrationJob
.
for_migration_class
(
MIGRATION_CLASS
)
.
for_migration_class
(
MIGRATION_CLASS
)
...
...
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