Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fixes for PostgreSQL support #9

Merged
merged 3 commits into from

2 participants

This page is out of date. Refresh to see the latest.
Showing with 21 additions and 12 deletions.
  1. +16 −11 lib/deadlock_retry.rb
  2. +5 −1 test/deadlock_retry_test.rb
View
27 lib/deadlock_retry.rb
@@ -18,7 +18,8 @@ class << self
module ClassMethods
DEADLOCK_ERROR_MESSAGES = [
"Deadlock found when trying to get lock",
- "Lock wait timeout exceeded"
+ "Lock wait timeout exceeded",
+ "deadlock detected"
]
MAXIMUM_RETRIES_ON_DEADLOCK = 3
@@ -71,17 +72,21 @@ def show_innodb_status
def check_innodb_status_available
return unless DeadlockRetry.innodb_status_cmd == nil
- begin
- mysql_version = self.connection.select_rows('show variables like \'version\'')[0][1]
- cmd = if mysql_version < '5.5'
- 'show innodb status'
- else
- 'show engine innodb status'
+ if self.connection.adapter_name == "MySQL"
+ begin
+ mysql_version = self.connection.select_rows('show variables like \'version\'')[0][1]
+ cmd = if mysql_version < '5.5'
+ 'show innodb status'
+ else
+ 'show engine innodb status'
+ end
+ self.connection.select_value(cmd)
+ DeadlockRetry.innodb_status_cmd = cmd
+ rescue
+ logger.info "Cannot log innodb status: #{$!.message}"
+ DeadlockRetry.innodb_status_cmd = false
end
- self.connection.select_value(cmd)
- DeadlockRetry.innodb_status_cmd = cmd
- rescue
- logger.info "Cannot log innodb status: #{$!.message}"
+ else
DeadlockRetry.innodb_status_cmd = false
end
end
View
6 test/deadlock_retry_test.rb
@@ -37,7 +37,7 @@ def self.show_innodb_status
[]
end
- def self.execute(sql)
+ def self.select_rows(sql)
[['version', '5.1.45']]
end
@@ -45,6 +45,10 @@ def self.select_value(sql)
true
end
+ def self.adapter_name
+ "MySQL"
+ end
+
include DeadlockRetry
end
Something went wrong with that request. Please try again.