[go: up one dir, main page]

Migrate varchar fields to text in p_ci_builds table

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

Description

Summary

The schema for the ci_builds table in production is necessarily different than a fresh schema would be because of inconsistencies that have been introduced historically. In order to fix several issues deriving from these inconsistencies, we need to align the ci_builds table on .com with what we expect.

Current Issues

  • Really long job names are truncated, the error thrown isn't surfaced. It's not possible to remove the limit without a complete table rewrite.
  • There are several differences between a fresh migration and prod as noted in the below diff:
--- gitlab.com
+++ fresh install
@@ -2,7 +2,7 @@
           Column          |            Type             | Collation | Nullable |                Default                | Storage  | Stats target | Description
 --------------------------+-----------------------------+-----------+----------+---------------------------------------+----------+--------------+-------------
  id                       | integer                     |           | not null | nextval('ci_builds_id_seq'::regclass) | plain    |              |
- status                   | character varying(255)      |           |          |                                       | extended |              |
+ status                   | character varying           |           |          |                                       | extended |              |
  finished_at              | timestamp without time zone |           |          |                                       | plain    |              |
  trace                    | text                        |           |          |                                       | extended |              |
  created_at               | timestamp without time zone |           |          |                                       | plain    |              |
@@ -12,18 +12,18 @@
  coverage                 | double precision            |           |          |                                       | plain    |              |
  commit_id                | integer                     |           |          |                                       | plain    |              |
  commands                 | text                        |           |          |                                       | extended |              |
- name                     | character varying(255)      |           |          |                                       | extended |              |
+ name                     | character varying           |           |          |                                       | extended |              |
  options                  | text                        |           |          |                                       | extended |              |
  allow_failure            | boolean                     |           | not null | false                                 | plain    |              |
  trigger_request_id       | integer                     |           |          |                                       | plain    |              |
  stage_idx                | integer                     |           |          |                                       | plain    |              |
  tag                      | boolean                     |           |          |                                       | plain    |              |
- ref                      | character varying(255)      |           |          |                                       | extended |              |
+ ref                      | character varying           |           |          |                                       | extended |              |
  user_id                  | integer                     |           |          |                                       | plain    |              |
- type                     | character varying(255)      |           |          |                                       | extended |              |
- target_url               | character varying(255)      |           |          |                                       | extended |              |
- description              | character varying(255)      |           |          |                                       | extended |              |
+ type                     | character varying           |           |          |                                       | extended |              |
+ target_url               | character varying           |           |          |                                       | extended |              |
+ description              | character varying           |           |          |                                       | extended |              |
  artifacts_file           | text                        |           |          |                                       | extended |              |
  project_id               | integer                     |           |          |                                       | plain    |              |
  artifacts_metadata       | text                        |           |          |                                       | extended |              |

Original Title: Error saving pipeline: ActiveRecord::ValueTooLong: PG::StringDataRightTruncation: ERROR: value too long for type character varying(255)

https://sentry.gitlab.net/gitlab/gitlabcom/issues/1912320/?referrer=gitlab_plugin

PG::StringDataRightTruncation: ERROR:  value too long for type character varying(255)

  active_record/connection_adapters/postgresql_adapter.rb:675:in `exec_params'
    @connection.exec_params(sql, type_casted_binds)
  active_record/persistence.rb:470:in `save'
    create_or_update(*args, **options, &block)
  active_record/validations.rb:47:in `save'
    perform_validations(options) ? super : false
  active_record/transactions.rb:314:in `block in save'
    with_transaction_returning_status { super }
  active_record/transactions.rb:375:in `block in with_transaction_returning_status'
    status = yield
...
(245 additional frame(s) were not displayed)

ActiveRecord::ValueTooLong: PG::StringDataRightTruncation: ERROR:  value too long for type character varying(255)

PG::StringDataRightTruncation: ERROR:  value too long for type character varying(255)
Edited by Marius Bobin