Skip to content

Create ci_runners_e59bb2812d partitioned table

NOTE: Even though we found that some records miss the sharding key in the source table (see Delete project and group runners belonging to n... (#498019 - closed) for context), I'm planning to move forward with this and only copy the valid records to the new table (which should be the default behavior by looking at the migration code)

What does this MR do and why?

This MR is the second part of a series of 3 MRs:

Number MR description
1 !165992 (merged) Implements the Gitlab::Database::PartitioningMigrationHelpers::TableManagementHelpers#partition_table_by_list method, which will allow tables such as ci_runners to be partitioned by an existing column (runner_type in that case).
2 !166308 (merged) Uses the new partition_table_by_list method to create the ci_runners_e59bb2812d partitioned table.
3 !166520 (merged) Backfills the new ci_runners_e59bb2812d table from ci_runners (ignores group/project runners that don't have a sharding_key_id).

Changelog: added

Part of #500447 (closed) and #442395

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

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Migration
$ be rails db:migrate:redo:ci VERSION=20241002082113
Running via Spring preloader in process 96746
ci: == [advisory_lock_connection] object_id: 501980, pg_backend_pid: 96765
ci: == 20241002082113 CreatePartitionedCiRunners: reverting =======================
ci: -- transaction_open?(nil)
ci:    -> 0.0000s
ci: -- transaction_open?(nil)
ci:    -> 0.0000s
ci: -- execute("DROP TRIGGER IF EXISTS table_sync_trigger_61879721b5 ON ci_runners")
ci:    -> 0.0011s
ci: -- execute("DROP FUNCTION IF EXISTS table_sync_function_686d6c7993()")
ci:    -> 0.0007s
ci: -- drop_table("ci_runners_e59bb2812d")
ci:    -> 0.0501s
ci: == 20241002082113 CreatePartitionedCiRunners: reverted (0.2399s) ==============

ci: == [advisory_lock_connection] object_id: 501980, pg_backend_pid: 96765
ci: == [advisory_lock_connection] object_id: 503960, pg_backend_pid: 96807
ci: == 20241002082113 CreatePartitionedCiRunners: migrating =======================
ci: -- transaction_open?(nil)
ci:    -> 0.0000s
ci: -- transaction_open?(nil)
ci:    -> 0.0000s
ci: -- create_table("ci_runners_e59bb2812d", {:primary_key=>["id", "runner_type"], :options=>"PARTITION BY LIST (runner_type)"})
ci: -- quote_column_name(:name)
ci:    -> 0.0000s
ci: -- quote_column_name(:token_encrypted)
ci:    -> 0.0000s
ci: -- quote_column_name(:token)
ci:    -> 0.0000s
ci: -- quote_column_name(:description)
ci:    -> 0.0000s
ci: -- quote_column_name(:maintainer_note)
ci:    -> 0.0000s
ci:    -> 0.0749s
ci: -- current_schema(nil)
ci:    -> 0.0014s
ci: -- current_schema(nil)
ci:    -> 0.0019s
ci: -- execute("CREATE TABLE public.instance_type_ci_runners_e59bb2812d PARTITION OF ci_runners_e59bb2812d\nFOR VALUES IN (1)\n")
ci:    -> 0.0390s
ci: -- current_schema(nil)
ci:    -> 0.0005s
ci: -- current_schema(nil)
ci:    -> 0.0012s
ci: -- execute("CREATE TABLE public.group_type_ci_runners_e59bb2812d PARTITION OF ci_runners_e59bb2812d\nFOR VALUES IN (2)\n")
ci:    -> 0.0246s
ci: -- current_schema(nil)
ci:    -> 0.0009s
ci: -- current_schema(nil)
ci:    -> 0.0017s
ci: -- execute("CREATE TABLE public.project_type_ci_runners_e59bb2812d PARTITION OF ci_runners_e59bb2812d\nFOR VALUES IN (3)\n")
ci:    -> 0.0220s
ci: -- execute("CREATE  FUNCTION table_sync_function_686d6c7993()\nRETURNS TRIGGER AS\n$$\nBEGIN\nIF (TG_OP = 'DELETE') THEN\n  DELETE FROM ci_runners_e59bb2812d where \"id\" = OLD.\"id\";\nELSIF (TG_OP = 'UPDATE') THEN\n  UPDATE ci_runners_e59bb2812d\n  SET \"creator_id\" = NEW.\"creator_id\",\n    \"sharding_key_id\" = NEW.\"sharding_key_id\",\n    \"created_at\" = NEW.\"created_at\",\n    \"updated_at\" = NEW.\"updated_at\",\n    \"contacted_at\" = NEW.\"contacted_at\",\n    \"token_expires_at\" = NEW.\"token_expires_at\",\n    \"public_projects_minutes_cost_factor\" = NEW.\"public_projects_minutes_cost_factor\",\n    \"private_projects_minutes_cost_factor\" = NEW.\"private_projects_minutes_cost_factor\",\n    \"access_level\" = NEW.\"access_level\",\n    \"maximum_timeout\" = NEW.\"maximum_timeout\",\n    \"runner_type\" = NEW.\"runner_type\",\n    \"registration_type\" = NEW.\"registration_type\",\n    \"creation_state\" = NEW.\"creation_state\",\n    \"active\" = NEW.\"active\",\n    \"run_untagged\" = NEW.\"run_untagged\",\n    \"locked\" = NEW.\"locked\",\n    \"name\" = NEW.\"name\",\n    \"token_encrypted\" = NEW.\"token_encrypted\",\n    \"token\" = NEW.\"token\",\n    \"description\" = NEW.\"description\",\n    \"maintainer_note\" = NEW.\"maintainer_note\",\n    \"allowed_plans\" = NEW.\"allowed_plans\",\n    \"allowed_plan_ids\" = NEW.\"allowed_plan_ids\"\n  WHERE ci_runners_e59bb2812d.\"id\" = NEW.\"id\";\nELSIF (TG_OP = 'INSERT') THEN\n  INSERT INTO ci_runners_e59bb2812d (\"id\",\n    \"creator_id\",\n    \"sharding_key_id\",\n    \"created_at\",\n    \"updated_at\",\n    \"contacted_at\",\n    \"token_expires_at\",\n    \"public_projects_minutes_cost_factor\",\n    \"private_projects_minutes_cost_factor\",\n    \"access_level\",\n    \"maximum_timeout\",\n    \"runner_type\",\n    \"registration_type\",\n    \"creation_state\",\n    \"active\",\n    \"run_untagged\",\n    \"locked\",\n    \"name\",\n    \"token_encrypted\",\n    \"token\",\n    \"description\",\n    \"maintainer_note\",\n    \"allowed_plans\",\n    \"allowed_plan_ids\")\n  VALUES (NEW.\"id\",\n    NEW.\"creator_id\",\n    NEW.\"sharding_key_id\",\n    NEW.\"created_at\",\n    NEW.\"updated_at\",\n    NEW.\"contacted_at\",\n    NEW.\"token_expires_at\",\n    NEW.\"public_projects_minutes_cost_factor\",\n    NEW.\"private_projects_minutes_cost_factor\",\n    NEW.\"access_level\",\n    NEW.\"maximum_timeout\",\n    NEW.\"runner_type\",\n    NEW.\"registration_type\",\n    NEW.\"creation_state\",\n    NEW.\"active\",\n    NEW.\"run_untagged\",\n    NEW.\"locked\",\n    NEW.\"name\",\n    NEW.\"token_encrypted\",\n    NEW.\"token\",\n    NEW.\"description\",\n    NEW.\"maintainer_note\",\n    NEW.\"allowed_plans\",\n    NEW.\"allowed_plan_ids\");\nEND IF;\nRETURN NULL;\n\nEND\n$$ LANGUAGE PLPGSQL\n")
ci:    -> 0.0222s
ci: -- execute("COMMENT ON FUNCTION table_sync_function_686d6c7993 IS 'Partitioning migration: table sync for ci_runners table'")
ci:    -> 0.0115s
ci: -- current_schema(nil)
ci:    -> 0.0117s
ci: -- execute("CREATE TRIGGER table_sync_trigger_61879721b5\nAFTER INSERT OR UPDATE OR DELETE ON ci_runners\nFOR EACH ROW\n\nEXECUTE FUNCTION table_sync_function_686d6c7993()\n")
ci:    -> 0.0071s
ci: -- transaction_open?(nil)
ci:    -> 0.0000s
ci: -- transaction_open?(nil)
ci:    -> 0.0000s
ci: -- execute("ALTER TABLE ci_runners_e59bb2812d\nADD CONSTRAINT check_sharding_key_id_nullness\nCHECK ( (runner_type = 1 AND sharding_key_id IS NULL) OR (runner_type <> 1 AND sharding_key_id IS NOT NULL) )\nNOT VALID;\n")
ci:    -> 0.0092s
ci: == 20241002082113 CreatePartitionedCiRunners: migrated (0.6099s) ==============

ci: == [advisory_lock_connection] object_id: 503960, pg_backend_pid: 96807
ci_runners_e59bb2812d schema
gitlabhq_development_ci> \d+ ci_runners_e59bb2812d
+--------------------------------------+--------------------------+----------------------------------+----------+
| Column                               | Type                     | Modifiers                        | Storage  |
|--------------------------------------+--------------------------+----------------------------------+----------|
| id                                   | bigint                   |  not null                        | plain    |
| creator_id                           | bigint                   |                                  | plain    |
| sharding_key_id                      | bigint                   |                                  | plain    |
| created_at                           | timestamp with time zone |                                  | plain    |
| updated_at                           | timestamp with time zone |                                  | plain    |
| contacted_at                         | timestamp with time zone |                                  | plain    |
| token_expires_at                     | timestamp with time zone |                                  | plain    |
| public_projects_minutes_cost_factor  | double precision         |  not null default 1.0            | plain    |
| private_projects_minutes_cost_factor | double precision         |  not null default 1.0            | plain    |
| access_level                         | integer                  |  not null default 0              | plain    |
| maximum_timeout                      | integer                  |                                  | plain    |
| runner_type                          | smallint                 |  not null                        | plain    |
| registration_type                    | smallint                 |  not null default 0              | plain    |
| creation_state                       | smallint                 |  not null default 0              | plain    |
| active                               | boolean                  |  not null default true           | plain    |
| run_untagged                         | boolean                  |  not null default true           | plain    |
| locked                               | boolean                  |  not null default false          | plain    |
| name                                 | text                     |                                  | extended |
| token_encrypted                      | text                     |                                  | extended |
| token                                | text                     |                                  | extended |
| description                          | text                     |                                  | extended |
| maintainer_note                      | text                     |                                  | extended |
| allowed_plans                        | text[]                   |  not null default '{}'::text[]   | extended |
| allowed_plan_ids                     | bigint[]                 |  not null default '{}'::bigint[] | extended |
+--------------------------------------+--------------------------+----------------------------------+----------+
Indexes:
    "ci_runners_e59bb2812d_pkey" PRIMARY KEY, btree (id, runner_type)
    "idx_uniq_ci_runners_e59bb2812d_on_token_and_type_where_not_null" UNIQUE, btree (token, runner_type) WHERE token IS NOT NULL
    "index_uniq_ci_runners_e59bb2812d_on_token_encrypted_and_type" UNIQUE, btree (token_encrypted, runner_type)
    "idx_ci_runners_e59bb2812d_on_contacted_at_and_id_where_inactive" btree (contacted_at DESC, id DESC) WHERE active = false
    "idx_ci_runners_e59bb2812d_on_token_expires_at_desc_and_id_desc" btree (token_expires_at DESC, id DESC)
    "index_ci_runners_e59bb2812d_on_active_and_id" btree (active, id)
    "index_ci_runners_e59bb2812d_on_contacted_at_and_id_desc" btree (contacted_at, id DESC)
    "index_ci_runners_e59bb2812d_on_contacted_at_desc_and_id_desc" btree (contacted_at DESC, id DESC)
    "index_ci_runners_e59bb2812d_on_created_at_and_id_desc" btree (created_at, id DESC)
    "index_ci_runners_e59bb2812d_on_created_at_and_id_where_inactive" btree (created_at DESC, id DESC) WHERE active = false
    "index_ci_runners_e59bb2812d_on_created_at_desc_and_id_desc" btree (created_at DESC, id DESC)
    "index_ci_runners_e59bb2812d_on_creator_id_where_not_null" btree (creator_id) WHERE creator_id IS NOT NULL
    "index_ci_runners_e59bb2812d_on_description_trigram" gin (description gin_trgm_ops)
    "index_ci_runners_e59bb2812d_on_locked" btree (locked)
    "index_ci_runners_e59bb2812d_on_sharding_key_id_where_not_null" btree (sharding_key_id) WHERE sharding_key_id IS NOT NULL
    "index_ci_runners_e59bb2812d_on_token_expires_at_and_id_desc" btree (token_expires_at, id DESC)
Check constraints:
    "check_1f8618ab23" CHECK (char_length(name) <= 256)
    "check_24b281f5bf" CHECK (char_length(maintainer_note) <= 1024)
    "check_31c16b2a99" CHECK (char_length(token_encrypted) <= 128)
    "check_5db8ae9d30" CHECK (char_length(description) <= 1024)
    "check_af25130d5a" CHECK (char_length(token) <= 128)
    "check_sharding_key_id_nullness" CHECK (runner_type = 1 AND sharding_key_id IS NULL OR runner_type <> 1 AND sharding_key_id IS NOT NULL) NOT VALID
Partition key: LIST (runner_type)
Partitions: public.group_type_ci_runners_e59bb2812d FOR VALUES IN ('2')
            public.instance_type_ci_runners_e59bb2812d FOR VALUES IN ('1')
            public.project_type_ci_runners_e59bb2812d FOR VALUES IN ('3')
instance_type_ci_runners_e59bb2812d schema
gitlabhq_development_ci> \d+ instance_type_ci_runners_e59bb2812d
+--------------------------------------+--------------------------+----------------------------------+----------+--------------+-------------+
| Column                               | Type                     | Modifiers                        | Storage  | Stats target | Description |
|--------------------------------------+--------------------------+----------------------------------+----------+--------------+-------------|
| id                                   | bigint                   |  not null                        | plain    | <null>       | <null>      |
| creator_id                           | bigint                   |                                  | plain    | <null>       | <null>      |
| sharding_key_id                      | bigint                   |                                  | plain    | <null>       | <null>      |
| created_at                           | timestamp with time zone |                                  | plain    | <null>       | <null>      |
| updated_at                           | timestamp with time zone |                                  | plain    | <null>       | <null>      |
| contacted_at                         | timestamp with time zone |                                  | plain    | <null>       | <null>      |
| token_expires_at                     | timestamp with time zone |                                  | plain    | <null>       | <null>      |
| public_projects_minutes_cost_factor  | double precision         |  not null default 1.0            | plain    | <null>       | <null>      |
| private_projects_minutes_cost_factor | double precision         |  not null default 1.0            | plain    | <null>       | <null>      |
| access_level                         | integer                  |  not null default 0              | plain    | <null>       | <null>      |
| maximum_timeout                      | integer                  |                                  | plain    | <null>       | <null>      |
| runner_type                          | smallint                 |  not null                        | plain    | <null>       | <null>      |
| registration_type                    | smallint                 |  not null default 0              | plain    | <null>       | <null>      |
| creation_state                       | smallint                 |  not null default 0              | plain    | <null>       | <null>      |
| active                               | boolean                  |  not null default true           | plain    | <null>       | <null>      |
| run_untagged                         | boolean                  |  not null default true           | plain    | <null>       | <null>      |
| locked                               | boolean                  |  not null default false          | plain    | <null>       | <null>      |
| name                                 | text                     |                                  | extended | <null>       | <null>      |
| token_encrypted                      | text                     |                                  | extended | <null>       | <null>      |
| token                                | text                     |                                  | extended | <null>       | <null>      |
| description                          | text                     |                                  | extended | <null>       | <null>      |
| maintainer_note                      | text                     |                                  | extended | <null>       | <null>      |
| allowed_plans                        | text[]                   |  not null default '{}'::text[]   | extended | <null>       | <null>      |
| allowed_plan_ids                     | bigint[]                 |  not null default '{}'::bigint[] | extended | <null>       | <null>      |
+--------------------------------------+--------------------------+----------------------------------+----------+--------------+-------------+
Indexes:
    "instance_type_ci_runners_e59bb2812d_pkey" PRIMARY KEY, btree (id, runner_type)
    "instance_type_ci_runners_e59bb2812d_token_runner_type_idx" UNIQUE, btree (token, runner_type) WHERE token IS NOT NULL
    "instance_type_ci_runners_e59bb2_token_encrypted_runner_type_idx" UNIQUE, btree (token_encrypted, runner_type)
    "instance_type_ci_runners_e59bb2812d_active_id_idx" btree (active, id)
    "instance_type_ci_runners_e59bb2812d_contacted_at_id_idx" btree (contacted_at, id DESC)
    "instance_type_ci_runners_e59bb2812d_contacted_at_id_idx1" btree (contacted_at DESC, id DESC) WHERE active = false
    "instance_type_ci_runners_e59bb2812d_contacted_at_id_idx2" btree (contacted_at DESC, id DESC)
    "instance_type_ci_runners_e59bb2812d_created_at_id_idx" btree (created_at, id DESC)
    "instance_type_ci_runners_e59bb2812d_created_at_id_idx1" btree (created_at DESC, id DESC) WHERE active = false
    "instance_type_ci_runners_e59bb2812d_created_at_id_idx2" btree (created_at DESC, id DESC)
    "instance_type_ci_runners_e59bb2812d_creator_id_idx" btree (creator_id) WHERE creator_id IS NOT NULL
    "instance_type_ci_runners_e59bb2812d_description_idx" gin (description gin_trgm_ops)
    "instance_type_ci_runners_e59bb2812d_locked_idx" btree (locked)
    "instance_type_ci_runners_e59bb2812d_sharding_key_id_idx" btree (sharding_key_id) WHERE sharding_key_id IS NOT NULL
    "instance_type_ci_runners_e59bb2812d_token_expires_at_id_idx" btree (token_expires_at, id DESC)
    "instance_type_ci_runners_e59bb2812d_token_expires_at_id_idx1" btree (token_expires_at DESC, id DESC)
Check constraints:
    "check_1f8618ab23" CHECK (char_length(name) <= 256)
    "check_24b281f5bf" CHECK (char_length(maintainer_note) <= 1024)
    "check_31c16b2a99" CHECK (char_length(token_encrypted) <= 128)
    "check_5db8ae9d30" CHECK (char_length(description) <= 1024)
    "check_af25130d5a" CHECK (char_length(token) <= 128)
    "check_sharding_key_id_nullness" CHECK (runner_type = 1 AND sharding_key_id IS NULL OR runner_type <> 1 AND sharding_key_id IS NOT NULL) NOT VALID
Partition of: public.ci_runners_e59bb2812d FOR VALUES IN ('1')
Partition constraint: ((runner_type IS NOT NULL) AND (runner_type = '1'::smallint))
Has OIDs: no
group_type_ci_runners_e59bb2812d schema
gitlabhq_development_ci> \d+ group_type_ci_runners_e59bb2812d
+--------------------------------------+--------------------------+----------------------------------+----------+--------------+-------------+
| Column                               | Type                     | Modifiers                        | Storage  | Stats target | Description |
|--------------------------------------+--------------------------+----------------------------------+----------+--------------+-------------|
| id                                   | bigint                   |  not null                        | plain    | <null>       | <null>      |
| creator_id                           | bigint                   |                                  | plain    | <null>       | <null>      |
| sharding_key_id                      | bigint                   |                                  | plain    | <null>       | <null>      |
| created_at                           | timestamp with time zone |                                  | plain    | <null>       | <null>      |
| updated_at                           | timestamp with time zone |                                  | plain    | <null>       | <null>      |
| contacted_at                         | timestamp with time zone |                                  | plain    | <null>       | <null>      |
| token_expires_at                     | timestamp with time zone |                                  | plain    | <null>       | <null>      |
| public_projects_minutes_cost_factor  | double precision         |  not null default 1.0            | plain    | <null>       | <null>      |
| private_projects_minutes_cost_factor | double precision         |  not null default 1.0            | plain    | <null>       | <null>      |
| access_level                         | integer                  |  not null default 0              | plain    | <null>       | <null>      |
| maximum_timeout                      | integer                  |                                  | plain    | <null>       | <null>      |
| runner_type                          | smallint                 |  not null                        | plain    | <null>       | <null>      |
| registration_type                    | smallint                 |  not null default 0              | plain    | <null>       | <null>      |
| creation_state                       | smallint                 |  not null default 0              | plain    | <null>       | <null>      |
| active                               | boolean                  |  not null default true           | plain    | <null>       | <null>      |
| run_untagged                         | boolean                  |  not null default true           | plain    | <null>       | <null>      |
| locked                               | boolean                  |  not null default false          | plain    | <null>       | <null>      |
| name                                 | text                     |                                  | extended | <null>       | <null>      |
| token_encrypted                      | text                     |                                  | extended | <null>       | <null>      |
| token                                | text                     |                                  | extended | <null>       | <null>      |
| description                          | text                     |                                  | extended | <null>       | <null>      |
| maintainer_note                      | text                     |                                  | extended | <null>       | <null>      |
| allowed_plans                        | text[]                   |  not null default '{}'::text[]   | extended | <null>       | <null>      |
| allowed_plan_ids                     | bigint[]                 |  not null default '{}'::bigint[] | extended | <null>       | <null>      |
+--------------------------------------+--------------------------+----------------------------------+----------+--------------+-------------+
Indexes:
    "group_type_ci_runners_e59bb2812d_pkey" PRIMARY KEY, btree (id, runner_type)
    "group_type_ci_runners_e59bb2812_token_encrypted_runner_type_idx" UNIQUE, btree (token_encrypted, runner_type)
    "group_type_ci_runners_e59bb2812d_token_runner_type_idx" UNIQUE, btree (token, runner_type) WHERE token IS NOT NULL
    "group_type_ci_runners_e59bb2812d_active_id_idx" btree (active, id)
    "group_type_ci_runners_e59bb2812d_contacted_at_id_idx" btree (contacted_at, id DESC)
    "group_type_ci_runners_e59bb2812d_contacted_at_id_idx1" btree (contacted_at DESC, id DESC) WHERE active = false
    "group_type_ci_runners_e59bb2812d_contacted_at_id_idx2" btree (contacted_at DESC, id DESC)
    "group_type_ci_runners_e59bb2812d_created_at_id_idx" btree (created_at, id DESC)
    "group_type_ci_runners_e59bb2812d_created_at_id_idx1" btree (created_at DESC, id DESC) WHERE active = false
    "group_type_ci_runners_e59bb2812d_created_at_id_idx2" btree (created_at DESC, id DESC)
    "group_type_ci_runners_e59bb2812d_creator_id_idx" btree (creator_id) WHERE creator_id IS NOT NULL
    "group_type_ci_runners_e59bb2812d_description_idx" gin (description gin_trgm_ops)
    "group_type_ci_runners_e59bb2812d_locked_idx" btree (locked)
    "group_type_ci_runners_e59bb2812d_sharding_key_id_idx" btree (sharding_key_id) WHERE sharding_key_id IS NOT NULL
    "group_type_ci_runners_e59bb2812d_token_expires_at_id_idx" btree (token_expires_at, id DESC)
    "group_type_ci_runners_e59bb2812d_token_expires_at_id_idx1" btree (token_expires_at DESC, id DESC)
Check constraints:
    "check_1f8618ab23" CHECK (char_length(name) <= 256)
    "check_24b281f5bf" CHECK (char_length(maintainer_note) <= 1024)
    "check_31c16b2a99" CHECK (char_length(token_encrypted) <= 128)
    "check_5db8ae9d30" CHECK (char_length(description) <= 1024)
    "check_af25130d5a" CHECK (char_length(token) <= 128)
    "check_sharding_key_id_nullness" CHECK (runner_type = 1 AND sharding_key_id IS NULL OR runner_type <> 1 AND sharding_key_id IS NOT NULL) NOT VALID
Partition of: public.ci_runners_e59bb2812d FOR VALUES IN ('2')
Partition constraint: ((runner_type IS NOT NULL) AND (runner_type = '2'::smallint))
Has OIDs: no
project_type_ci_runners_e59bb2812d schema
gitlabhq_development_ci> \d+ project_type_ci_runners_e59bb2812d
+--------------------------------------+--------------------------+----------------------------------+----------+--------------+-------------+
| Column                               | Type                     | Modifiers                        | Storage  | Stats target | Description |
|--------------------------------------+--------------------------+----------------------------------+----------+--------------+-------------|
| id                                   | bigint                   |  not null                        | plain    | <null>       | <null>      |
| creator_id                           | bigint                   |                                  | plain    | <null>       | <null>      |
| sharding_key_id                      | bigint                   |                                  | plain    | <null>       | <null>      |
| created_at                           | timestamp with time zone |                                  | plain    | <null>       | <null>      |
| updated_at                           | timestamp with time zone |                                  | plain    | <null>       | <null>      |
| contacted_at                         | timestamp with time zone |                                  | plain    | <null>       | <null>      |
| token_expires_at                     | timestamp with time zone |                                  | plain    | <null>       | <null>      |
| public_projects_minutes_cost_factor  | double precision         |  not null default 1.0            | plain    | <null>       | <null>      |
| private_projects_minutes_cost_factor | double precision         |  not null default 1.0            | plain    | <null>       | <null>      |
| access_level                         | integer                  |  not null default 0              | plain    | <null>       | <null>      |
| maximum_timeout                      | integer                  |                                  | plain    | <null>       | <null>      |
| runner_type                          | smallint                 |  not null                        | plain    | <null>       | <null>      |
| registration_type                    | smallint                 |  not null default 0              | plain    | <null>       | <null>      |
| creation_state                       | smallint                 |  not null default 0              | plain    | <null>       | <null>      |
| active                               | boolean                  |  not null default true           | plain    | <null>       | <null>      |
| run_untagged                         | boolean                  |  not null default true           | plain    | <null>       | <null>      |
| locked                               | boolean                  |  not null default false          | plain    | <null>       | <null>      |
| name                                 | text                     |                                  | extended | <null>       | <null>      |
| token_encrypted                      | text                     |                                  | extended | <null>       | <null>      |
| token                                | text                     |                                  | extended | <null>       | <null>      |
| description                          | text                     |                                  | extended | <null>       | <null>      |
| maintainer_note                      | text                     |                                  | extended | <null>       | <null>      |
| allowed_plans                        | text[]                   |  not null default '{}'::text[]   | extended | <null>       | <null>      |
| allowed_plan_ids                     | bigint[]                 |  not null default '{}'::bigint[] | extended | <null>       | <null>      |
+--------------------------------------+--------------------------+----------------------------------+----------+--------------+-------------+
Indexes:
    "project_type_ci_runners_e59bb2812d_pkey" PRIMARY KEY, btree (id, runner_type)
    "project_type_ci_runners_e59bb2812d_token_runner_type_idx" UNIQUE, btree (token, runner_type) WHERE token IS NOT NULL
    "project_type_ci_runners_e59bb28_token_encrypted_runner_type_idx" UNIQUE, btree (token_encrypted, runner_type)
    "project_type_ci_runners_e59bb2812d_active_id_idx" btree (active, id)
    "project_type_ci_runners_e59bb2812d_contacted_at_id_idx" btree (contacted_at, id DESC)
    "project_type_ci_runners_e59bb2812d_contacted_at_id_idx1" btree (contacted_at DESC, id DESC) WHERE active = false
    "project_type_ci_runners_e59bb2812d_contacted_at_id_idx2" btree (contacted_at DESC, id DESC)
    "project_type_ci_runners_e59bb2812d_created_at_id_idx" btree (created_at, id DESC)
    "project_type_ci_runners_e59bb2812d_created_at_id_idx1" btree (created_at DESC, id DESC) WHERE active = false
    "project_type_ci_runners_e59bb2812d_created_at_id_idx2" btree (created_at DESC, id DESC)
    "project_type_ci_runners_e59bb2812d_creator_id_idx" btree (creator_id) WHERE creator_id IS NOT NULL
    "project_type_ci_runners_e59bb2812d_description_idx" gin (description gin_trgm_ops)
    "project_type_ci_runners_e59bb2812d_locked_idx" btree (locked)
    "project_type_ci_runners_e59bb2812d_sharding_key_id_idx" btree (sharding_key_id) WHERE sharding_key_id IS NOT NULL
    "project_type_ci_runners_e59bb2812d_token_expires_at_id_idx" btree (token_expires_at, id DESC)
    "project_type_ci_runners_e59bb2812d_token_expires_at_id_idx1" btree (token_expires_at DESC, id DESC)
Check constraints:
    "check_1f8618ab23" CHECK (char_length(name) <= 256)
    "check_24b281f5bf" CHECK (char_length(maintainer_note) <= 1024)
    "check_31c16b2a99" CHECK (char_length(token_encrypted) <= 128)
    "check_5db8ae9d30" CHECK (char_length(description) <= 1024)
    "check_af25130d5a" CHECK (char_length(token) <= 128)
    "check_sharding_key_id_nullness" CHECK (runner_type = 1 AND sharding_key_id IS NULL OR runner_type <> 1 AND sharding_key_id IS NOT NULL) NOT VALID
Partition of: public.ci_runners_e59bb2812d FOR VALUES IN ('3')
Partition constraint: ((runner_type IS NOT NULL) AND (runner_type = '3'::smallint))
Has OIDs: no
topic screenshot
Comparison between non-partitioned and partitioned tables image

How to set up and validate locally

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

Edited by Pedro Pombeiro

Merge request reports

Loading