Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Silence strong migration warning #1037

Merged
merged 5 commits into from
Dec 1, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config/initializers/strong_migrations.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# rubocop:disable Style/NumericLiterals
unless Rails.env.production?
StrongMigrations.start_after = 20200205123840
StrongMigrations.lock_timeout_limit = 86400.seconds
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a timeout of 24h, do we expect a migration to take longer?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem with this check is, that it not actually checks how long a transaction takes but rather what mariadb is configured to (aka when to cancel a transaction).

See: https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_lock_wait_timeout which is fetched by the check here: https://github.com/ankane/strong_migrations/blob/master/lib/strong_migrations/adapters/mysql_adapter.rb#L35

To make this sane, we would need to ship our own mariadb configuration since the default is 31536000 and us setting 86400 will trigger this check and fail always with default configuration.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, I see. Why not remove that line entirely then instead of setting to 0?

In glue we're setting timeouts for migrations, which I guess was the goal here too when we added that line:

StrongMigrations.lock_timeout = 20.seconds
StrongMigrations.statement_timeout = 2.minutes

Would it make sense to set some limits for RMT too, so that a migration cannot block the db endlessly?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree we should set the lock_timeout and statement_timeout, then also the lock_timeout_limit works. But without you will run into: https://github.com/ankane/strong_migrations/blob/master/lib/strong_migrations/checker.rb#L162 which then is setting by default: https://github.com/ankane/strong_migrations/blob/master/lib/strong_migrations.rb#L59

I'm not sure if setting a statement_timeout is really wanted, since a migration can take a long time which is completely fine.

Copy link
Member

@digitaltom digitaltom Nov 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, ok that's unexpected that strong migrations sets it's own default and fails then. Maybe a comment explaining this would help.

Regarding the statement_timeout, it's possible to change it to a higher value for specific migrations that are known to take long.

Anyway, strong_migrations isn't used in production anyway it seems in RMT.

StrongMigrations.lock_timeout_limit = 0
end
# rubocop:enable Style/NumericLiterals
Loading