activerecord-debug_errors 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 818e63536312d27e39718e58eb6ec33827cd703e245f284c806e53d4dfcc86dc
|
4
|
+
data.tar.gz: b177c2624722f1a5bd01f5378c252c6344d134679704f2e816ccbf2b184732f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2198d3f0a7a61a1d71f1c171c8fa9aaa1a4a7f650ae40fb69c39bf95f37ed83aa3d0c125b2beaa2032cac1a7ec05938607448b3266a399e79bd774476dd69610
|
7
|
+
data.tar.gz: d6a9a8df96bff2a512468e3c56ce07099a2eee6818a9adef13422d832bb1b22cb2dadc0450b960f0ed244d6d21223453e3fd957fac67816fc4c0ba1770de0943
|
data/README.md
CHANGED
@@ -32,7 +32,7 @@ By loading the gem, you can see useful debug logs on errors as described below.
|
|
32
32
|
|
33
33
|
### ActiveRecord::LockWaitTimeout
|
34
34
|
|
35
|
-
|
35
|
+
If you use MySQL and when `ActiveRecord::LockWaitTimeout` occurs, you can see a log like below:
|
36
36
|
|
37
37
|
```
|
38
38
|
ActiveRecord::LockWaitTimeout occurred:
|
@@ -77,7 +77,7 @@ In the preceding log, you can find that there were two long transactions. The fi
|
|
77
77
|
|
78
78
|
### ActiveRecord::Deadlocked
|
79
79
|
|
80
|
-
|
80
|
+
If you use MySQL and when `ActiveRecord::Deadlocked` occurs, you can see the information of the latest detected deadlock:
|
81
81
|
|
82
82
|
```
|
83
83
|
ActiveRecord::Deadlocked occurred:
|
@@ -124,37 +124,44 @@ When `ActiveRecord::ConnectionTimeoutError` occurs, you can see the information
|
|
124
124
|
|
125
125
|
```
|
126
126
|
ActiveRecord::ConnectionTimeoutError occured:
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
/path/to/ruby/gems/2.7.0/gems/rspec-core-3.9.3/lib/rspec/core/example.rb:262:in `block in run'
|
140
|
-
/path/to/ruby/gems/2.7.0/gems/rspec-core-3.9.3/lib/rspec/core/example.rb:508:in `block in with_around_and_singleton_context_hooks'
|
141
|
-
/path/to/ruby/gems/2.7.0/gems/rspec-core-3.9.3/lib/rspec/core/example.rb:465:in `block in with_around_example_hooks'
|
142
|
-
/path/to/ruby/gems/2.7.0/gems/rspec-core-3.9.3/lib/rspec/core/hooks.rb:486:in `block in run'
|
143
|
-
/path/to/ruby/gems/2.7.0/gems/rspec-core-3.9.3/lib/rspec/core/hooks.rb:626:in `block in run_around_example_hooks_for'
|
144
|
-
/path/to/ruby/gems/2.7.0/gems/rspec-core-3.9.3/lib/rspec/core/example.rb:350:in `call'
|
145
|
-
/path/to/activerecord-debug_errors/spec/activerecord/debug_errors/ext/connection_adapters/connection_pool_spec.rb:13:in `block (2 levels) in <top (required)>'
|
146
|
-
/path/to/ruby/gems/2.7.0/gems/rspec-core-3.9.3/lib/rspec/core/example.rb:455:in `instance_exec'
|
147
|
-
/path/to/ruby/gems/2.7.0/gems/rspec-core-3.9.3/lib/rspec/core/example.rb:455:in `instance_exec'
|
148
|
-
/path/to/ruby/gems/2.7.0/gems/rspec-core-3.9.3/lib/rspec/core/hooks.rb:390:in `execute_with'
|
127
|
+
connection owners:
|
128
|
+
Thread #<Thread:0x00007fbda205fa70 sleep_forever> status=sleep priority=0
|
129
|
+
/path/to/activerecord-debug_errors/spec/activerecord/debug_errors/ext/connection_adapters/connection_pool_spec.rb:32:in `join'
|
130
|
+
/path/to/activerecord-debug_errors/spec/activerecord/debug_errors/ext/connection_adapters/connection_pool_spec.rb:32:in `each'
|
131
|
+
/path/to/activerecord-debug_errors/spec/activerecord/debug_errors/ext/connection_adapters/connection_pool_spec.rb:32:in `block (4 levels) in <top (required)>'
|
132
|
+
/path/to/ruby/gems/2.7.0/gems/rspec-expectations-3.9.3/lib/rspec/matchers/built_in/raise_error.rb:52:in `matches?'
|
133
|
+
/path/to/ruby/gems/2.7.0/gems/rspec-expectations-3.9.3/lib/rspec/expectations/handler.rb:50:in `block in handle_matcher'
|
134
|
+
/path/to/ruby/gems/2.7.0/gems/rspec-expectations-3.9.3/lib/rspec/expectations/handler.rb:27:in `with_matcher'
|
135
|
+
/path/to/ruby/gems/2.7.0/gems/rspec-expectations-3.9.3/lib/rspec/expectations/handler.rb:48:in `handle_matcher'
|
136
|
+
/path/to/ruby/gems/2.7.0/gems/rspec-expectations-3.9.3/lib/rspec/expectations/expectation_target.rb:65:in `to'
|
137
|
+
/path/to/ruby/gems/2.7.0/gems/rspec-expectations-3.9.3/lib/rspec/expectations/expectation_target.rb:101:in `to'
|
138
|
+
/path/to/activerecord-debug_errors/spec/activerecord/debug_errors/ext/connection_adapters/connection_pool_spec.rb:26:in `block (3 levels) in <top (required)>'
|
149
139
|
-- snip --
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
140
|
+
/path/to/bin/rspec:23:in `load'
|
141
|
+
/path/to/bin/rspec:23:in `<main>'
|
142
|
+
Thread #<Thread:0x00007fbda4908008 /path/to/activerecord-debug_errors/spec/activerecord/debug_errors/ext/connection_adapters/connection_pool_spec.rb:29 dead> status=false priority=0
|
143
|
+
Thread #<Thread:0x00007fbda4909688 /path/to/activerecord-debug_errors/spec/activerecord/debug_errors/ext/connection_adapters/connection_pool_spec.rb:29 dead> status=false priority=0
|
144
|
+
Thread #<Thread:0x00007fbda4908170 /path/to/activerecord-debug_errors/spec/activerecord/debug_errors/ext/connection_adapters/connection_pool_spec.rb:29 dead> status=false priority=0
|
145
|
+
Thread #<Thread:0x00007fbda48fbd58 /path/to/activerecord-debug_errors/spec/activerecord/debug_errors/ext/connection_adapters/connection_pool_spec.rb:29 dead> status=false priority=0
|
146
|
+
other threads:
|
147
|
+
Thread #<Thread:0x00007fbda52b3ad0 /path/to/ruby/gems/2.7.0/gems/activerecord-6.0.3.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:334 sleep> status=sleep priority=0
|
148
|
+
/path/to/ruby/gems/2.7.0/gems/activerecord-6.0.3.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:337:in `sleep'
|
149
|
+
/path/to/ruby/gems/2.7.0/gems/activerecord-6.0.3.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:337:in `block in spawn_thread'
|
150
|
+
Thread #<Thread:0x00007fbda5100170 /path/to/activerecord-debug_errors/spec/activerecord/debug_errors/ext/connection_adapters/connection_pool_spec.rb:24 sleep> status=sleep priority=0
|
151
|
+
/path/to/activerecord-debug_errors/spec/activerecord/debug_errors/ext/connection_adapters/connection_pool_spec.rb:24:in `sleep'
|
152
|
+
/path/to/activerecord-debug_errors/spec/activerecord/debug_errors/ext/connection_adapters/connection_pool_spec.rb:24:in `block (4 levels) in <top (required)>'
|
153
|
+
Thread #<Thread:0x00007fbda48fbc40 /path/to/activerecord-debug_errors/spec/activerecord/debug_errors/ext/connection_adapters/connection_pool_spec.rb:29 run> status=run priority=0
|
154
|
+
/path/to/activerecord-debug_errors/lib/activerecord/debug_errors/ext/connection_adapters/connection_pool.rb:22:in `backtrace'
|
155
|
+
/path/to/activerecord-debug_errors/lib/activerecord/debug_errors/ext/connection_adapters/connection_pool.rb:22:in `block in dump_threads'
|
156
|
+
/path/to/activerecord-debug_errors/lib/activerecord/debug_errors/ext/connection_adapters/connection_pool.rb:34:in `each'
|
157
|
+
/path/to/activerecord-debug_errors/lib/activerecord/debug_errors/ext/connection_adapters/connection_pool.rb:34:in `dump_threads'
|
158
|
+
/path/to/activerecord-debug_errors/lib/activerecord/debug_errors/ext/connection_adapters/connection_pool.rb:9:in `rescue in acquire_connection'
|
159
|
+
/path/to/activerecord-debug_errors/lib/activerecord/debug_errors/ext/connection_adapters/connection_pool.rb:6:in `acquire_connection'
|
160
|
+
/path/to/ruby/gems/2.7.0/gems/activerecord-6.0.3.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:593:in `checkout'
|
161
|
+
/path/to/activerecord-debug_errors/spec/activerecord/debug_errors/ext/connection_adapters/connection_pool_spec.rb:30:in `block (6 levels) in <top (required)>'
|
156
162
|
```
|
157
163
|
|
164
|
+
In the preceding log, you can find that there were five connection owners and three other threads. The first owner was the main thread (Thread:0x00007fbda205fa70) and the other owners are dead threads.
|
158
165
|
|
159
166
|
## Development
|
160
167
|
|
@@ -6,21 +6,32 @@ module ActiveRecord
|
|
6
6
|
def acquire_connection(*args)
|
7
7
|
super
|
8
8
|
rescue ActiveRecord::ConnectionTimeoutError
|
9
|
-
|
9
|
+
dump_threads if ActiveRecord::Base.logger
|
10
10
|
raise
|
11
11
|
end
|
12
12
|
|
13
13
|
private
|
14
14
|
|
15
|
-
def
|
15
|
+
def dump_threads
|
16
16
|
logger = ActiveRecord::Base.logger
|
17
17
|
|
18
18
|
logger.error "ActiveRecord::ConnectionTimeoutError occured:"
|
19
|
-
|
20
|
-
|
19
|
+
|
20
|
+
dump_thread = ->(thread) {
|
21
|
+
logger.error " Thread #{thread} status=#{thread.status} priority=#{thread.priority}"
|
21
22
|
thread.backtrace&.each do |bt|
|
22
|
-
logger.error "
|
23
|
+
logger.error " #{bt}"
|
23
24
|
end
|
25
|
+
}
|
26
|
+
|
27
|
+
owners = ActiveRecord::Base.connection_pool.connections.map(&:owner)
|
28
|
+
logger.error " connection owners:"
|
29
|
+
owners.each(&dump_thread)
|
30
|
+
|
31
|
+
other_threads = Thread.list - owners
|
32
|
+
unless other_threads.empty?
|
33
|
+
logger.error " other threads:"
|
34
|
+
other_threads.each(&dump_thread)
|
24
35
|
end
|
25
36
|
end
|
26
37
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord-debug_errors
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- abicky
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-10-
|
11
|
+
date: 2020-10-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|