Skip to content

Resolve "[DevOps Adoption] Daily updates" - part 1

Pavel Shutsin requested to merge 292516-daily-updates-for-devops-adoption into master

What does this MR do?

Previously we were using recorded_at for "when" snapshot was recorded and "what" is snapshot range. However those are different concepts and can be different, so new column separates the concepts.

Migration output

== 20201221124036 AddDevopsSnapshotIndex: reverting ===========================
-- transaction_open?()
   -> 0.0000s
-- indexes(:analytics_devops_adoption_snapshots)
   -> 0.0074s
-- remove_index(:analytics_devops_adoption_snapshots, {:algorithm=>:concurrently, :name=>"index_on_snapshots_segment_id_end_time"})
   -> 0.0041s
== 20201221124036 AddDevopsSnapshotIndex: reverted (0.0132s) ==================

== 20201216185336 AddDevopsAdoptionSnapshotNotNull: reverting =================
-- execute("ALTER TABLE analytics_devops_adoption_snapshots ALTER COLUMN end_time DROP NOT NULL;\n")
   -> 0.0019s
== 20201216185336 AddDevopsAdoptionSnapshotNotNull: reverted (0.0133s) ========

== 20201216154457 AddDevopsAdoptionSnapshotRangeEnd: reverting ================
-- remove_column(:analytics_devops_adoption_snapshots, :end_time)
   -> 0.0029s
== 20201216154457 AddDevopsAdoptionSnapshotRangeEnd: reverted (0.0029s) =======

== 20201216154457 AddDevopsAdoptionSnapshotRangeEnd: migrating ================
-- add_column(:analytics_devops_adoption_snapshots, :end_time, :datetime_with_timezone)
   -> 0.0030s
== 20201216154457 AddDevopsAdoptionSnapshotRangeEnd: migrated (0.0031s) =======

== 20201216185336 AddDevopsAdoptionSnapshotNotNull: migrating =================
-- execute("LOCK TABLE analytics_devops_adoption_snapshots IN ACCESS EXCLUSIVE MODE;\n\nUPDATE analytics_devops_adoption_snapshots SET end_time = date_trunc('month', recorded_at) - interval '1 millisecond';\n\nALTER TABLE analytics_devops_adoption_snapshots ALTER COLUMN end_time SET NOT NULL;\n")
   -> 0.0035s
== 20201216185336 AddDevopsAdoptionSnapshotNotNull: migrated (0.0137s) ========

== 20201221124036 AddDevopsSnapshotIndex: migrating ===========================
-- transaction_open?()
   -> 0.0000s
-- index_exists?(:analytics_devops_adoption_snapshots, [:segment_id, :end_time], {:name=>"index_on_snapshots_segment_id_end_time", :algorithm=>:concurrently})
   -> 0.0053s
-- add_index(:analytics_devops_adoption_snapshots, [:segment_id, :end_time], {:name=>"index_on_snapshots_segment_id_end_time", :algorithm=>:concurrently})
   -> 0.0101s
== 20201221124036 AddDevopsSnapshotIndex: migrated (0.0169s) ==================

Data migration details

With current behavior (20 segments per instance limit) there might be up to 240 records per year in snapshots table. Snapshots feature was introduced in %13.7 so it's safe to say that there will be very low number of rows in DB => safe to migrate in sync.

Explains

https://explain.depesz.com/s/oiQX

Screenshots (strongly suggested)

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team

Related to #292516 (closed)

Edited by Pavel Shutsin

Merge request reports