Class: PgHaMigrations::BlockingDatabaseTransactionsReporter
- Inherits:
-
Object
- Object
- PgHaMigrations::BlockingDatabaseTransactionsReporter
- Defined in:
- lib/pg_ha_migrations/blocking_database_transactions_reporter.rb
Constant Summary collapse
- CHECK_DURATION =
"30 seconds"
Class Method Summary collapse
- ._puts(msg) ⇒ Object
- .get_blocking_transactions ⇒ Object
- .report(transactions) ⇒ Object
- .run ⇒ Object
Class Method Details
._puts(msg) ⇒ Object
46 47 48 |
# File 'lib/pg_ha_migrations/blocking_database_transactions_reporter.rb', line 46 def self._puts(msg) puts msg end |
.get_blocking_transactions ⇒ Object
40 41 42 43 44 |
# File 'lib/pg_ha_migrations/blocking_database_transactions_reporter.rb', line 40 def self.get_blocking_transactions { "Primary database" => PgHaMigrations::BlockingDatabaseTransactions.find_blocking_transactions(CHECK_DURATION) } end |
.report(transactions) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/pg_ha_migrations/blocking_database_transactions_reporter.rb', line 13 def self.report(transactions) report = StringIO.new report << "Potentially blocking transactions:\n" transactions.each do |db_description, blocking_transactions| report << "#{db_description}:\n" if blocking_transactions.empty? report << "\t(no long running transactions)\n\n" else blocking_transactions.each do |transaction| report << "\t#{transaction.description}\n\n" end end if blocking_transactions.any?(&:concurrent_index_creation?) report << " Warning: concurrent indexes are currently being built. If you have any other\n migrations in this deploy that will attempt to create additional\n concurrent indexes on the same physical database (even if the table\n being indexes is on another dimension) those migrations will not be\n able to complete until the in-progress index creations finish.\\n\n eos\n report << \"\\n\" # Blank line intentional\n end\n end\n report.string\nend\n".lines.map { |line| "\t#{line}" }.join |
.run ⇒ Object
7 8 9 10 11 |
# File 'lib/pg_ha_migrations/blocking_database_transactions_reporter.rb', line 7 def self.run blocking_transactions = get_blocking_transactions has_transactions = blocking_transactions.values.flatten.present? _puts(report(blocking_transactions)) if has_transactions end |