deadlock_retry 1.1.2 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +5 -0
- data/Gemfile +3 -0
- data/deadlock_retry.gemspec +5 -1
- data/lib/deadlock_retry.rb +16 -14
- data/lib/deadlock_retry/version.rb +3 -0
- data/test/deadlock_retry_test.rb +6 -2
- metadata +20 -6
data/CHANGELOG
CHANGED
data/Gemfile
ADDED
data/deadlock_retry.gemspec
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
|
3
|
-
|
3
|
+
$:.push File.expand_path("../lib", __FILE__)
|
4
|
+
|
5
|
+
require "deadlock_retry/version"
|
4
6
|
|
5
7
|
Gem::Specification.new do |s|
|
6
8
|
s.name = %q{deadlock_retry}
|
@@ -9,7 +11,9 @@ Gem::Specification.new do |s|
|
|
9
11
|
s.description = s.summary = %q{Provides automatic deadlock retry and logging functionality for ActiveRecord and MySQL}
|
10
12
|
s.email = %q{mperham@gmail.com}
|
11
13
|
s.files = `git ls-files`.split("\n")
|
14
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
12
15
|
s.homepage = %q{http://github.com/mperham/deadlock_retry}
|
13
16
|
s.require_paths = ["lib"]
|
14
17
|
s.add_development_dependency 'mocha'
|
18
|
+
s.add_development_dependency 'activerecord', ENV['ACTIVERECORD_VERSION'] || ' ~>3.0'
|
15
19
|
end
|
data/lib/deadlock_retry.rb
CHANGED
@@ -1,9 +1,6 @@
|
|
1
1
|
require 'active_support/core_ext/module/attribute_accessors'
|
2
2
|
|
3
3
|
module DeadlockRetry
|
4
|
-
|
5
|
-
VERSION = '1.1.2'
|
6
|
-
|
7
4
|
def self.included(base)
|
8
5
|
base.extend(ClassMethods)
|
9
6
|
base.class_eval do
|
@@ -18,7 +15,8 @@ module DeadlockRetry
|
|
18
15
|
module ClassMethods
|
19
16
|
DEADLOCK_ERROR_MESSAGES = [
|
20
17
|
"Deadlock found when trying to get lock",
|
21
|
-
"Lock wait timeout exceeded"
|
18
|
+
"Lock wait timeout exceeded",
|
19
|
+
"deadlock detected"
|
22
20
|
]
|
23
21
|
|
24
22
|
MAXIMUM_RETRIES_ON_DEADLOCK = 3
|
@@ -71,17 +69,21 @@ module DeadlockRetry
|
|
71
69
|
def check_innodb_status_available
|
72
70
|
return unless DeadlockRetry.innodb_status_cmd == nil
|
73
71
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
72
|
+
if self.connection.adapter_name == "MySQL"
|
73
|
+
begin
|
74
|
+
mysql_version = self.connection.select_rows('show variables like \'version\'')[0][1]
|
75
|
+
cmd = if mysql_version < '5.5'
|
76
|
+
'show innodb status'
|
77
|
+
else
|
78
|
+
'show engine innodb status'
|
79
|
+
end
|
80
|
+
self.connection.select_value(cmd)
|
81
|
+
DeadlockRetry.innodb_status_cmd = cmd
|
82
|
+
rescue
|
83
|
+
logger.info "Cannot log innodb status: #{$!.message}"
|
84
|
+
DeadlockRetry.innodb_status_cmd = false
|
80
85
|
end
|
81
|
-
|
82
|
-
DeadlockRetry.innodb_status_cmd = cmd
|
83
|
-
rescue
|
84
|
-
logger.info "Cannot log innodb status: #{$!.message}"
|
86
|
+
else
|
85
87
|
DeadlockRetry.innodb_status_cmd = false
|
86
88
|
end
|
87
89
|
end
|
data/test/deadlock_retry_test.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
|
3
3
|
# Change the version if you want to test a different version of ActiveRecord
|
4
|
-
gem 'activerecord', ' ~>3.0'
|
4
|
+
gem 'activerecord', ENV['ACTIVERECORD_VERSION'] || ' ~>3.0'
|
5
5
|
require 'active_record'
|
6
6
|
require 'active_record/version'
|
7
7
|
puts "Testing ActiveRecord #{ActiveRecord::VERSION::STRING}"
|
@@ -37,7 +37,7 @@ class MockModel
|
|
37
37
|
[]
|
38
38
|
end
|
39
39
|
|
40
|
-
def self.
|
40
|
+
def self.select_rows(sql)
|
41
41
|
[['version', '5.1.45']]
|
42
42
|
end
|
43
43
|
|
@@ -45,6 +45,10 @@ class MockModel
|
|
45
45
|
true
|
46
46
|
end
|
47
47
|
|
48
|
+
def self.adapter_name
|
49
|
+
"MySQL"
|
50
|
+
end
|
51
|
+
|
48
52
|
include DeadlockRetry
|
49
53
|
end
|
50
54
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: deadlock_retry
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,11 +10,11 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2012-02-15 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: mocha
|
17
|
-
requirement: &
|
17
|
+
requirement: &70189971244660 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,7 +22,18 @@ dependencies:
|
|
22
22
|
version: '0'
|
23
23
|
type: :development
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *70189971244660
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: activerecord
|
28
|
+
requirement: &70189971244140 !ruby/object:Gem::Requirement
|
29
|
+
none: false
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: *70189971244140
|
26
37
|
description: Provides automatic deadlock retry and logging functionality for ActiveRecord
|
27
38
|
and MySQL
|
28
39
|
email: mperham@gmail.com
|
@@ -32,11 +43,13 @@ extra_rdoc_files: []
|
|
32
43
|
files:
|
33
44
|
- .gitignore
|
34
45
|
- CHANGELOG
|
46
|
+
- Gemfile
|
35
47
|
- LICENSE
|
36
48
|
- README
|
37
49
|
- Rakefile
|
38
50
|
- deadlock_retry.gemspec
|
39
51
|
- lib/deadlock_retry.rb
|
52
|
+
- lib/deadlock_retry/version.rb
|
40
53
|
- test/deadlock_retry_test.rb
|
41
54
|
homepage: http://github.com/mperham/deadlock_retry
|
42
55
|
licenses: []
|
@@ -58,9 +71,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
58
71
|
version: '0'
|
59
72
|
requirements: []
|
60
73
|
rubyforge_project:
|
61
|
-
rubygems_version: 1.8.
|
74
|
+
rubygems_version: 1.8.15
|
62
75
|
signing_key:
|
63
76
|
specification_version: 3
|
64
77
|
summary: Provides automatic deadlock retry and logging functionality for ActiveRecord
|
65
78
|
and MySQL
|
66
|
-
test_files:
|
79
|
+
test_files:
|
80
|
+
- test/deadlock_retry_test.rb
|