[ci failure] undefined method `jobs_per_stage_page_size'
Summary
The master branch CI jobs are currently failing on waiting for the proper migrations. The CI run that seems to have gotten the database into a problematic state can be seen here: https://gitlab.com/gitlab-org/charts/gitlab/-/jobs/1601709285
undefined method `jobs_per_stage_page_size' for #<ApplicationSetting:0x00007f1affee9938>
command terminated with exit code 1
If we use the task-runner to check the migrations, we can see that this migration is down:
up 20210826124311 Add index to error tracking error
down 20210826145509 Add function for inserting deleted records
down 20210826170902 Add throttle unauthenticated api columns
If we run it we see that the function is trying to create already exists:
gitlab-rake db:migrate:up VERSION=20210826145509
== 20210826145509 AddFunctionForInsertingDeletedRecords: migrating ============
-- execute("CREATE FUNCTION insert_into_loose_foreign_keys_deleted_records()\nRETURNS TRIGGER AS\n$$\nBEGIN\n INSERT INTO loose_foreign_keys_deleted_records\n (deleted_table_name, deleted_table_primary_key_value)\n SELECT TG_TABLE_NAME, old_table.id FROM old_table\n ON CONFLICT DO NOTHING;\n\n RETURN NULL;\nEND\n$$ LANGUAGE PLPGSQL\n")
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:
PG::DuplicateFunction: ERROR: function "insert_into_loose_foreign_keys_deleted_records" already exists with same argument types
On friday we worked around this by marking the migration up. But the problem re-appears at our next backup/restore test.