Module: Gitlab::Database::MigrationHelpers::WraparoundAutovacuum
- Defined in:
- lib/gitlab/database/migration_helpers/wraparound_autovacuum.rb
Instance Method Summary collapse
-
#can_execute_on?(*tables) ⇒ Boolean
This is used for partitioning CI tables because the autovacuum for wraparound prevention can take many hours to complete on some of the tables and this in turn blocks the post deployment migrations pipeline.
- #wraparound_prevention_on_tables?(tables) ⇒ Boolean
Instance Method Details
#can_execute_on?(*tables) ⇒ Boolean
This is used for partitioning CI tables because the autovacuum for wraparound prevention can take many hours to complete on some of the tables and this in turn blocks the post deployment migrations pipeline. Intended workflow for this helper:
-
Introduce a migration that is guarded with this helper
-
Check that the migration was successfully executed on .com
-
Introduce the migration again for self-managed.
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/gitlab/database/migration_helpers/wraparound_autovacuum.rb', line 15 def can_execute_on?(*tables) return false unless Gitlab.com? || Gitlab.dev_or_test_env? if wraparound_prevention_on_tables?(tables) Gitlab::AppLogger.info(message: "Wraparound prevention vacuum detected", class: self.class) say "Wraparound prevention vacuum detected, skipping migration" return false end true end |
#wraparound_prevention_on_tables?(tables) ⇒ Boolean
27 28 29 30 31 32 33 34 |
# File 'lib/gitlab/database/migration_helpers/wraparound_autovacuum.rb', line 27 def wraparound_prevention_on_tables?(tables) Gitlab::Database::PostgresAutovacuumActivity.reset_column_information Gitlab::Database::PostgresAutovacuumActivity .wraparound_prevention .for_tables(tables) .any? end |