Skip to content

Draft: Partition ci_build_trace_metadata table - 4

Marius Bobin requested to merge 469056-third-attempt into master

What does this MR do and why?

We failed to lock job artifacts in !163746 (merged) and the migration is not performed on .com. With this change we're retrying the same migration code from Sidekiq to be attempted multiple times without blocking deployments.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

pgai use -o ci bin/rails c and execute:

[1] pry(main)> s = Gitlab::Database::Partitioning::PartitionBuildTraceMetadata.new; s.execute
  Feature::FlipperGate Pluck (0.7ms)  SELECT "feature_gates"."key", "feature_gates"."value" FROM "feature_gates" WHERE "feature_gates"."feature_key" = 'partition_ci_build_trace_metadata' /*application:console,db_config_name:main,console_hostname:rocket-sled.local,console_username:marius,line:/lib/feature.rb:299:in `block in current_feature_value'*/
=> nil
[2] pry(main)> Feature.enable(:partition_ci_build_trace_metadata)
=> true
[3] pry(main)> s = Gitlab::Database::Partitioning::PartitionBuildTraceMetadata.new; s.execute
  Feature::FlipperGate Pluck (0.3ms)  SELECT "feature_gates"."key", "feature_gates"."value" FROM "feature_gates" WHERE "feature_gates"."feature_key" = 'partition_ci_build_trace_metadata' /*application:console,db_config_name:main,console_hostname:rocket-sled.local,console_username:marius,line:/lib/feature.rb:308:in `block in current_feature_value'*/
  Gitlab::Database::PostgresPartition Exists? (275.3ms)  SELECT 1 AS one FROM "postgres_partitions" WHERE (parent_identifier = concat(current_schema(), '.', 'p_ci_build_trace_metadata')) AND (identifier = concat(current_schema(), '.', 'ci_build_trace_metadata')) LIMIT 1 /*application:console,db_config_name:ci,console_hostname:rocket-sled.local,console_username:marius,line:/lib/gitlab/database/postgres_partition.rb:47:in `partition_exists?'*/
  TRANSACTION (282.6ms)  BEGIN /*application:console,db_config_name:ci,console_hostname:rocket-sled.local,console_username:marius,line:/lib/gitlab/database/with_lock_retries.rb:172:in `execute'*/
   (274.9ms)  SET LOCAL lock_timeout TO '5000ms' /*application:console,db_config_name:ci,console_hostname:rocket-sled.local,console_username:marius,line:/lib/gitlab/database/with_lock_retries.rb:172:in `execute'*/
   (306.6ms)  DROP TABLE "ci_build_trace_metadata" /*application:console,db_config_name:ci,console_hostname:rocket-sled.local,console_username:marius,line:/lib/gitlab/database/partitioning/partition_build_trace_metadata.rb:15:in `block in execute'*/
   (279.2ms)  CREATE TABLE IF NOT EXISTS ci_build_trace_metadata PARTITION OF p_ci_build_trace_metadata FOR VALUES IN (100, 101, 102); /*application:console,db_config_name:ci,console_hostname:rocket-sled.local,console_username:marius,line:/lib/gitlab/database/partitioning/partition_build_trace_metadata.rb:17:in `block in execute'*/
  TRANSACTION (160870.4ms)  COMMIT /*application:console,db_config_name:ci,console_hostname:rocket-sled.local,console_username:marius,line:/lib/gitlab/database.rb:412:in `commit'*/
   (286.6ms)  RESET idle_in_transaction_session_timeout; RESET lock_timeout /*application:console,db_config_name:ci,console_hostname:rocket-sled.local,console_username:marius,line:/lib/gitlab/database/with_lock_retries.rb:172:in `execute'*/
=> true
[4] pry(main)> s = Gitlab::Database::Partitioning::PartitionBuildTraceMetadata.new; s.execute
  Gitlab::Database::PostgresPartition Exists? (207.5ms)  SELECT 1 AS one FROM "postgres_partitions" WHERE (parent_identifier = concat(current_schema(), '.', 'p_ci_build_trace_metadata')) AND (identifier = concat(current_schema(), '.', 'ci_build_trace_metadata')) LIMIT 1 /*application:console,db_config_name:ci,console_hostname:rocket-sled.local,console_username:marius,line:/lib/gitlab/database/postgres_partition.rb:47:in `partition_exists?'*/
=> nil

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

Related to #469056 (closed)

Edited by Marius Bobin

Merge request reports

Loading