Run gitlab:db:lock_writes when creating new database
requested to merge 404974-make-sure-to-run-gitlab-db-lock_writes-when-setting-new-database into master
What does this MR do and why?
Omnibus install calls db:configure
rake task during installation. This task will:
- create tables (
db:schema:load
) if database is empty - run migrations exist if database is not empty
This MR will make sure we set a write lock on:
-
main
tables inci
database (example:users
table) -
ci
tables inmain
database (example:ci_pipelines
table)
This is implemented using the rake task gitlab:db:lock_writes
The task is idempotent.
How to set up and validate locally
WARNING This will reset the data in the database!
- run
bundle exec rake db:drop db:create gitlab:db:configure
- (database seeding can be aborted using CTRL-C)
- run
gdk psql -c "DELETE FROM ci_pipelines WHERE id = 1"
On master
branch, this will result in:
$ gdk psql -c "DELETE FROM ci_pipelines WHERE id = 1"
DELETE 0
On this branch, this will result in:
$ gdk psql -c "DELETE FROM ci_pipelines WHERE id = 1"
ERROR: Table: "ci_pipelines" is write protected within this Gitlab database.
HINT: Make sure you are using the right database connection
CONTEXT: PL/pgSQL function gitlab_schema_prevent_write() line 4 at RAISE
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #404974 (closed)
Edited by Rutger Wessels