Skip to content

When locking tables, skip tables that are not yet created

Rutger Wessels requested to merge 444321-ignore-missing-tables into master

What does this MR do and why?

We have logic in place that ensures that main tables are locked in ci database and the other way around.

This logic works by going over the database yaml files in db/docs directory and then enable or disable write locks. However, it is possible that this code is run for tables that are in db/docs but they have not been created.

With this MR, we will exclude tables that are not available in the database.

Related to #444321 (closed)

How to set up and validate locally

On master branch, using local development (gdk):

  • Ensure all write locks are set bundle exec rake gitlab:db:lock_writes
  • Create a file in db/docs/new_table.yml with this content:
    ---
    table_name: new_table
    gitlab_schema: gitlab_main_cell
  • In a rails console, run Database::MonitorLockedTablesWorker.new.perform

This will result in new_table mentioned as a table that needs a lock.

When this is repeated on this branch, new_table is not mentioned because it does not exist

Merge request reports