Skip to content

Enable lock retries by default for transactional migrations

What does this MR do and why?

Runs migration WithLockRetries by default, unless the ddl_transaction is disabled.

Notes:

  • At the worst case we will force run the migration (without timing out), but it was an (optimistically) intentional decision made during development.

    • Also there were only 2 such occasions (log) in the past month, so I am positive that this should not create a problem (as we enable_lock_retries! for most of the migrations already).

      Screenshot

      Screenshot 2024-02-14 at 17.18.24.png

  • Follow up issues has been created to

    • #442353 - Cleanup PreventGlobalEnableLockRetriesWithDisableDdlTransaction rubocop.
    • #442354 - Remove usages of enable_lock_retries! from migrations, after the next required stop.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After

How to set up and validate locally

  1. Create a new migration bundle exec rails g migration CreateTestTable

  2. Observe the logs, tail -f log/migrations.log

  3. Run the created migration and we should be able see the below log entry (with message: Lock timeout is set)

    {"severity":"INFO","time":"2024-02-19T18:31:58.634Z","correlation_id":null,"method":"with_lock_retries","class":"CreateTestTable","message":"Lock timeout is set","current_iteration":1,"lock_timeout_in_ms":100}

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #419234 (closed)

Edited by Prabakaran Murugesan

Merge request reports