Skip to content

Database migration error from 20211103162025

Summary

./db/post_migrate/20211103162025_add_index_on_events_using_btree_created_at_id.rb as introduced in !73670 (merged) seems to be causing a problem with a PostgreSQL 12 database within Cloud Native GitLab, as deployed by the gitlab/gitlab Helm chart. The review_specs_* jobs restore from a known good backup, and then execute database migrations.

Steps to reproduce

  1. Deploy a clean environment
  2. Check migrations job log
  3. Restore a database from a known-good
  4. Attempt to run /scripts/db-migrate from toolbox container

What is the current bug behavior?

git@rvw-406388268-master-trigger-b-toolbox-794c5b9744-xt7rk:/$ /scripts/db-migrate 
Checking database migrations are up-to-date
Performing migrations (this will initialized if needed)
== 20211103162025 AddIndexOnEventsUsingBtreeCreatedAtId: migrating ============
-- transaction_open?()
   -> 0.0000s
-- index_exists?(:events, [:created_at, :id], {:name=>"index_events_on_created_at_and_id", :where=>"created_at > '2021-08-27 00:00:00+00'::timestamp with time zone", :algorithm=>:concurrently})
   -> 0.0154s
-- add_index(:events, [:created_at, :id], {:name=>"index_events_on_created_at_and_id", :where=>"created_at > '2021-08-27 00:00:00+00'::timestamp with time zone", :algorithm=>:concurrently})
rake aborted!
StandardError: An error has occurred, all later migrations canceled:

PG::InvalidObjectDefinition: ERROR:  functions in index predicate must be marked IMMUTABLE

What is the expected correct behavior?

Migrations / seeding complete fully.

Relevant logs and/or screenshots

git@rvw-406388268-master-trigger-b-toolbox-794c5b9744-xt7rk:/$ cat /srv/gitlab/REVISION /srv/gitlab/VERSION 
7844282c5f9
14.5.0-pre

Output of checks

Results of GitLab environment info

Fresh deployment of CNG into GKE

Possible fixes

Edited by Jason Plum