Class: PgHaMigrations::BlockingDatabaseTransactions::LongRunningTransaction
- Inherits:
-
Struct
- Object
- Struct
- PgHaMigrations::BlockingDatabaseTransactions::LongRunningTransaction
- Defined in:
- lib/pg_ha_migrations/blocking_database_transactions.rb
Instance Attribute Summary collapse
-
#current_query ⇒ Object
Returns the value of attribute current_query.
-
#database ⇒ Object
Returns the value of attribute database.
-
#state ⇒ Object
Returns the value of attribute state.
-
#tables_with_locks ⇒ Object
Returns the value of attribute tables_with_locks.
-
#transaction_age ⇒ Object
Returns the value of attribute transaction_age.
Instance Method Summary collapse
- #concurrent_index_creation? ⇒ Boolean
- #description ⇒ Object
- #idle? ⇒ Boolean
-
#initialize(*args) ⇒ LongRunningTransaction
constructor
A new instance of LongRunningTransaction.
Constructor Details
#initialize(*args) ⇒ LongRunningTransaction
Returns a new instance of LongRunningTransaction.
4 5 6 7 8 |
# File 'lib/pg_ha_migrations/blocking_database_transactions.rb', line 4 def initialize(*args) super self.tables_with_locks = tables_with_locks.map { |args| Table.new(*args) }.select(&:present?) end |
Instance Attribute Details
#current_query ⇒ Object
Returns the value of attribute current_query
3 4 5 |
# File 'lib/pg_ha_migrations/blocking_database_transactions.rb', line 3 def current_query @current_query end |
#database ⇒ Object
Returns the value of attribute database
3 4 5 |
# File 'lib/pg_ha_migrations/blocking_database_transactions.rb', line 3 def database @database end |
#state ⇒ Object
Returns the value of attribute state
3 4 5 |
# File 'lib/pg_ha_migrations/blocking_database_transactions.rb', line 3 def state @state end |
#tables_with_locks ⇒ Object
Returns the value of attribute tables_with_locks
3 4 5 |
# File 'lib/pg_ha_migrations/blocking_database_transactions.rb', line 3 def tables_with_locks @tables_with_locks end |
#transaction_age ⇒ Object
Returns the value of attribute transaction_age
3 4 5 |
# File 'lib/pg_ha_migrations/blocking_database_transactions.rb', line 3 def transaction_age @transaction_age end |
Instance Method Details
#concurrent_index_creation? ⇒ Boolean
19 20 21 |
# File 'lib/pg_ha_migrations/blocking_database_transactions.rb', line 19 def concurrent_index_creation? !!current_query.match(/create\s+index\s+concurrently/i) end |
#description ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/pg_ha_migrations/blocking_database_transactions.rb', line 10 def description [ database, tables_with_locks.size > 0 ? "tables (#{tables_with_locks.map(&:fully_qualified_name).join(', ')})" : nil, "#{idle? ? "currently idle " : ""}transaction open for #{transaction_age}", "#{idle? ? "last " : ""}query: #{current_query}", ].compact.join(" | ") end |
#idle? ⇒ Boolean
23 24 25 |
# File 'lib/pg_ha_migrations/blocking_database_transactions.rb', line 23 def idle? state == "idle in transaction" end |