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
9a7454de
Commit
9a7454de
authored
Apr 26, 2021
by
Andreas Brandl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Report migrated tuples count in total
Relates to
https://gitlab.com/gitlab-org/gitlab/-/issues/327005
parent
e77edc54
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
0 deletions
+33
-0
lib/gitlab/database/background_migration/batched_migration.rb
...gitlab/database/background_migration/batched_migration.rb
+4
-0
lib/gitlab/database/background_migration/batched_migration_wrapper.rb
...atabase/background_migration/batched_migration_wrapper.rb
+5
-0
spec/lib/gitlab/database/background_migration/batched_migration_spec.rb
...b/database/background_migration/batched_migration_spec.rb
+16
-0
spec/lib/gitlab/database/background_migration/batched_migration_wrapper_spec.rb
...se/background_migration/batched_migration_wrapper_spec.rb
+8
-0
No files found.
lib/gitlab/database/background_migration/batched_migration.rb
View file @
9a7454de
...
...
@@ -64,6 +64,10 @@ module Gitlab
write_attribute
(
:batch_class_name
,
class_name
.
demodulize
)
end
def
migrated_tuple_count
batched_jobs
.
succeeded
.
sum
(
:batch_size
)
end
def
prometheus_labels
@prometheus_labels
||=
{
migration_id:
id
,
...
...
lib/gitlab/database/background_migration/batched_migration_wrapper.rb
View file @
9a7454de
...
...
@@ -65,6 +65,7 @@ module Gitlab
metric_for
(
:gauge_interval
).
set
(
base_labels
,
tracking_record
.
batched_migration
.
interval
)
metric_for
(
:gauge_job_duration
).
set
(
base_labels
,
(
tracking_record
.
finished_at
-
tracking_record
.
started_at
).
to_i
)
metric_for
(
:counter_updated_tuples
).
increment
(
base_labels
,
tracking_record
.
batch_size
)
metric_for
(
:gauge_migrated_tuples
).
set
(
base_labels
,
tracking_record
.
batched_migration
.
migrated_tuple_count
)
metric_for
(
:gauge_total_tuple_count
).
set
(
base_labels
,
tracking_record
.
batched_migration
.
total_tuple_count
)
if
metrics
=
tracking_record
.
metrics
...
...
@@ -106,6 +107,10 @@ module Gitlab
:batched_migration_job_updated_tuples_total
,
'Number of tuples updated by batched migration job'
),
gauge_migrated_tuples:
Gitlab
::
Metrics
.
gauge
(
:batched_migration_migrated_tuples_total
,
'Total number of tuples migrated by a batched migration'
),
histogram_timings:
Gitlab
::
Metrics
.
histogram
(
:batched_migration_job_query_duration_seconds
,
'Query timings for a batched migration job'
,
...
...
spec/lib/gitlab/database/background_migration/batched_migration_spec.rb
View file @
9a7454de
...
...
@@ -204,6 +204,22 @@ RSpec.describe Gitlab::Database::BackgroundMigration::BatchedMigration, type: :m
it_behaves_like
'an attr_writer that demodulizes assigned class names'
,
:batch_class_name
end
describe
'#migrated_tuple_count'
do
subject
{
batched_migration
.
migrated_tuple_count
}
let
(
:batched_migration
)
{
create
(
:batched_background_migration
)
}
before
do
create_list
(
:batched_background_migration_job
,
5
,
status: :succeeded
,
batch_size:
1_000
,
batched_migration:
batched_migration
)
create_list
(
:batched_background_migration_job
,
1
,
status: :running
,
batch_size:
1_000
,
batched_migration:
batched_migration
)
create_list
(
:batched_background_migration_job
,
1
,
status: :failed
,
batch_size:
1_000
,
batched_migration:
batched_migration
)
end
it
'sums the batch_size of succeeded jobs'
do
expect
(
subject
).
to
eq
(
5_000
)
end
end
describe
'#prometheus_labels'
do
let
(
:batched_migration
)
{
create
(
:batched_background_migration
,
job_class_name:
'TestMigration'
,
table_name:
'foo'
,
column_name:
'bar'
)
}
...
...
spec/lib/gitlab/database/background_migration/batched_migration_wrapper_spec.rb
View file @
9a7454de
...
...
@@ -80,6 +80,14 @@ RSpec.describe Gitlab::Database::BackgroundMigration::BatchedMigrationWrapper, '
subject
end
it
'reports migrated tuples'
do
count
=
double
expect
(
job_record
.
batched_migration
).
to
receive
(
:migrated_tuple_count
).
and_return
(
count
)
expect
(
described_class
.
metrics
[
:gauge_migrated_tuples
]).
to
receive
(
:set
).
with
(
labels
,
count
)
subject
end
it
'reports summary of query timings'
do
metrics
=
{
'timings'
=>
{
'update_all'
=>
[
1
,
2
,
3
,
4
,
5
]
}
}
...
...
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