From 1bb8ecdaa45ba577315afe0d73a2cbb5970f0998 Mon Sep 17 00:00:00 2001 From: Andrei Kaleshka Date: Mon, 12 Feb 2024 13:48:20 +0100 Subject: [PATCH 1/8] Update README.md The text was a bit hard to understand for me. I hope this version is a bit better. --- README.md | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index df843f13..2bb0dd82 100644 --- a/README.md +++ b/README.md @@ -90,11 +90,9 @@ class ChargeCreditCard < Que::Job # Write any changes you'd like to the database. user.update charged_at: Time.now - # It's best to destroy the job in the same transaction as any other - # changes you make. Que will mark the job as destroyed for you after the - # run method if you don't do it yourself, but if your job writes to the DB - # but doesn't destroy the job in the same transaction, it's possible that - # the job could be repeated in the event of a crash. + # It's recommended to delete the job in the same transaction as any other changes you make. + # If you don't do so, Que will mark the job as destroyed for you after the run method outside the transaction. + # However, if you don't delete the job in the same transaction, it might be repeated in the event of a crash. destroy # If you'd rather leave the job record in the database to maintain a job From 1606023fb98d50ed591f445962779dddca57e556 Mon Sep 17 00:00:00 2001 From: Bogdanov Anton Date: Wed, 21 Feb 2024 15:27:44 +0300 Subject: [PATCH 2/8] update readme with link to Que::View --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index df843f13..1447f6fd 100644 --- a/README.md +++ b/README.md @@ -189,6 +189,7 @@ There are a couple ways to do testing. You may want to set `Que::Job.run_synchro These projects are tested to be compatible with Que 1.x: - [que-web](https://github.com/statianzo/que-web) is a Sinatra-based UI for inspecting your job queue. +- [que-view](https://github.com/kortirso/que-view) is a Rails engine-based UI for inspecting your job queue. - [que-scheduler](https://github.com/hlascelles/que-scheduler) lets you schedule tasks using a cron style config file. - [que-locks](https://github.com/airhorns/que-locks) lets you lock around job execution for so only one job runs at once for a set of arguments. - [que-unique](https://github.com/bambooengineering/que-unique) provides fast in-memory `enqueue` deduping. From a3d8beb8fff09298c23f82e35c5f498a1abd1424 Mon Sep 17 00:00:00 2001 From: David Cristofaro Date: Tue, 5 Mar 2024 11:38:22 +1100 Subject: [PATCH 3/8] Fix bundler in CI [Bundler 2.5 dropped support for Ruby 2.7](https://github.com/rubygems/rubygems/releases/tag/bundler-v2.5.0). Since we are testing with Ruby 2.7, we should pin the version of Bundler to 2.4.x since this is the last version that's compatible with 2.7. --- .github/workflows/tests.yml | 2 +- Dockerfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 41c814ef..77965ddc 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -45,7 +45,7 @@ jobs: run: | sudo apt-get -yqq install libpq-dev postgresql-client createdb que-test - gem install bundler + gem install bundler --version '~> 2.4.22' bundle install --jobs 4 --retry 3 USE_RAILS=true bundle exec rake test bundle exec rake test diff --git a/Dockerfile b/Dockerfile index cc85d0da..f10a61f9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,7 +5,7 @@ RUN apt-get update \ && apt-get install -y libpq-dev \ && rm -rf /var/lib/apt/lists/* -ENV RUBY_BUNDLER_VERSION 2.3.7 +ENV RUBY_BUNDLER_VERSION 2.4.22 RUN gem install bundler -v $RUBY_BUNDLER_VERSION ENV BUNDLE_PATH /usr/local/bundle From af6ed61f9bdcd9eaec80a9eb924d5e64a0b95700 Mon Sep 17 00:00:00 2001 From: Vladimir Lyzo Date: Tue, 30 Apr 2024 09:30:29 +1000 Subject: [PATCH 4/8] fix server? method --- lib/que.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/que.rb b/lib/que.rb index 89459472..99c2686c 100644 --- a/lib/que.rb +++ b/lib/que.rb @@ -80,7 +80,7 @@ def default_queue end def server? - defined?(Que::CommandLineInterface).nil? + !defined?(Que::CommandLineInterface).nil? end # Support simple integration with many common connection pools. From 7bf4ff5c7b2ec97e2d2c0e21d32af95bd4fe2d6d Mon Sep 17 00:00:00 2001 From: Owen Stephens Date: Wed, 24 Jul 2024 12:04:29 +0100 Subject: [PATCH 5/8] Log full job details rather than just job_id A partial revert of https://github.com/que-rb/que/commit/c43eb24aebcc5054c299cfed00690fce9add36ac which didn't include any reasoning/justification for the log simplification. It's useful to be able to log details of the job, particularly the job_class and arguments; if this additional detail isn't desired then it can be removed by using a custom `Que.log_formatter`, for example: ```ruby Que.log_formatter = proc do |data| if (job = data.delete(:job)) data[:job_id] = job[:id] end JSON.dump(data) end ``` --- docs/README.md | 2 +- lib/que/worker.rb | 4 ++-- spec/que/worker_spec.rb | 5 +++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/docs/README.md b/docs/README.md index 4b5e1f46..fef84b67 100644 --- a/docs/README.md +++ b/docs/README.md @@ -349,7 +349,7 @@ que --worker-count 1 By default, Que logs important information in JSON to either Rails' logger (when running in a Rails web process) or STDOUT (when running via the `que` executable). So, your logs will look something like: ``` -I, [2017-08-12T05:07:31.094201 #4687] INFO -- : {"lib":"que","hostname":"lovelace","pid":21626,"thread":21471100,"event":"job_worked","job_id":6157665,"elapsed":0.531411} +I, [2017-08-12T05:07:31.094201 #4687] INFO -- : {"lib":"que","hostname":"lovelace","pid":98240,"thread":42660,"event":"job_worked","job":{"priority":1,"run_at":"2024-07-24T11:07:10.056514Z","id":2869885284504751564,"job_class":"WorkerJob","error_count":0,"last_error_message":null,"queue":"default","last_error_backtrace":null,"finished_at":null,"expired_at":null,"args":[1],"data":{},"job_schema_version":2,"kwargs":{}},"elapsed":0.001356} ``` Of course you can have it log wherever you like: diff --git a/lib/que/worker.rb b/lib/que/worker.rb index 91e7d02a..00ef19aa 100644 --- a/lib/que/worker.rb +++ b/lib/que/worker.rb @@ -114,7 +114,7 @@ def work_job(metajob) if VALID_LOG_LEVELS.include?(log_level) log_message = { level: log_level, - job_id: metajob.id, + job: metajob.job, elapsed: elapsed, } @@ -133,7 +133,7 @@ def work_job(metajob) Que.log( level: :debug, event: :job_errored, - job_id: metajob.id, + job: metajob.job, error: { class: error.class.to_s, message: error.message, diff --git a/spec/que/worker_spec.rb b/spec/que/worker_spec.rb index 435e213f..c5851701 100644 --- a/spec/que/worker_spec.rb +++ b/spec/que/worker_spec.rb @@ -74,7 +74,8 @@ def finished_job_ids events = logged_messages.select{|m| m[:event] == 'job_worked'} assert_equal 3, events.count - assert_equal job_ids, events.map{|m| m[:job_id]} + assert_equal [1, 2, 3], events.map{|m| m.dig(:job, :priority) } + assert_equal job_ids, events.map{|m| m.dig(:job, :id) } end it "should handle namespaced job subclasses" do @@ -228,7 +229,7 @@ def assert_retry_cadence( # Error should be logged. event = events.first - assert_equal job_ids.first, event[:job_id] + assert_equal job_ids.first, event.dig(:job, :id) assert_equal "RuntimeError: Error!", event[:error] # Errored job should still be in the DB. From 3efe0e4bbd14942145661ff4bf81ed3ba3309d3f Mon Sep 17 00:00:00 2001 From: Andrei Kaleshka Date: Wed, 24 Jul 2024 16:45:35 +0200 Subject: [PATCH 6/8] Update README.md --- README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 2bb0dd82..4ce4ccd8 100644 --- a/README.md +++ b/README.md @@ -90,9 +90,11 @@ class ChargeCreditCard < Que::Job # Write any changes you'd like to the database. user.update charged_at: Time.now - # It's recommended to delete the job in the same transaction as any other changes you make. - # If you don't do so, Que will mark the job as destroyed for you after the run method outside the transaction. - # However, if you don't delete the job in the same transaction, it might be repeated in the event of a crash. + # It's best to destroy the job in the same transaction as any other + # changes you make. Que will mark the job as destroyed for you after the + # run method if you don't do it yourself; however if your job writes to the DB + # but doesn't destroy the job in the same transaction, it's possible that + # the job could be repeated in the event of a crash. destroy # If you'd rather leave the job record in the database to maintain a job From 9a1d634d1368eb79342e5b156ef6f909d05faaaa Mon Sep 17 00:00:00 2001 From: Brendan Weibrecht Date: Wed, 21 Aug 2024 00:27:46 +1000 Subject: [PATCH 7/8] Update version number to 2.4.0 --- lib/que/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/que/version.rb b/lib/que/version.rb index ea6873f8..1da80ed9 100644 --- a/lib/que/version.rb +++ b/lib/que/version.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module Que - VERSION = '2.3.0' + VERSION = '2.4.0' def self.job_schema_version 2 From 51403c0054b2a94b55e4977a334b54993ab96f86 Mon Sep 17 00:00:00 2001 From: Brendan Weibrecht Date: Wed, 21 Aug 2024 00:53:25 +1000 Subject: [PATCH 8/8] Changelog: Add entry for version 2.4.0 --- CHANGELOG.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 68d4ee3e..0524328a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,8 @@ -- [2.3.0 \(2023-10-10\)](#230-2023-10-16) +- [2.4.0 \(2024-08-21\)](#240-2024-08-21) +- [2.3.0 \(2023-10-16\)](#230-2023-10-16) - [2.2.1 \(2023-04-28\)](#221-2023-04-28) - [2.2.0 \(2022-08-29\)](#220-2022-08-29) - [2.1.0 \(2022-08-25\)](#210-2022-08-25) @@ -58,7 +59,18 @@ +## 2.4.0 (2024-08-21) + +- **Fixed**: + + Fixed `Que.server?` method returning the inverse of what was intended. This method can be used to determine whether Que is running as a server process (run from the Que CLI). [#426](https://github.com/que-rb/que/pull/426), context in [#382](https://github.com/que-rb/que/pull/382) +- **Added**: + + Added logging of full job details rather than just `job_id`. Note that the hash `Que.log_formatter` is called with no longer contains `:job_id`; instead it now has a `:job` hash including `:id`. [#428](https://github.com/que-rb/que/pull/428) +- **Documentation**: + + Improved wording of transaction recommendation in the readme for destroying a job. [#417](https://github.com/que-rb/que/pull/417) + + Added [que-view](https://github.com/kortirso/que-view) to the list of Que-compatible projects in the readme: "A Rails engine-based UI for inspecting your job queue". [#418](https://github.com/que-rb/que/pull/418) + ## 2.3.0 (2023-10-16) + - **Fixed**: + Don't clear `ActiveRecord` connections when `run_synchronously` is enabled [#393](https://github.com/que-rb/que/pull/393)