Skip to content

Commit 7941b6f

Browse files
committed
fix: Remove thread pool executor logic until we get a better handle on what's causing thread pool hangs. refs #469
revert: "thread pool scope and mutex need to be global across all instances of Scope for it to be a global thread pool (#471)" revert: "add thread pool and concurrency_max_threads configuration option (#470)" This reverts commit 51fb51c. This reverts commit 697d761.
1 parent 8f46cf3 commit 7941b6f

File tree

3 files changed

+1
-48
lines changed

3 files changed

+1
-48
lines changed

lib/graphiti/configuration.rb

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,6 @@ class Configuration
88
# Defaults to false OR if classes are cached (Rails-only)
99
attr_accessor :concurrency
1010

11-
# This number must be considered in accordance with the database
12-
# connection pool size configured in `database.yml`. The connection
13-
# pool should be large enough to accommodate both the foreground
14-
# threads (ie. web server or job worker threads) and background
15-
# threads. For each process, Graphiti will create one global
16-
# executor that uses this many threads to sideload resources
17-
# asynchronously. Thus, the pool size should be at least
18-
# `thread_count + concurrency_max_threads + 1`. For example, if your
19-
# web server has a maximum of 3 threads, and
20-
# `concurrency_max_threads` is set to 4, then your pool size should
21-
# be at least 8.
22-
# @return [Integer] Maximum number of threads to use when fetching sideloads concurrently
23-
attr_accessor :concurrency_max_threads
24-
2511
attr_accessor :respond_to
2612
attr_accessor :context_for_endpoint
2713
attr_accessor :links_on_demand
@@ -40,7 +26,6 @@ class Configuration
4026
def initialize
4127
@raise_on_missing_sideload = true
4228
@concurrency = false
43-
@concurrency_max_threads = 4
4429
@respond_to = [:json, :jsonapi, :xml]
4530
@links_on_demand = false
4631
@pagination_links_on_demand = false

lib/graphiti/scope.rb

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,6 @@ module Graphiti
22
class Scope
33
attr_accessor :object, :unpaginated_object
44
attr_reader :pagination
5-
6-
@@thread_pool_executor_mutex = Mutex.new
7-
8-
def self.thread_pool_executor
9-
return @thread_pool_executor if @thread_pool_executor
10-
11-
concurrency = Graphiti.config.concurrency_max_threads || 4
12-
@@thread_pool_executor_mutex.synchronize do
13-
@@thread_pool_executor ||= Concurrent::ThreadPoolExecutor.new(
14-
min_threads: 0,
15-
max_threads: concurrency,
16-
max_queue: concurrency * 4,
17-
fallback_policy: :caller_runs
18-
)
19-
end
20-
end
21-
225
def initialize(object, resource, query, opts = {})
236
@object = object
247
@resource = resource
@@ -66,7 +49,7 @@ def resolve_sideloads(results)
6649
@resource.adapter.close if concurrent
6750
}
6851
if concurrent
69-
promises << Concurrent::Promise.execute(executor: self.class.thread_pool_executor, &resolve_sideload)
52+
promises << Concurrent::Promise.execute(&resolve_sideload)
7053
else
7154
resolve_sideload.call
7255
end

spec/configuration_spec.rb

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -150,21 +150,6 @@
150150
end
151151
end
152152

153-
describe "#concurrency_max_threads" do
154-
include_context "with config", :concurrency_max_threads
155-
156-
it "defaults" do
157-
expect(Graphiti.config.concurrency_max_threads).to eq(4)
158-
end
159-
160-
it "is overridable" do
161-
Graphiti.configure do |c|
162-
c.concurrency_max_threads = 1
163-
end
164-
expect(Graphiti.config.concurrency_max_threads).to eq(1)
165-
end
166-
end
167-
168153
describe "#raise_on_missing_sideload" do
169154
include_context "with config", :raise_on_missing_sideload
170155

0 commit comments

Comments
 (0)