workhorse 1.0.0.beta0 → 1.0.0.beta1

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: 5dd13b11d5f7488e58812f57ad2bb70da07b95f18b89653687bf9ec579bbcaa5
4
- data.tar.gz: a0e7c53cf4de56b6109830decf16f6f70a8aead13ca703a795ce7709234c1b05
3
+ metadata.gz: 4e60ee9b02f73f0ecffe49df98f1d83e59d23f612d84e7a15232e7c95da15873
4
+ data.tar.gz: 3dcae37910f823e33af81b47ad4578a6e0294213b8c2eb5a01dca39762d8f9ca
5
5
  SHA512:
6
- metadata.gz: 2c6e9162d5b2735cd1de678b56e4c4e4960e25776a64cc45dfe5fbfee4fe0e50b1b3a5d15e81ca65ebfe496cce6ac4d81cfe1ba47a65b591a54916807bbe5c68
7
- data.tar.gz: a24094b51e7751010920e39ad6ac3924dbccdfb84f1728efec73ed1cc0e9376a873cdb2ff4a562f49d78b17ae08e5659fd596684b299fc35b8bdcd228be15f0e
6
+ metadata.gz: 6fd243a410f19deb78d09331e7e67e27438851b90ac99a9fcd4495cf33be832014f63c9c691a118da003e1bc4305e793a13dc8a3399885d69c168b39bc5c9d6e
7
+ data.tar.gz: 8b0407c7f00e05258a7f7a837c9246514afcb2a039dc3e68aeb7622fe929e9fc7f6b84a90de9026219d0acc87a7a8131effb49c43c791761d518410492e5c652
@@ -1,5 +1,13 @@
1
1
  # Workhorse Changelog
2
2
 
3
+ ## 1.0.0.beta1 - 2020-08-20
4
+
5
+ This is a stability release that is still experimental and has to be tested in
6
+ battle before it can be considered stable.
7
+
8
+ * Stop passing ActiveRecord job objects between polling and worker threads to
9
+ avoid AR race conditions. Now only IDs are passed between threads.
10
+
3
11
  ## 1.0.0.beta0 - 2020-08-19
4
12
 
5
13
  This is a stability release that is still experimental and has to be tested in
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0.beta0
1
+ 1.0.0.beta1
@@ -2,8 +2,8 @@ module Workhorse
2
2
  class Performer
3
3
  attr_reader :worker
4
4
 
5
- def initialize(db_job, worker)
6
- @db_job = db_job
5
+ def initialize(db_job_id, worker)
6
+ @db_job = Workhorse::DbJob.find(db_job_id)
7
7
  @worker = worker
8
8
  @started = false
9
9
  end
@@ -105,6 +105,8 @@ module Workhorse
105
105
  timeout = [MIN_LOCK_TIMEOUT, [MAX_LOCK_TIMEOUT, worker.polling_interval].min].max
106
106
 
107
107
  with_global_lock timeout: timeout do
108
+ job_ids = []
109
+
108
110
  Workhorse.tx_callback.call do
109
111
  # As we are the only thread posting into the worker pool, it is safe to
110
112
  # get the number of idle threads without mutex synchronization. The
@@ -119,10 +121,12 @@ module Workhorse
119
121
  jobs.each do |job|
120
122
  worker.log "Marking job #{job.id} as locked", :debug
121
123
  job.mark_locked!(worker.id)
122
- worker.perform job
124
+ job_ids << job.id
123
125
  end
124
126
  end
125
127
  end
128
+
129
+ job_ids.each { |job_id| worker.perform(job_id) }
126
130
  end
127
131
  end
128
132
 
@@ -127,14 +127,14 @@ module Workhorse
127
127
  @pool.idle
128
128
  end
129
129
 
130
- def perform(db_job)
130
+ def perform(db_job_id)
131
131
  mutex.synchronize do
132
132
  assert_state! :running
133
- log "Posting job #{db_job.id} to thread pool"
133
+ log "Posting job #{db_job_id} to thread pool"
134
134
 
135
135
  @pool.post do
136
136
  begin
137
- Workhorse::Performer.new(db_job, self).perform
137
+ Workhorse::Performer.new(db_job_id, self).perform
138
138
  rescue Exception => e
139
139
  log %(#{e.message}\n#{e.backtrace.join("\n")}), :error
140
140
  end
@@ -1,14 +1,14 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: workhorse 1.0.0.beta0 ruby lib
2
+ # stub: workhorse 1.0.0.beta1 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "workhorse".freeze
6
- s.version = "1.0.0.beta0"
6
+ s.version = "1.0.0.beta1"
7
7
 
8
8
  s.required_rubygems_version = Gem::Requirement.new("> 1.3.1".freeze) if s.respond_to? :required_rubygems_version=
9
9
  s.require_paths = ["lib".freeze]
10
10
  s.authors = ["Sitrox".freeze]
11
- s.date = "2020-08-19"
11
+ s.date = "2020-08-20"
12
12
  s.files = [".gitignore".freeze, ".releaser_config".freeze, ".rubocop.yml".freeze, ".travis.yml".freeze, "CHANGELOG.md".freeze, "FAQ.md".freeze, "Gemfile".freeze, "LICENSE".freeze, "README.md".freeze, "RUBY_VERSION".freeze, "Rakefile".freeze, "VERSION".freeze, "bin/rubocop".freeze, "lib/active_job/queue_adapters/workhorse_adapter.rb".freeze, "lib/generators/workhorse/install_generator.rb".freeze, "lib/generators/workhorse/templates/bin/workhorse.rb".freeze, "lib/generators/workhorse/templates/config/initializers/workhorse.rb".freeze, "lib/generators/workhorse/templates/create_table_jobs.rb".freeze, "lib/workhorse.rb".freeze, "lib/workhorse/daemon.rb".freeze, "lib/workhorse/daemon/shell_handler.rb".freeze, "lib/workhorse/db_job.rb".freeze, "lib/workhorse/enqueuer.rb".freeze, "lib/workhorse/jobs/cleanup_succeeded_jobs.rb".freeze, "lib/workhorse/jobs/detect_stale_jobs_job.rb".freeze, "lib/workhorse/jobs/run_active_job.rb".freeze, "lib/workhorse/jobs/run_rails_op.rb".freeze, "lib/workhorse/performer.rb".freeze, "lib/workhorse/poller.rb".freeze, "lib/workhorse/pool.rb".freeze, "lib/workhorse/scoped_env.rb".freeze, "lib/workhorse/worker.rb".freeze, "test/active_job/queue_adapters/workhorse_adapter_test.rb".freeze, "test/lib/db_schema.rb".freeze, "test/lib/jobs.rb".freeze, "test/lib/test_helper.rb".freeze, "test/workhorse/db_job_test.rb".freeze, "test/workhorse/enqueuer_test.rb".freeze, "test/workhorse/performer_test.rb".freeze, "test/workhorse/poller_test.rb".freeze, "test/workhorse/pool_test.rb".freeze, "test/workhorse/worker_test.rb".freeze, "workhorse.gemspec".freeze]
13
13
  s.rubygems_version = "3.0.3".freeze
14
14
  s.summary = "Multi-threaded job backend with database queuing for ruby.".freeze
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: workhorse
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.beta0
4
+ version: 1.0.0.beta1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sitrox
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-19 00:00:00.000000000 Z
11
+ date: 2020-08-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler