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
0f69fdc0
Commit
0f69fdc0
authored
Feb 04, 2022
by
Marius Bobin
Committed by
Mayra Cabrera
Feb 04, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove dangling running entries from ci running builds table
Changelog: fixed
parent
ee294618
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
78 additions
and
0 deletions
+78
-0
db/post_migrate/20220128155251_remove_dangling_running_builds.rb
..._migrate/20220128155251_remove_dangling_running_builds.rb
+25
-0
db/schema_migrations/20220128155251
db/schema_migrations/20220128155251
+1
-0
spec/migrations/20220128155251_remove_dangling_running_builds_spec.rb
...ons/20220128155251_remove_dangling_running_builds_spec.rb
+52
-0
No files found.
db/post_migrate/20220128155251_remove_dangling_running_builds.rb
0 → 100644
View file @
0f69fdc0
# frozen_string_literal: true
class
RemoveDanglingRunningBuilds
<
Gitlab
::
Database
::
Migration
[
1.0
]
BATCH_SIZE
=
100
disable_ddl_transaction!
def
up
each_batch_range
(
'ci_running_builds'
,
of:
BATCH_SIZE
)
do
|
min
,
max
|
execute
<<~
SQL
DELETE FROM ci_running_builds
USING ci_builds
WHERE ci_builds.id = ci_running_builds.build_id
AND ci_builds.status = 'failed'
AND ci_builds.type = 'Ci::Build'
AND ci_running_builds.id BETWEEN
#{
min
}
AND
#{
max
}
SQL
end
end
def
down
# no-op
# This migration deletes data and it can not be reversed
end
end
db/schema_migrations/20220128155251
0 → 100644
View file @
0f69fdc0
0d121aeecdd6ace1516c2e9b84fefd47d963c4cbe22a0448728241d83da3742e
\ No newline at end of file
spec/migrations/20220128155251_remove_dangling_running_builds_spec.rb
0 → 100644
View file @
0f69fdc0
# frozen_string_literal: true
require
'spec_helper'
require_migration!
(
'remove_dangling_running_builds'
)
RSpec
.
describe
RemoveDanglingRunningBuilds
do
let
(
:namespace
)
{
table
(
:namespaces
).
create!
(
name:
'user'
,
path:
'user'
)
}
let
(
:project
)
{
table
(
:projects
).
create!
(
namespace_id:
namespace
.
id
)
}
let
(
:runner
)
{
table
(
:ci_runners
).
create!
(
runner_type:
1
)
}
let
(
:builds
)
{
table
(
:ci_builds
)
}
let
(
:running_builds
)
{
table
(
:ci_running_builds
)
}
let
(
:running_build
)
do
builds
.
create!
(
name:
'test 1'
,
status:
'running'
,
project_id:
project
.
id
,
type:
'Ci::Build'
)
end
let
(
:failed_build
)
do
builds
.
create!
(
name:
'test 2'
,
status:
'failed'
,
project_id:
project
.
id
,
type:
'Ci::Build'
)
end
let!
(
:running_metadata
)
do
running_builds
.
create!
(
build_id:
running_build
.
id
,
project_id:
project
.
id
,
runner_id:
runner
.
id
,
runner_type:
runner
.
runner_type
)
end
let!
(
:failed_metadata
)
do
running_builds
.
create!
(
build_id:
failed_build
.
id
,
project_id:
project
.
id
,
runner_id:
runner
.
id
,
runner_type:
runner
.
runner_type
)
end
it
'removes failed builds'
do
migrate!
expect
(
running_metadata
.
reload
).
to
be_present
expect
{
failed_metadata
.
reload
}
.
to
raise_error
(
ActiveRecord
::
RecordNotFound
)
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