Commit 0bff6c12 authored by Patrick Bair's avatar Patrick Bair

Merge branch 'ab/track-bloat' into 'master'

Track index bloat estimate

See merge request gitlab-org/gitlab!49822
parents 4f35e055 1395fe27
---
title: Track index bloat estimate
merge_request: 49822
author:
type: other
# frozen_string_literal: true
class AddBloatEstimateToReindexAction < ActiveRecord::Migration[6.0]
DOWNTIME = false
def change
add_column :postgres_reindex_actions, :bloat_estimate_bytes_start, :bigint
end
end
ecf6b392f35bb0ef905144a4605bcb927ce767240e47ec3b0653a94139b987bd
\ No newline at end of file
...@@ -15216,6 +15216,7 @@ CREATE TABLE postgres_reindex_actions ( ...@@ -15216,6 +15216,7 @@ CREATE TABLE postgres_reindex_actions (
ondisk_size_bytes_end bigint, ondisk_size_bytes_end bigint,
state smallint DEFAULT 0 NOT NULL, state smallint DEFAULT 0 NOT NULL,
index_identifier text NOT NULL, index_identifier text NOT NULL,
bloat_estimate_bytes_start bigint,
CONSTRAINT check_f12527622c CHECK ((char_length(index_identifier) <= 255)) CONSTRAINT check_f12527622c CHECK ((char_length(index_identifier) <= 255))
); );
......
...@@ -18,7 +18,8 @@ module Gitlab ...@@ -18,7 +18,8 @@ module Gitlab
action = create!( action = create!(
index_identifier: index.identifier, index_identifier: index.identifier,
action_start: Time.zone.now, action_start: Time.zone.now,
ondisk_size_bytes_start: index.ondisk_size_bytes ondisk_size_bytes_start: index.ondisk_size_bytes,
bloat_estimate_bytes_start: index.bloat_size
) )
yield yield
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe Gitlab::Database::Reindexing::ReindexAction, '.keep_track_of' do RSpec.describe Gitlab::Database::Reindexing::ReindexAction, '.keep_track_of' do
let(:index) { double('index', identifier: 'public.something', ondisk_size_bytes: 10240, reload: nil) } let(:index) { double('index', identifier: 'public.something', ondisk_size_bytes: 10240, reload: nil, bloat_size: 42) }
let(:size_after) { 512 } let(:size_after) { 512 }
it 'yields to the caller' do it 'yields to the caller' do
...@@ -47,6 +47,12 @@ RSpec.describe Gitlab::Database::Reindexing::ReindexAction, '.keep_track_of' do ...@@ -47,6 +47,12 @@ RSpec.describe Gitlab::Database::Reindexing::ReindexAction, '.keep_track_of' do
expect(find_record.ondisk_size_bytes_end).to eq(size_after) expect(find_record.ondisk_size_bytes_end).to eq(size_after)
end end
it 'creates the record with the indexes bloat estimate' do
described_class.keep_track_of(index) do
expect(find_record.bloat_estimate_bytes_start).to eq(index.bloat_size)
end
end
context 'in case of errors' do context 'in case of errors' do
it 'sets the state to failed' do it 'sets the state to failed' do
expect do expect do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment