que 0.11.3 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (114) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/tests.yml +51 -0
  3. data/.gitignore +2 -0
  4. data/.ruby-version +1 -0
  5. data/CHANGELOG.md +502 -97
  6. data/Dockerfile +20 -0
  7. data/LICENSE.txt +1 -1
  8. data/README.md +205 -59
  9. data/auto/dev +21 -0
  10. data/auto/pre-push-hook +30 -0
  11. data/auto/psql +9 -0
  12. data/auto/test +5 -0
  13. data/auto/test-postgres-14 +17 -0
  14. data/bin/que +8 -81
  15. data/docker-compose.yml +47 -0
  16. data/docs/README.md +881 -0
  17. data/lib/que/active_job/extensions.rb +114 -0
  18. data/lib/que/active_record/connection.rb +51 -0
  19. data/lib/que/active_record/model.rb +48 -0
  20. data/lib/que/command_line_interface.rb +259 -0
  21. data/lib/que/connection.rb +198 -0
  22. data/lib/que/connection_pool.rb +78 -0
  23. data/lib/que/job.rb +210 -103
  24. data/lib/que/job_buffer.rb +255 -0
  25. data/lib/que/job_methods.rb +176 -0
  26. data/lib/que/listener.rb +176 -0
  27. data/lib/que/locker.rb +507 -0
  28. data/lib/que/metajob.rb +47 -0
  29. data/lib/que/migrations/4/down.sql +48 -0
  30. data/lib/que/migrations/4/up.sql +267 -0
  31. data/lib/que/migrations/5/down.sql +73 -0
  32. data/lib/que/migrations/5/up.sql +76 -0
  33. data/lib/que/migrations/6/down.sql +8 -0
  34. data/lib/que/migrations/6/up.sql +8 -0
  35. data/lib/que/migrations/7/down.sql +5 -0
  36. data/lib/que/migrations/7/up.sql +13 -0
  37. data/lib/que/migrations.rb +37 -18
  38. data/lib/que/poller.rb +274 -0
  39. data/lib/que/rails/railtie.rb +12 -0
  40. data/lib/que/result_queue.rb +35 -0
  41. data/lib/que/sequel/model.rb +52 -0
  42. data/lib/que/utils/assertions.rb +62 -0
  43. data/lib/que/utils/constantization.rb +19 -0
  44. data/lib/que/utils/error_notification.rb +68 -0
  45. data/lib/que/utils/freeze.rb +20 -0
  46. data/lib/que/utils/introspection.rb +50 -0
  47. data/lib/que/utils/json_serialization.rb +21 -0
  48. data/lib/que/utils/logging.rb +79 -0
  49. data/lib/que/utils/middleware.rb +46 -0
  50. data/lib/que/utils/queue_management.rb +18 -0
  51. data/lib/que/utils/ruby2_keywords.rb +19 -0
  52. data/lib/que/utils/transactions.rb +34 -0
  53. data/lib/que/version.rb +5 -1
  54. data/lib/que/worker.rb +145 -149
  55. data/lib/que.rb +103 -159
  56. data/que.gemspec +17 -4
  57. data/scripts/docker-entrypoint +14 -0
  58. data/scripts/test +6 -0
  59. metadata +59 -95
  60. data/.rspec +0 -2
  61. data/.travis.yml +0 -17
  62. data/Gemfile +0 -24
  63. data/docs/advanced_setup.md +0 -106
  64. data/docs/customizing_que.md +0 -200
  65. data/docs/error_handling.md +0 -47
  66. data/docs/inspecting_the_queue.md +0 -114
  67. data/docs/logging.md +0 -50
  68. data/docs/managing_workers.md +0 -80
  69. data/docs/migrating.md +0 -30
  70. data/docs/multiple_queues.md +0 -27
  71. data/docs/shutting_down_safely.md +0 -7
  72. data/docs/using_plain_connections.md +0 -41
  73. data/docs/using_sequel.md +0 -31
  74. data/docs/writing_reliable_jobs.md +0 -117
  75. data/lib/generators/que/install_generator.rb +0 -24
  76. data/lib/generators/que/templates/add_que.rb +0 -13
  77. data/lib/que/adapters/active_record.rb +0 -54
  78. data/lib/que/adapters/base.rb +0 -127
  79. data/lib/que/adapters/connection_pool.rb +0 -16
  80. data/lib/que/adapters/pg.rb +0 -21
  81. data/lib/que/adapters/pond.rb +0 -16
  82. data/lib/que/adapters/sequel.rb +0 -20
  83. data/lib/que/railtie.rb +0 -16
  84. data/lib/que/rake_tasks.rb +0 -59
  85. data/lib/que/sql.rb +0 -152
  86. data/spec/adapters/active_record_spec.rb +0 -152
  87. data/spec/adapters/connection_pool_spec.rb +0 -22
  88. data/spec/adapters/pg_spec.rb +0 -41
  89. data/spec/adapters/pond_spec.rb +0 -22
  90. data/spec/adapters/sequel_spec.rb +0 -57
  91. data/spec/gemfiles/Gemfile1 +0 -18
  92. data/spec/gemfiles/Gemfile2 +0 -18
  93. data/spec/spec_helper.rb +0 -118
  94. data/spec/support/helpers.rb +0 -19
  95. data/spec/support/jobs.rb +0 -35
  96. data/spec/support/shared_examples/adapter.rb +0 -37
  97. data/spec/support/shared_examples/multi_threaded_adapter.rb +0 -46
  98. data/spec/travis.rb +0 -23
  99. data/spec/unit/connection_spec.rb +0 -14
  100. data/spec/unit/customization_spec.rb +0 -251
  101. data/spec/unit/enqueue_spec.rb +0 -245
  102. data/spec/unit/helper_spec.rb +0 -12
  103. data/spec/unit/logging_spec.rb +0 -101
  104. data/spec/unit/migrations_spec.rb +0 -84
  105. data/spec/unit/pool_spec.rb +0 -365
  106. data/spec/unit/run_spec.rb +0 -14
  107. data/spec/unit/states_spec.rb +0 -50
  108. data/spec/unit/stats_spec.rb +0 -46
  109. data/spec/unit/transaction_spec.rb +0 -36
  110. data/spec/unit/work_spec.rb +0 -407
  111. data/spec/unit/worker_spec.rb +0 -167
  112. data/tasks/benchmark.rb +0 -3
  113. data/tasks/rspec.rb +0 -14
  114. data/tasks/safe_shutdown.rb +0 -67
data/CHANGELOG.md CHANGED
@@ -1,193 +1,598 @@
1
- ### 0.11.3 (2016-02-26)
1
+ # Changelog
2
+
3
+ <!-- MarkdownTOC autolink=true -->
4
+
5
+ - [2.2.0 \(2022-08-29\)](#220-2022-08-29)
6
+ - [2.1.0 \(2022-08-25\)](#210-2022-08-25)
7
+ - [2.0.0 \(2022-08-25\)](#200-2022-08-25)
8
+ - [1.4.1 \(2022-07-24\)](#141-2022-07-24)
9
+ - [2.0.0.beta1 \(2022-03-24\)](#200beta1-2022-03-24)
10
+ - [1.4.0 \(2022-03-23\)](#140-2022-03-23)
11
+ - [1.3.1 \(2022-02-25\)](#131-2022-02-25)
12
+ - [1.3.0 \(2022-02-25\)](#130-2022-02-25)
13
+ - [1.2.0 \(2022-02-23\)](#120-2022-02-23)
14
+ - [1.1.0 \(2022-02-21\)](#110-2022-02-21)
15
+ - [1.0.0 \(2022-01-24\)](#100-2022-01-24)
16
+ - [1.0.0.beta5 \(2021-12-23\)](#100beta5-2021-12-23)
17
+ - [1.0.0.beta4 \(2020-01-17\)](#100beta4-2020-01-17)
18
+ - [1.0.0.beta3 \(2018-05-18\)](#100beta3-2018-05-18)
19
+ - [1.0.0.beta2 \(2018-04-13\)](#100beta2-2018-04-13)
20
+ - [1.0.0.beta \(2017-10-25\)](#100beta-2017-10-25)
21
+ - [0.14.3 \(2018-03-02\)](#0143-2018-03-02)
22
+ - [0.14.2 \(2018-01-05\)](#0142-2018-01-05)
23
+ - [0.14.1 \(2017-12-14\)](#0141-2017-12-14)
24
+ - [0.14.0 \(2017-08-11\)](#0140-2017-08-11)
25
+ - [0.13.1 \(2017-07-05\)](#0131-2017-07-05)
26
+ - [0.13.0 \(2017-06-08\)](#0130-2017-06-08)
27
+ - [0.12.3 \(2017-06-01\)](#0123-2017-06-01)
28
+ - [0.12.2 \(2017-06-01\)](#0122-2017-06-01)
29
+ - [0.12.1 \(2017-01-22\)](#0121-2017-01-22)
30
+ - [0.12.0 \(2016-09-09\)](#0120-2016-09-09)
31
+ - [0.11.6 \(2016-07-01\)](#0116-2016-07-01)
32
+ - [0.11.5 \(2016-05-13\)](#0115-2016-05-13)
33
+ - [0.11.4 \(2016-03-03\)](#0114-2016-03-03)
34
+ - [0.11.3 \(2016-02-26\)](#0113-2016-02-26)
35
+ - [0.11.2 \(2015-09-09\)](#0112-2015-09-09)
36
+ - [0.11.1 \(2015-09-04\)](#0111-2015-09-04)
37
+ - [0.11.0 \(2015-09-04\)](#0110-2015-09-04)
38
+ - [0.10.0 \(2015-03-18\)](#0100-2015-03-18)
39
+ - [0.9.2 \(2015-02-05\)](#092-2015-02-05)
40
+ - [0.9.1 \(2015-01-11\)](#091-2015-01-11)
41
+ - [0.9.0 \(2014-12-16\)](#090-2014-12-16)
42
+ - [0.8.2 \(2014-10-12\)](#082-2014-10-12)
43
+ - [0.8.1 \(2014-07-28\)](#081-2014-07-28)
44
+ - [0.8.0 \(2014-07-12\)](#080-2014-07-12)
45
+ - [0.7.3 \(2014-05-19\)](#073-2014-05-19)
46
+ - [0.7.2 \(2014-05-18\)](#072-2014-05-18)
47
+ - [0.7.1 \(2014-04-29\)](#071-2014-04-29)
48
+ - [0.7.0 \(2014-04-09\)](#070-2014-04-09)
49
+ - [0.6.0 \(2014-02-04\)](#060-2014-02-04)
50
+ - [0.5.0 \(2014-01-14\)](#050-2014-01-14)
51
+ - [0.4.0 \(2014-01-05\)](#040-2014-01-05)
52
+ - [0.3.0 \(2013-12-21\)](#030-2013-12-21)
53
+ - [0.2.0 \(2013-11-30\)](#020-2013-11-30)
54
+ - [0.1.0 \(2013-11-18\)](#010-2013-11-18)
55
+ - [0.0.1 \(2013-11-07\)](#001-2013-11-07)
56
+
57
+ <!-- /MarkdownTOC -->
58
+
59
+ ## 2.2.0 (2022-08-29)
60
+
61
+ - **Changed**:
62
+ + When migrating, now raises an exception when the Que DB schema version is missing from the database. The migrations system records this version in a comment on the `que_jobs` table. [#379](https://github.com/que-rb/que/pull/379)
63
+ * > Que::Error: Cannot determine Que DB schema version.
64
+ >
65
+ > The que_jobs table is missing its comment recording the Que DB schema version. This is likely due to a bug in Rails schema dump in Rails 7 versions prior to 7.0.3, omitting comments - see https://github.com/que-rb/que/issues/363. Please determine the appropriate schema version from your migrations and record it manually by running the following SQL (replacing version as appropriate):
66
+ >
67
+ > COMMENT ON TABLE que_jobs IS 'version';
68
+ - **Removed**:
69
+ + Removed support for upgrading directly from a version of Que prior to v0.5.0 (released on 2014-01-14), which introduced the migrations system. It's too difficult to handle the different DB schemas from prior to this.
70
+ - **Internal**:
71
+ + Moved `command_line_interface.rb` from `bin/` to `lib/`. [#378](https://github.com/que-rb/que/pull/378)
72
+
73
+ ## 2.1.0 (2022-08-25)
74
+
75
+ - **Added**:
76
+ + Added bulk enqueue interface for performance when enqueuing a large number of jobs at once - [docs](docs#enqueueing-jobs-in-bulk).
77
+ - **Deprecated**:
78
+ + Deprecated `que_state_notify` trigger (`que_state` notification channel / `job_change` notification message). See [#372](https://github.com/que-rb/que/issues/372). We plan to remove this in a future release - let us know on the issue if you desire otherwise.
79
+
80
+ This release contains a database migration. You will need to migrate Que to the latest database schema version (7). For example, on ActiveRecord and Rails 6:
81
+
82
+ ```ruby
83
+ class UpdateQueTablesToVersion7 < ActiveRecord::Migration[6.0]
84
+ def up
85
+ Que.migrate!(version: 7)
86
+ end
87
+
88
+ def down
89
+ Que.migrate!(version: 6)
90
+ end
91
+ end
92
+ ```
93
+
94
+ ## 2.0.0 (2022-08-25)
95
+
96
+ **Important: Do not upgrade straight to Que 2.** You will need to first update to the latest 1.x version, apply the Que database schema migration, and deploy, before you can safely begin the process of upgrading to Que 2. See the [2.0.0.beta1 changelog entry](#200beta1-2022-03-24) for details.
97
+
98
+ See beta 2.0.0.beta1, plus:
99
+
100
+ - **Fixed**:
101
+ + Updated to use non-deprecated method from PG when params are passed (`#async_exec_params`). [#374](https://github.com/que-rb/que/pull/374)
102
+
103
+ Note that @dtcristo submitted a PR proposing an easier upgrade path to Que 2 and Ruby 3 - [#365](https://github.com/que-rb/que/pull/365). We are yet to properly consider this, but a later release which includes this feature would mean you don't need to simultaneously deploy Que 1.x and 2.x workers during the upgrade.
104
+
105
+ ## 1.4.1 (2022-07-24)
106
+
107
+ - **Added**
108
+ + Added Ruby version requirement of < 3. For Ruby 3 compatibility, upgrade to Que 2 - [upgrade process](https://github.com/que-rb/que/blob/master/CHANGELOG.md#200beta1-2022-03-24)
109
+
110
+ ## 2.0.0.beta1 (2022-03-24)
111
+
112
+ **Preliminary release of Ruby 3 support**
113
+
114
+ **Notable changes**:
115
+
116
+ * Support for Ruby 3 introduced
117
+ * Database schema has changed to split the job arguments `args` column into `args` and `kwargs` columns, for reliable args and kwargs splitting for Ruby 3.
118
+ - The job schema version is now 2. Note that job schema version is distinct from database schema version and Que version. The `job_schema_version` column of the `que_jobs` table no longer defaults and has a not null constraint, so when manually inserting jobs into the table, this must be specified as `2`. If you have a gem that needs to support multiple Que versions, best not to blindly use the value of `Que.job_schema_version`; instead have different code paths depending on the value of `Que.job_schema_version`. You could also use this to know whether keyword arguments are in `args` or `kwargs`.
119
+ * Passing a hash literal as the last job argument to be splatted into job keyword arguments is no longer supported.
120
+ * Dropped support for providing job options as top-level keyword arguments to `Job.enqueue`, i.e. `queue`, `priority`, `run_at`, `job_class`, and `tags`. Job options now need to be nested under the `job_options` keyword argument instead. See [#336](https://github.com/que-rb/que/pull/336)
121
+ * Dropped support for Ruby < 2.7
122
+ * Dropped support for Rails < 6.0
123
+ * The `#by_args` method on the Job model (for both Sequel and ActiveRecord) now searches based on both args and kwargs, but it performs a subset match instead of an exact match. For instance, if your job was scheduled with `'a', 'b', 'c', foo: 'bar', baz: 1`, `by_args('a', 'b', baz: 1)` would find and return the job.
124
+ * This release contains a database migration. You will need to migrate Que to the latest database schema version (6). For example, on ActiveRecord and Rails 6:
2
125
 
3
- * Fixed bug with displaying the current version of the que executable. (#122) (hardbap)
126
+ ```ruby
127
+ class UpdateQueTablesToVersion6 < ActiveRecord::Migration[6.0]
128
+ def up
129
+ Que.migrate!(version: 6)
130
+ end
4
131
 
5
- * Output to STDOUT when running via the executable or rake task is no longer buffered. This prevented logging in some cases. (#129) (hmarr)
132
+ def down
133
+ Que.migrate!(version: 5)
134
+ end
135
+ end
136
+ ```
6
137
 
7
- * Officially added support for Ruby 2.2 and 2.3.
138
+ **Recommended upgrade process**:
8
139
 
9
- * String literals are now frozen on Ruby 2.3.
140
+ When using Que 2.x, a job enqueued with Ruby 2.7 will run as expected on Ruby 3. We recommend:
10
141
 
11
- ### 0.11.2 (2015-09-09)
142
+ 1. Upgrade your project to the latest 1.x version of Que (1.3.1+)
143
+ - IMPORTANT: adds support for zero downtime upgrade to Que 2.x, see changelog below
144
+ 2. Upgrade your project to Ruby 2.7 and Rails 6.x if it is not already
145
+ 3. Upgrade your project to Que 2.x but stay on Ruby 2.7
146
+ - IMPORTANT: You will need to continue to run Que 1.x workers until all jobs enqueued using Que 1.x (i.e. with a `job_schema_version` of `1`) have been finished. See below
147
+ 4. Upgrade your project to Ruby 3
12
148
 
13
- * Fix Job class constantizing when ActiveSupport isn't loaded. (#121) (godfat)
149
+ *NOTES:*
14
150
 
15
- ### 0.11.1 (2015-09-04)
151
+ * If you were already running Ruby 2.7 and were not passing a hash literal as the last job argument, you *may* be able to upgrade a running system without draining the queue, though this is not recommended.
152
+ * For all other cases, you will need to follow the recommended process above or first completely drain the queue (stop enqueuing new jobs and finish processing any jobs in the database, including cleaning out any expired jobs) before upgrading.
16
153
 
17
- * The `rake que:work` rake task that was specific to Rails has been deprecated and will be removed in Que 1.0. A deprecation warning will display when it is run.
154
+ **Deploying Que 1.x and 2.x workers simultaneously**:
18
155
 
19
- ### 0.11.0 (2015-09-04)
156
+ To run workers with two different versions of Que, you'll probably need to temporarily duplicate your gem bundle, with the Que version being the only difference. e.g.:
20
157
 
21
- * A command-line program has been added that can be used to work jobs in a more flexible manner than the previous rake task. Run `que -h` for more information.
158
+ - Copy your `Gemfile` and `Gemfile.lock` into a directory called `que-1-gemfile`
159
+ - Set a suitable Que version in each `Gemfile`
160
+ - Update the bundle at `que-1-gemfile/Gemfile.lock` using `BUNDLE_GEMFILE=que-1-gemfile/Gemfile bundle`
161
+ - Create a second deployment of Que, but with your `que` command prefixed with `BUNDLE_GEMFILE=que-1-gemfile/Gemfile`
22
162
 
23
- * The worker pool will no longer start automatically in the same process when running the rails server - this behavior was too prone to breakage. If you'd like to recreate the old behavior, you can manually set `Que.mode = :async` in your app whenever conditions are appropriate (classes have loaded, a database connection has been established, and the process will not be forking).
163
+ We'd appreciate feedback on your experience upgrading to and running Que 2. Feel free to post on our Discord, or if you run into trouble, open an issue on GitHub.
24
164
 
25
- * Add a Que.disable_prepared_transactions= configuration option, to make it easier to use tools like pgbouncer. (#110)
165
+ ## 1.4.0 (2022-03-23)
26
166
 
27
- * Add a Que.json_converter= option, to configure how arguments are transformed before being passed to the job. By default this is set to the `Que::INDIFFERENTIATOR` proc, which provides simple indifferent access (via strings or symbols) to args hashes. If you're using Rails, the default is to convert the args to HashWithIndifferentAccess instead. You can also pass it the Que::SYMBOLIZER proc, which will destructively convert all keys in the args hash to symbols (this will probably be the default in Que 1.0). If you want to define a custom converter, you will usually want to pass this option a proc, and you'll probably want it to be recursive. See the implementations of Que::INDIFFERENTIATOR and Que::SYMBOLIZER for examples. (#113)
167
+ - **Fixed**
168
+ + The poller will no longer sleep when jobs exist for only some of its priorities. It now skips sleeping when a poll returns more jobs than the lowest priority requested. [#349](https://github.com/que-rb/que/pull/349).
169
+ * An alternative was considered which skipped polling when only some of the waiting worker priorities would be fully utilised ([diagram explanation](https://github.com/que-rb/que/pull/348#discussion_r819213357)); but this was decided against for code complexity reasons. [#348](https://github.com/que-rb/que/pull/348)
170
+ - **Deprecated**:
171
+ + Deprecated `--minimum-buffer-size` option. It was not actually used, and will be removed in v2.0.0. [#346](https://github.com/que-rb/que/pull/346)
172
+ * It became used in 1.0.0.beta4, and that changelog entry has been updated to reflect this.
173
+ - **Documentation**:
174
+ + Reformatted the changelog to be more consistent, including adding links to all issue/PR numbers. [#347](https://github.com/que-rb/que/pull/347)
28
175
 
29
- * When using Que with ActiveRecord, workers now call `ActiveRecord::Base.clear_active_connections!` between jobs. This cleans up connections that ActiveRecord leaks when it is used to access mutliple databases. (#116)
176
+ ## 1.3.1 (2022-02-25)
30
177
 
31
- * If it exists, use String#constantize to constantize job classes, since ActiveSupport's constantize method behaves better with Rails' autoloading. (#115, #120) (joevandyk)
178
+ Unfortunately, v1.3.0 was broken. Follow its upgrade instructions, but use this version instead.
32
179
 
33
- ### 0.10.0 (2015-03-18)
180
+ - **Fixed**
181
+ + Fixed startup error: `undefined method 'job_schema_version' for Que:Module`, in [#343](https://github.com/que-rb/que/pull/343)
34
182
 
35
- * When working jobs via the rake task, Rails applications are now eager-loaded if present, to avoid problems with multithreading and autoloading. (#96) (hmarr)
183
+ ## 1.3.0 (2022-02-25)
36
184
 
37
- * The que:work rake task now uses whatever logger Que is configured to use normally, rather than forcing the use of STDOUT. (#95)
185
+ **ACTION REQUIRED**
38
186
 
39
- * Add Que.transaction() helper method, to aid in transaction management in migrations or when the user's ORM doesn't provide one. (#81)
187
+ This release will allow you to safely upgrade to Que 2 when it comes out, without first needing to empty your `que_jobs` table.
40
188
 
41
- ### 0.9.2 (2015-02-05)
189
+ **You will need to first update to this version, apply the Que schema migration, and deploy, before you can safely begin the process of upgrading to Que 2.**
42
190
 
43
- * Fix a bug wherein the at_exit hook in the railtie wasn't waiting for jobs to finish before exiting.
191
+ Que 2 will bring Ruby 3 support, but to do that, the job arguments in the `que_jobs` table will need to be split into two columns - repurposing the existing one for positional arguments only (`args`), and adding a new one for keyword arguments (`kwargs`). This is so that Que running in Ruby 3, when reading job arguments stored in the database, can disambiguate between keyword arguments and a last positional argument hash.
44
192
 
45
- * Fix a bug wherein the que:work rake task wasn't waiting for jobs to finish before exiting. (#85) (tycooon)
193
+ The args split hasn't happened yet, but when it does, we still need to be able to successfully process all the existing queued jobs which have their keyword arguments in the `args` column still. Our solution is for you to have both Que 1 workers and Que 2 workers operating simultaneously during the upgrade, each processing only the jobs enqueued from that version. Once all the Que 1 jobs are processed, the Que 1 workers can be retired.
46
194
 
47
- ### 0.9.1 (2015-01-11)
195
+ To allow the different worker versions to tell which jobs belong to which, we've added a new column to the `que_jobs` table in this version, `job_schema_version`. Jobs enqueued with Que 1 will have a `1` here, and jobs from Que 2 will have a `2`. Que schema migration 5 will default the job schema version of all existing jobs to `1`.
48
196
 
49
- * Use now() rather than 'now' when inserting jobs, to avoid using an old value as the default run_at in prepared statements. (#74) (bgentry)
197
+ You will need to migrate Que to the latest Que schema version (5). For instance, on ActiveRecord and Rails 6:
50
198
 
51
- ### 0.9.0 (2014-12-16)
199
+ ```ruby
200
+ class UpdateQueTablesToVersion5 < ActiveRecord::Migration[6.0]
201
+ def up
202
+ Que.migrate!(version: 5)
203
+ end
204
+ def down
205
+ Que.migrate!(version: 4)
206
+ end
207
+ end
208
+ ```
209
+
210
+ You must apply the schema migration and deploy to upgrade all workers.
211
+
212
+ No further action is required from you at this stage. The Que 2 release changelog will provide full upgrade instructions for the process briefly described above of simultaneously running both Que 1 & 2 workers. Note that you won't be required to upgrade from Ruby 2.7 to Ruby 3 at the same time as upgrading to Que 2.
213
+
214
+ If you use any Que plugins or custom code that interacts with the `que_jobs` table, before you can upgrade to Que 2, you will need to make sure they are updated for compatibility with Que 2: They'll need to make use of the `kwargs` column, and when inserting jobs, put a `2` into the `job_schema_version` column rather than continue to rely on its soon-to-be-removed default of `1`.
215
+
216
+ **Other improvements**:
217
+
218
+ - **Features**:
219
+ + Log config on startup, in [#337](https://github.com/que-rb/que/pull/337)
220
+ - **Internal**:
221
+ + Added Git pre-push hook, in [#338](https://github.com/que-rb/que/pull/338)
222
+ + Documented our gem release process, in [#341](https://github.com/que-rb/que/pull/341)
223
+
224
+ ## 1.2.0 (2022-02-23)
225
+
226
+ - **Deprecated**
227
+ + Providing job options as top level keyword arguments to Job.enqueue is now deprecated. Support will be dropped in `2.0`. Job options should be nested under the `job_options` keyword arg instead. See [#336](https://github.com/que-rb/que/pull/336)
228
+
229
+ ## 1.1.0 (2022-02-21)
230
+
231
+ - **Features**:
232
+ + Add backtrace to errors, by [@trammel](https://github.com/trammel) in [#328](https://github.com/que-rb/que/pull/328)
233
+ - **Internal**:
234
+ + Add Dockerised development environment, in [#324](https://github.com/que-rb/que/pull/324)
235
+
236
+ ## 1.0.0 (2022-01-24)
237
+
238
+ _This release does not add any changes on top of 1.0.0.beta5._
239
+
240
+ ## 1.0.0.beta5 (2021-12-23)
241
+
242
+ - **Bug fixes and improvements**
243
+ + Add more context to error message when config files fail to load. by [@trammel](https://github.com/trammel) in [#293](https://github.com/que-rb/que/pull/293)
244
+ + Fix lock leak on PostgreSQL 12 and later by [@jasoncodes](https://github.com/jasoncodes) in [#298](https://github.com/que-rb/que/pull/298)
245
+ + Fix deadlock issue [#318](https://github.com/que-rb/que/pull/318)
246
+ + Fix thread attrition issue [#321](https://github.com/que-rb/que/pull/321)
247
+ - **Rails fixes:**
248
+ + Set schema in table_name for ActiveRecord model by [@nikitug](https://github.com/nikitug) in [#274](https://github.com/que-rb/que/pull/274)
249
+ - **Documentation:**
250
+ + Add link to que-locks for exclusive job locking by [@airhorns](https://github.com/airhorns) in [#263](https://github.com/que-rb/que/pull/263)
251
+ [`5259303`](https://github.com/que-rb/que/commit/52593031a7eef2d52ac38eceb2d8df776ec74090)
252
+ + Fix links to Writing Reliable Jobs by [@nikitug](https://github.com/nikitug) in [#273](https://github.com/que-rb/que/pull/273)
253
+ + Add build badge to README by [@jonathanhefner](https://github.com/jonathanhefner) in [#278](https://github.com/que-rb/que/pull/278)
254
+ + Fix ToC links in docs by [@swrobel](https://github.com/swrobel) in [#287](https://github.com/que-rb/que/pull/287)
255
+ + Note all Rails queue names that must be changed by [@swrobel](https://github.com/swrobel) in [#296](https://github.com/que-rb/que/pull/296)
256
+ + Add instructions for how to start Que by [@xcskier56](https://github.com/xcskier56) in [#292](https://github.com/que-rb/que/pull/292)
257
+ - **CI/tests**
258
+ + Fix CI failure from Docker Postgres image by [@jonathanhefner](https://github.com/jonathanhefner) in [#275](https://github.com/que-rb/que/pull/275)
259
+ + Test with Ruby 2.7 by [@jonathanhefner](https://github.com/jonathanhefner) in [#276](https://github.com/que-rb/que/pull/276)
260
+ + Run GitHub build workflow on push by [@jonathanhefner](https://github.com/jonathanhefner) in [#277](https://github.com/que-rb/que/pull/277)
261
+ **Full Changelog**: [`v1.0.0.beta4...v1.0.0.beta5`](https://github.com/que-rb/que/compare/v1.0.0.beta4...v1.0.0.beta5)
262
+ **Unless an issue is found we intend for this release to become v1.0.0 proper.**
263
+
264
+ ## 1.0.0.beta4 (2020-01-17)
265
+
266
+ - Rails 6 compatibility: Fix time parsing [#249](https://github.com/que-rb/que/pull/249) and [5ddddd5](https://github.com/que-rb/que/commit/5ddddd5ebac6153d7a683ef08c86bced8e03fb51)
267
+ - Cleaner sequel usage, in [#257](https://github.com/que-rb/que/pull/257)
268
+ - Documentation improvements: [#264](https://github.com/que-rb/que/pull/264), [#269](https://github.com/que-rb/que/pull/269), [#261](https://github.com/que-rb/que/pull/261), [#231](https://github.com/que-rb/que/pull/231)
269
+ - The `--minimum-buffer-size` option is now unused
270
+
271
+ ## 1.0.0.beta3 (2018-05-18)
272
+
273
+ - Added support for customizing log levels for `job_worked` events ([#217](https://github.com/que-rb/que/issues/217)).
274
+ - Began logging all `job_errored` events at the `ERROR` log level.
275
+ - Fixed the Railtie when running in test mode ([#214](https://github.com/que-rb/que/issues/214)).
276
+ - Tweaked the meanings of worker-priorities and worker-count options in the CLI, to better support use cases with low worker counts ([#216](https://github.com/que-rb/que/issues/216)).
277
+
278
+ ## 1.0.0.beta2 (2018-04-13)
279
+
280
+ - **A schema upgrade to version 4 will be required for this release.** See [the migration doc](https://github.com/que-rb/que/blob/master/docs/migrating.md) for information if you're upgrading from a previous release.
281
+ + Please note that this migration requires a rewrite of the jobs table, which makes it O(n) with the size of the table. If you have a very large backlog of jobs you may want to schedule downtime for this migration.
282
+ - Que's implementation has been changed from one in which worker threads hold their own PG connections and lock their own jobs to one in which a single thread (and PG connection) locks jobs through LISTEN/NOTIFY and batch polling, and passes jobs along to worker threads. This has many benefits, including:
283
+ + Jobs queued for immediate processing can be actively distributed to workers with LISTEN/NOTIFY, which is more efficient than having workers repeatedly poll for new jobs.
284
+ + When polling is necessary (to pick up jobs that are scheduled for the future or that need to be retried due to errors), jobs can be locked and fetched in batches, rather than one at a time.
285
+ + Individual workers no longer need to monopolize their own (usually idle) connections while working jobs, so Ruby processes will require fewer Postgres connections.
286
+ + PgBouncer or another external connection pool can be used for workers' connections (though not for the connection used to lock and listen for jobs).
287
+ - Other features introduced in this version include:
288
+ + Much better support for all versions of ActiveJob.
289
+ * In particular, you may (optionally) include `Que::ActiveJob::JobExtensions` into `ApplicationJob` to get support for all of Que's job helper methods.
290
+ + Custom middleware that wrap running jobs and executing SQL statements are now supported.
291
+ + Support for categorizing jobs with tags.
292
+ + Support for configuring a `maximum_retry_count` on individual job classes.
293
+ + Job configuration options are now inheritable, so job class hierarchies are more useful.
294
+ + There are now built-in models for ActiveRecord and Sequel to allow inspecting the queue easily.
295
+ + Jobs that have finished working may optionally be retained in the database indefinitely.
296
+ * To keep a job record, replace the `destroy` calls in your jobs with `finish`. `destroy` will still delete records entirely, for jobs that you don't want to keep.
297
+ * If you don't resolve a job yourself one way or another, Que will still `destroy` the job for you by default.
298
+ * Finished jobs have a timestamp set in the finished_at column.
299
+ + Jobs that have errored too many times will now be marked as expired, and won't be retried again.
300
+ * You can configure a maximum_retry_count in your job classes, to set the threshold at which a job will be marked expired. The default is 15.
301
+ * To manually mark a job as expired (and keep it in the database but not try to run it again) you can call `expire` helper in your job.
302
+ + You can now set job priority thresholds for individual workers, to ensure that there will always be space available for high-priority jobs.
303
+ + `Que.job_states` returns a list of locked jobs and the hostname/pid of the Ruby processes that have locked them.
304
+ + `Que.connection_proc=` has been added, to allow for the easy integration of custom connection pools.
305
+ - In keeping with semantic versioning, the major version is being bumped since the new implementation requires some backwards-incompatible changes. These changes include:
306
+ + Support for MRI Rubies before 2.2 has been dropped.
307
+ + Support for Postgres versions before 9.5 has been dropped (JSONB and upsert support is required).
308
+ + JRuby support has been dropped. It will be reintroduced whenever the jruby-pg gem is production-ready.
309
+ + The `que:work` rake task has been removed. Use the `que` executable instead.
310
+ * Therefore, configuring workers using QUE_* environment variables is no longer supported. Please pass the appropriate options to the `que` executable instead.
311
+ + The `mode` setter has been removed.
312
+ * To run jobs synchronously when they are enqueued (the old `:sync` behavior) you can set `Que.run_synchronously = true`.
313
+ * To start up the worker pool (the old :async behavior) you should use the `que` executable to start up a worker process. There's no longer a supported API for running workers outside of the `que` executable.
314
+ + The following methods are not meaningful under the new implementation and have been removed:
315
+ * The `Que.wake_interval` getter and setter.
316
+ * The `Que.worker_count` getter and setter.
317
+ * `Que.wake!`
318
+ * `Que.wake_all!`
319
+ + Since Que needs a dedicated Postgres connection to manage job locks, running Que through a single PG connection is no longer supported.
320
+ * It's not clear that anyone ever actually did this.
321
+ + `Que.worker_states` has been removed, as the connection that locks a job is no longer the one that the job is using to run. Its functionality has been partially replaced with `Que.job_states`.
322
+ + When using Rails, for simplicity, job attributes and keys in argument hashes are now converted to symbols when retrieved from the database, rather than being converted to instances of HashWithIndifferentAccess.
323
+ + Arguments passed to jobs are now deep-frozen, to prevent unexpected behavior when the args are mutated and the job is reenqueued.
324
+ + Since JSONB is now used to store arguments, the order of argument hashes is no longer maintained.
325
+ * It wouldn't have been a good idea to rely on this anyway.
326
+ + Calling Que.log() directly is no longer supported/recommended.
327
+ + Features marked as deprecated in the final 0.x releases have been removed.
328
+ - Finally, if you've built up your own tooling and customizations around Que, you may need to be aware of some DB schema changes made in the migration to schema version #4.
329
+ + The `job_id` column has been renamed `id` and is now the primary key. This makes it easier to manage the queue using an ActiveRecord model.
330
+ + Finished jobs are now kept in the DB, unless you explicitly call `destroy`. If you want to query the DB for only jobs that haven't finished yet, add a `WHERE finished_at IS NULL` condition to your query, or use the not_finished scope on one of the provided ORM models.
331
+ + There is now an `expired_at` timestamp column, which is set when a job reaches its maximum number of retries and will not be attempted again.
332
+ + Due to popular demand, the default queue name is now "default" rather than an empty string. The migration will move pending jobs under the "" queue to the "default" queue.
333
+ + The `last_error` column has been split in two, to `last_error_message` and `last_error_backtrace`. These two columns are now limited to 500 and 10,000 characters, respectively. The migration will split old error data correctly, and truncate it if necessary.
334
+ + Names for queues and job classes are now limited to 500 characters, which is still far longer than either of these values should reasonably be.
335
+ + There is now a `data` JSONB column which is used to support various ways of organizing jobs (setting tags on them, etc).
336
+
337
+ ## 1.0.0.beta (2017-10-25)
338
+
339
+ - **A schema upgrade to version 4 will be required for this release.** See [the migration doc](https://github.com/que-rb/que/blob/master/docs/migrating.md) for information if you're upgrading from a previous release.
340
+ + Please note that this migration requires a rewrite of the jobs table, which makes it O(n) with the size of the table. If you have a very large backlog of jobs you may want to schedule downtime for this migration.
341
+ - Que's implementation has been changed from one in which worker threads hold their own PG connections and lock their own jobs to one in which a single thread (and PG connection) locks jobs through LISTEN/NOTIFY and batch polling, and passes jobs along to worker threads. This has many benefits, including:
342
+ + Jobs queued for immediate processing can be actively distributed to workers with LISTEN/NOTIFY, which is more efficient than having workers repeatedly poll for new jobs.
343
+ + When polling is necessary (to pick up jobs that are scheduled for the future or that need to be retried due to errors), jobs can be locked and fetched in batches, rather than one at a time.
344
+ + Individual workers no longer need to monopolize their own (usually idle) connections while working jobs, so Ruby processes will require fewer Postgres connections.
345
+ + PgBouncer or another external connection pool can be used for workers' connections (though not for the connection used to lock and listen for jobs).
346
+ - Other features introduced in this version include:
347
+ + Much better support for all versions of ActiveJob.
348
+ * In particular, you may (optionally) include `Que::ActiveJob::JobExtensions` into `ApplicationJob` to get support for all of Que's job helper methods.
349
+ + Custom middleware that wrap running jobs are now supported.
350
+ + Support for categorizing jobs with tags.
351
+ + Support for configuring a `maximum_retry_count` on individual job classes.
352
+ + Job configuration options are now inheritable, so job class hierarchies are more useful.
353
+ + There are now built-in models for ActiveRecord and Sequel to allow inspecting the queue easily.
354
+ + Jobs that have finished working may optionally be retained in the database indefinitely.
355
+ * To keep a job record, replace the `destroy` calls in your jobs with `finish`. `destroy` will still delete records entirely, for jobs that you don't want to keep.
356
+ * If you don't resolve a job yourself one way or another, Que will still `destroy` the job for you by default.
357
+ * Finished jobs have a timestamp set in the finished_at column.
358
+ + Jobs that have errored too many times will now be marked as expired, and won't be retried again.
359
+ * You can configure a maximum_retry_count in your job classes, to set the threshold at which a job will be marked expired. The default is 15.
360
+ * To manually mark a job as expired (and keep it in the database but not try to run it again) you can call `expire` helper in your job.
361
+ + You can now set job priority thresholds for individual workers, to ensure that there will always be space available for high-priority jobs.
362
+ + `Que.job_states` returns a list of locked jobs and the hostname/pid of the Ruby processes that have locked them.
363
+ + `Que.connection_proc=` has been added, to allow for the easy integration of custom connection pools.
364
+ - In keeping with semantic versioning, the major version is being bumped since the new implementation requires some backwards-incompatible changes. These changes include:
365
+ + Support for MRI Rubies before 2.2 has been dropped.
366
+ + Support for Postgres versions before 9.5 has been dropped (JSONB and upsert support is required).
367
+ + JRuby support has been dropped. It will be reintroduced whenever the jruby-pg gem is production-ready.
368
+ + The `que:work` rake task has been removed. Use the `que` executable instead.
369
+ * Therefore, configuring workers using QUE_* environment variables is no longer supported. Please pass the appropriate options to the `que` executable instead.
370
+ + The `mode` setter has been removed.
371
+ * To run jobs synchronously when they are enqueued (the old `:sync` behavior) you can set `Que.run_synchronously = true`.
372
+ * To start up the worker pool (the old :async behavior) you should use the `que` executable to start up a worker process. There's no longer a supported API for running workers outside of the `que` executable.
373
+ + The following methods are not meaningful under the new implementation and have been removed:
374
+ * The `Que.wake_interval` getter and setter.
375
+ * The `Que.worker_count` getter and setter.
376
+ * `Que.wake!`
377
+ * `Que.wake_all!`
378
+ + Since Que needs a dedicated Postgres connection to manage job locks, running Que through a single PG connection is no longer supported.
379
+ * It's not clear that anyone ever actually did this.
380
+ + `Que.worker_states` has been removed, as the connection that locks a job is no longer the one that the job is using to run. Its functionality has been partially replaced with `Que.job_states`.
381
+ + When using Rails, for simplicity, job attributes and keys in argument hashes are now converted to symbols when retrieved from the database, rather than being converted to instances of HashWithIndifferentAccess.
382
+ + Arguments passed to jobs are now deep-frozen, to prevent unexpected behavior when the args are mutated and the job is reenqueued.
383
+ + Since JSONB is now used to store arguments, the order of argument hashes is no longer maintained.
384
+ * It wouldn't have been a good idea to rely on this anyway.
385
+ + Calling Que.log() directly is no longer supported/recommended.
386
+ + Features marked as deprecated in the final 0.x releases have been removed.
387
+ - Finally, if you've built up your own tooling and customizations around Que, you may need to be aware of some DB schema changes made in the migration to schema version #4.
388
+ + The `job_id` column has been renamed `id` and is now the primary key. This makes it easier to manage the queue using an ActiveRecord model.
389
+ + Finished jobs are now kept in the DB, unless you explicitly call `destroy`. If you want to query the DB for only jobs that haven't finished yet, add a `WHERE finished_at IS NULL` condition to your query, or use the not_finished scope on one of the provided ORM models.
390
+ + There is now an `expired_at` timestamp column, which is set when a job reaches its maximum number of retries and will not be attempted again.
391
+ + Due to popular demand, the default queue name is now "default" rather than an empty string. The migration will move pending jobs under the "" queue to the "default" queue.
392
+ + The `last_error` column has been split in two, to `last_error_message` and `last_error_backtrace`. These two columns are now limited to 500 and 10,000 characters, respectively. The migration will split old error data correctly, and truncate it if necessary.
393
+ + Names for queues and job classes are now limited to 500 characters, which is still far longer than either of these values should reasonably be.
394
+ + There is now a `data` JSONB column which is used to support various ways of organizing jobs (setting tags on them, etc).
395
+
396
+ ## 0.14.3 (2018-03-02)
397
+
398
+ - Recorded errors now always include the error class, so that empty error messages can still be helpful. ( joehorsnell)
399
+ - Recorded error messages are now truncated to the first 500 characters.
400
+
401
+ ## 0.14.2 (2018-01-05)
402
+
403
+ - Deprecate the Que.disable_prepared_statements= accessors.
404
+ - Add Que.use_prepared_statements= configuration accessors.
405
+ - Update the generated Rails migration to declare a version. (NARKOZ)
52
406
 
53
- * The error_handler callable is now be passed two objects, the error and the job that raised it. If your current error_handler is a proc, as recommended in the docs, you shouldn't need to make any code changes, unless you want to use the job in your error handling. If your error_handler is a lambda, or another callable with a strict arity requirement, you'll want to change it before upgrading. (#69) (statianzo)
407
+ ## 0.14.1 (2017-12-14)
54
408
 
55
- ### 0.8.2 (2014-10-12)
409
+ - Fix a bug with typecasting boolean values on Rails 5+.
56
410
 
57
- * Fix errors raised during rollbacks in the ActiveRecord adapter, which remained silent until Rails 4.2. (#64, #65) (Strech)
411
+ ## 0.14.0 (2017-08-11)
58
412
 
59
- ### 0.8.1 (2014-07-28)
413
+ - Fix incompatibility with Rails 5.1.
414
+ - Drop support for waking an in-process worker when an ActiveRecord transaction commits.
60
415
 
61
- * Fix regression introduced in the `que:work` rake task by the `mode` / `worker_count` disentangling in 0.8.0. (#50)
416
+ ## 0.13.1 (2017-07-05)
62
417
 
63
- ### 0.8.0 (2014-07-12)
418
+ - Fix issue that caused error stacktraces to not be persisted in most cases.
64
419
 
65
- * A callable can now be set as the logger, like `Que.logger = proc { MyLogger.new }`. Que uses this in its Railtie for cleaner initialization, but it is also available for public use.
420
+ ## 0.13.0 (2017-06-08)
66
421
 
67
- * `Que.mode=` and `Que.worker_count=` now function independently. That is, setting the worker_count to a nonzero number no longer sets mode = :async (triggering the pool to start working jobs), and setting it to zero no longer sets mode = :off. Similarly, setting the mode to :async no longer sets the worker_count to 4 from 0, and setting the mode to :off no longer sets the worker_count to 0. This behavior was changed because it was interfering with configuration during initialization of Rails applications, and because it was unexpected. (#47)
422
+ - Fix recurring JSON issues by dropping MultiJson support. Previously MultiJson was detected and used automatically, and now it's just ignored and stdlib JSON used instead, so this shouldn't require any code changes.
68
423
 
69
- * Fixed a similar bug wherein setting a wake_interval during application startup would break worker awakening after the process was forked.
424
+ ## 0.12.3 (2017-06-01)
70
425
 
71
- ### 0.7.3 (2014-05-19)
426
+ - Fix incompatibility with MultiJson introduced by the previous release.
72
427
 
73
- * When mode = :sync, don't touch the database at all when running jobs inline. Needed for ActiveJob compatibility (#46).
428
+ ## 0.12.2 (2017-06-01)
74
429
 
75
- ### 0.7.2 (2014-05-18)
430
+ - Fix security vulnerability in parsing JSON from the DB (by specifying create_additions: false). This shouldn't be a concern unless you were passing untrusted user input in your job arguments. (hmac)
76
431
 
77
- * Fix issue wherein intermittent worker wakeups would not work after forking (#44).
432
+ ## 0.12.1 (2017-01-22)
78
433
 
79
- ### 0.7.1 (2014-04-29)
434
+ - Fix incompatibility with Rails 5.0. ([#166](https://github.com/que-rb/que/issues/166)) (nbibler, thedarkone)
80
435
 
81
- * Fix errors with prepared statements when ActiveRecord reconnects to the database. (dvrensk)
436
+ ## 0.12.0 (2016-09-09)
82
437
 
83
- * Don't use prepared statements when inside a transaction. This negates the risk of a prepared statement error harming the entire transaction. The query that benefits the most from preparation is the job-lock CTE, which is never run in a transaction, so the performance impact should be negligible.
438
+ - The error_handler configuration option has been renamed to error_notifier, which is more descriptive of what it's actually supposed to do. You can still use error_handler for configuration, but you'll get a warning.
439
+ - Introduced a new framework for handling errors on a per-job basis. See the docs for more information. ([#106](https://github.com/que-rb/que/pull/106), [#147](https://github.com/que-rb/que/issues/147))
84
440
 
85
- ### 0.7.0 (2014-04-09)
441
+ ## 0.11.6 (2016-07-01)
86
442
 
87
- * `JobClass.queue(*args)` has been deprecated and will be removed in version 1.0.0. Please use `JobClass.enqueue(*args)` instead.
443
+ - Fix for operating in nested transactions in Rails 5.0. ([#160](https://github.com/que-rb/que/pull/160)) (greysteil)
88
444
 
89
- * The `@default_priority` and `@default_run_at` variables have been deprecated and will be removed in version 1.0.0. Please use `@priority` and `@run_at` instead, respectively.
445
+ ## 0.11.5 (2016-05-13)
90
446
 
91
- * Log lines now include the process pid - its omission in the previous release was an oversight.
447
+ - Fix error when running `que -v`. ([#154](https://github.com/que-rb/que/pull/154)) (hardbap)
92
448
 
93
- * The [Pond gem](https://github.com/chanks/pond) is now supported as a connection. It is very similar to the ConnectionPool gem, but creates connections lazily and is dynamically resizable.
449
+ ## 0.11.4 (2016-03-03)
94
450
 
95
- ### 0.6.0 (2014-02-04)
451
+ - Fix incompatibility with ActiveRecord 5.0.0.beta3. ([#143](https://github.com/que-rb/que/issues/143), [#144](https://github.com/que-rb/que/pull/144)) (joevandyk)
96
452
 
97
- * **A schema upgrade to version 3 is required for this release.** See [the migration doc](https://github.com/chanks/que/blob/master/docs/migrating.md) for information if you're upgrading from a previous release.
453
+ ## 0.11.3 (2016-02-26)
98
454
 
99
- * You can now run a job's logic directly (without enqueueing it) like `MyJob.run(arg1, arg2, :other_arg => arg3)`. This is useful when a job class encapsulates logic that you want to invoke without involving the entire queue.
455
+ - Fixed bug with displaying the current version of the que executable. ([#122](https://github.com/que-rb/que/pull/122)) (hardbap)
456
+ - Output to STDOUT when running via the executable or rake task is no longer buffered. This prevented logging in some cases. ([#129](https://github.com/que-rb/que/pull/129)) (hmarr)
457
+ - Officially added support for Ruby 2.2 and 2.3.
458
+ - String literals are now frozen on Ruby 2.3.
100
459
 
101
- * You can now check the current version of Que's database schema with `Que.db_version`.
460
+ ## 0.11.2 (2015-09-09)
102
461
 
103
- * The method for enqueuing a job has been renamed from `MyJob.queue` to `MyJob.enqueue`, since we were beginning to use the word 'queue' in a LOT of places. `MyJob.queue` still works, but it may be removed at some point.
462
+ - Fix Job class constantizing when ActiveSupport isn't loaded. ([#121](https://github.com/que-rb/que/pull/121)) (godfat)
104
463
 
105
- * The variables for setting the defaults for a given job class have been changed from `@default_priority` to `@priority` and `@default_run_at` to `@run_at`. The old variables still work, but like `Job.queue`, they may be removed at some point.
464
+ ## 0.11.1 (2015-09-04)
106
465
 
107
- * Log lines now include the machine's hostname, since a pid alone may not uniquely identify a process.
466
+ - The `rake que:work` rake task that was specific to Rails has been deprecated and will be removed in Que 1.0. A deprecation warning will display when it is run.
108
467
 
109
- * Multiple queues are now supported. See [the docs](https://github.com/chanks/que/blob/master/docs/multiple_queues.md) for details. (chanks, joevandyk)
468
+ ## 0.11.0 (2015-09-04)
110
469
 
111
- * Rubinius 2.2 is now supported. (brixen)
470
+ - A command-line program has been added that can be used to work jobs in a more flexible manner than the previous rake task. Run `que -h` for more information.
471
+ - The worker pool will no longer start automatically in the same process when running the rails server - this behavior was too prone to breakage. If you'd like to recreate the old behavior, you can manually set `Que.mode = :async` in your app whenever conditions are appropriate (classes have loaded, a database connection has been established, and the process will not be forking).
472
+ - Add a Que.disable_prepared_transactions= configuration option, to make it easier to use tools like pgbouncer. ([#110](https://github.com/que-rb/que/issues/110))
473
+ - Add a Que.json_converter= option, to configure how arguments are transformed before being passed to the job. By default this is set to the `Que::INDIFFERENTIATOR` proc, which provides simple indifferent access (via strings or symbols) to args hashes. If you're using Rails, the default is to convert the args to HashWithIndifferentAccess instead. You can also pass it the Que::SYMBOLIZER proc, which will destructively convert all keys in the args hash to symbols (this will probably be the default in Que 1.0). If you want to define a custom converter, you will usually want to pass this option a proc, and you'll probably want it to be recursive. See the implementations of Que::INDIFFERENTIATOR and Que::SYMBOLIZER for examples. ([#113](https://github.com/que-rb/que/issues/113))
474
+ - When using Que with ActiveRecord, workers now call `ActiveRecord::Base.clear_active_connections!` between jobs. This cleans up connections that ActiveRecord leaks when it is used to access mutliple databases. ([#116](https://github.com/que-rb/que/pull/116))
475
+ - If it exists, use String#constantize to constantize job classes, since ActiveSupport's constantize method behaves better with Rails' autoloading. ([#115](https://github.com/que-rb/que/issues/115), [#120](https://github.com/que-rb/que/pull/120)) (joevandyk)
112
476
 
113
- * Job classes may now define their own logic for determining the retry interval when a job raises an error. See [error handling](https://github.com/chanks/que/blob/master/docs/error_handling.md) for more information.
477
+ ## 0.10.0 (2015-03-18)
114
478
 
115
- ### 0.5.0 (2014-01-14)
479
+ - When working jobs via the rake task, Rails applications are now eager-loaded if present, to avoid problems with multithreading and autoloading. ([#96](https://github.com/que-rb/que/pull/96)) (hmarr)
480
+ - The que:work rake task now uses whatever logger Que is configured to use normally, rather than forcing the use of STDOUT. ([#95](https://github.com/que-rb/que/issues/95))
481
+ - Add Que.transaction() helper method, to aid in transaction management in migrations or when the user's ORM doesn't provide one. ([#81](https://github.com/que-rb/que/issues/81))
116
482
 
117
- * When running a worker pool inside your web process on ActiveRecord, Que will now wake a worker once a transaction containing a queued job is committed. (joevandyk, chanks)
483
+ ## 0.9.2 (2015-02-05)
118
484
 
119
- * The `que:work` rake task now has a default wake_interval of 0.1 seconds, since it relies exclusively on polling to pick up jobs. You can set a QUE_WAKE_INTERVAL environment variable to change this. The environment variable to set a size for the worker pool in the rake task has also been changed from WORKER_COUNT to QUE_WORKER_COUNT.
485
+ - Fix a bug wherein the at_exit hook in the railtie wasn't waiting for jobs to finish before exiting.
486
+ - Fix a bug wherein the que:work rake task wasn't waiting for jobs to finish before exiting. ([#85](https://github.com/que-rb/que/pull/85)) (tycooon)
120
487
 
121
- * Officially support Ruby 1.9.3. Note that due to the Thread#kill problems (see "Remove Que.stop!" below) there's a danger of data corruption when running under 1.9, though.
488
+ ## 0.9.1 (2015-01-11)
122
489
 
123
- * The default priority for jobs is now 100 (it was 1 before). Like always (and like delayed_job), a lower priority means it's more important. You can migrate the schema version to 2 to set the new default value on the que_jobs table, though it's only necessary if you're doing your own INSERTs - if you use `MyJob.queue`, it's already taken care of.
490
+ - Use now() rather than 'now' when inserting jobs, to avoid using an old value as the default run_at in prepared statements. ([#74](https://github.com/que-rb/que/pull/74)) (bgentry)
124
491
 
125
- * Added a migration system to make it easier to change the schema when updating Que. You can now write, for example, `Que.migrate!(:version => 2)` in your migrations. Migrations are run transactionally.
492
+ ## 0.9.0 (2014-12-16)
126
493
 
127
- * The logging format has changed to be more easily machine-readable. You can also now customize the logging format by assigning a callable to Que.log_formatter=. See the new doc on [logging](https://github.com/chanks/que/blob/master/docs/logging.md)) for details. The default logger level is INFO - for less critical information (such as when no jobs were found to be available or when a job-lock race condition has been detected and avoided) you can set the QUE_LOG_LEVEL environment variable to DEBUG.
494
+ - The error_handler callable is now passed two objects, the error and the job that raised it. If your current error_handler is a proc, as recommended in the docs, you shouldn't need to make any code changes, unless you want to use the job in your error handling. If your error_handler is a lambda, or another callable with a strict arity requirement, you'll want to change it before upgrading. ([#69](https://github.com/que-rb/que/pull/69)) (statianzo)
128
495
 
129
- * MultiJson is now a soft dependency. Que will use it if it is available, but it is not required.
496
+ ## 0.8.2 (2014-10-12)
130
497
 
131
- * Remove Que.stop!.
498
+ - Fix errors raised during rollbacks in the ActiveRecord adapter, which remained silent until Rails 4.2. ([#64](https://github.com/que-rb/que/pull/64), [#65](https://github.com/que-rb/que/pull/65)) (Strech)
132
499
 
133
- Using Thread#raise to kill workers is a bad idea - the results are unpredictable and nearly impossible to spec reliably. Its purpose was to prevent premature commits in ActiveRecord/Sequel when a thread is killed during shutdown, but it's possible to detect that situation on Ruby 2.0+, so this is really better handled by the ORMs directly. See the pull requests for [Sequel](https://github.com/jeremyevans/sequel/pull/752) and [ActiveRecord](https://github.com/rails/rails/pull/13656).
500
+ ## 0.8.1 (2014-07-28)
134
501
 
135
- Now, when a process exits, if the worker pool is running (whether in a rake task or in a web process) the exit will be stalled until all workers have finished their current jobs. If you have long-running jobs, this may take a long time. If you need the process to exit immediately, you can SIGKILL without any threat of commiting prematurely.
502
+ - Fix regression introduced in the `que:work` rake task by the `mode` / `worker_count` disentangling in 0.8.0. ([#50](https://github.com/que-rb/que/issues/50))
136
503
 
137
- ### 0.4.0 (2014-01-05)
504
+ ## 0.8.0 (2014-07-12)
138
505
 
139
- * Que.wake_all! was added, as a simple way to wake up all workers in the pool.
506
+ - A callable can now be set as the logger, like `Que.logger = proc { MyLogger.new }`. Que uses this in its Railtie for cleaner initialization, but it is also available for public use.
507
+ - `Que.mode=` and `Que.worker_count=` now function independently. That is, setting the worker_count to a nonzero number no longer sets mode = :async (triggering the pool to start working jobs), and setting it to zero no longer sets mode = :off. Similarly, setting the mode to :async no longer sets the worker_count to 4 from 0, and setting the mode to :off no longer sets the worker_count to 0. This behavior was changed because it was interfering with configuration during initialization of Rails applications, and because it was unexpected. ([#47](https://github.com/que-rb/que/issues/47))
508
+ - Fixed a similar bug wherein setting a wake_interval during application startup would break worker awakening after the process was forked.
140
509
 
141
- * Que.sleep_period was renamed to the more descriptive Que.wake_interval.
510
+ ## 0.7.3 (2014-05-19)
142
511
 
143
- * When queueing a job, Que will wait until the current transaction commits and then wake a background worker, if possible. This allows newly queued jobs to be started immediately instead of waiting for a worker to wake up and poll, which may be up to `Que.wake_interval` seconds.
512
+ - When mode = :sync, don't touch the database at all when running jobs inline. Needed for ActiveJob compatibility ([#46](https://github.com/que-rb/que/issues/46)).
144
513
 
145
- This feature currently only works with Sequel, since there doesn't seem to be a clean way to do it on ActiveRecord (if anyone can figure one out, please let me know). Note that if you're using ActiveRecord, you can always manually trigger a single worker to wake up and check for work by manually calling Que.wake! after your transaction completes.
514
+ ## 0.7.2 (2014-05-18)
146
515
 
147
- * Add Que.job_stats, which queries the database and returns statistics on the different job classes - for each class, how many are queued, how many are currently being worked, what is the highest error_count, and so on.
516
+ - Fix issue wherein intermittent worker wakeups would not work after forking ([#44](https://github.com/que-rb/que/issues/44)).
148
517
 
149
- * Add Que.worker_states, which queries the database and returns all currently-locked jobs and info on their workers' connections - what and when was the last query they ran, are they waiting on locks, and so on.
518
+ ## 0.7.1 (2014-04-29)
150
519
 
151
- * Have Que only clear advisory locks that it has taken when locking jobs, and not touch any that may have been taken by other code using the same connection.
520
+ - Fix errors with prepared statements when ActiveRecord reconnects to the database. (dvrensk)
521
+ - Don't use prepared statements when inside a transaction. This negates the risk of a prepared statement error harming the entire transaction. The query that benefits the most from preparation is the job-lock CTE, which is never run in a transaction, so the performance impact should be negligible.
152
522
 
153
- * Add Que.worker_count, to retrieve the current number of workers in the pool of the current process.
523
+ ## 0.7.0 (2014-04-09)
154
524
 
155
- * Much more internal cleanup.
525
+ - `JobClass.queue(*args)` has been deprecated and will be removed in version 1.0.0. Please use `JobClass.enqueue(*args)` instead.
526
+ - The `@default_priority` and `@default_run_at` variables have been deprecated and will be removed in version 1.0.0. Please use `@priority` and `@run_at` instead, respectively.
527
+ - Log lines now include the process pid - its omission in the previous release was an oversight.
528
+ - The [Pond gem](https://github.com/chanks/pond) is now supported as a connection. It is very similar to the ConnectionPool gem, but creates connections lazily and is dynamically resizable.
156
529
 
157
- ### 0.3.0 (2013-12-21)
530
+ ## 0.6.0 (2014-02-04)
158
531
 
159
- * Add Que.stop!, which immediately kills all jobs being worked in the process.
532
+ - **A schema upgrade to version 3 is required for this release.** See [the migration doc](https://github.com/que-rb/que/blob/master/docs/migrating.md) for information if you're upgrading from a previous release.
533
+ - You can now run a job's logic directly (without enqueueing it) like `MyJob.run(arg1, arg2, other_arg: arg3)`. This is useful when a job class encapsulates logic that you want to invoke without involving the entire queue.
534
+ - You can now check the current version of Que's database schema with `Que.db_version`.
535
+ - The method for enqueuing a job has been renamed from `MyJob.queue` to `MyJob.enqueue`, since we were beginning to use the word 'queue' in a LOT of places. `MyJob.queue` still works, but it may be removed at some point.
536
+ - The variables for setting the defaults for a given job class have been changed from `@default_priority` to `@priority` and `@default_run_at` to `@run_at`. The old variables still work, but like `Job.queue`, they may be removed at some point.
537
+ - Log lines now include the machine's hostname, since a pid alone may not uniquely identify a process.
538
+ - Multiple queues are now supported. See [the docs](https://github.com/que-rb/que/blob/master/docs/multiple_queues.md) for details. (chanks, joevandyk)
539
+ - Rubinius 2.2 is now supported. (brixen)
540
+ - Job classes may now define their own logic for determining the retry interval when a job raises an error. See [error handling](https://github.com/que-rb/que/blob/master/docs/error_handling.md) for more information.
160
541
 
161
- This can leave database connections and such in an unpredictable state, and so should only be used when the process is exiting.
542
+ ## 0.5.0 (2014-01-14)
162
543
 
163
- * Use Que.stop! to safely handle processes that exit while Que is running.
544
+ - When running a worker pool inside your web process on ActiveRecord, Que will now wake a worker once a transaction containing a queued job is committed. (joevandyk, chanks)
545
+ - The `que:work` rake task now has a default wake_interval of 0.1 seconds, since it relies exclusively on polling to pick up jobs. You can set a QUE_WAKE_INTERVAL environment variable to change this. The environment variable to set a size for the worker pool in the rake task has also been changed from WORKER_COUNT to QUE_WORKER_COUNT.
546
+ - Officially support Ruby 1.9.3. Note that due to the Thread#kill problems (see "Remove Que.stop!" below) there's a danger of data corruption when running under 1.9, though.
547
+ - The default priority for jobs is now 100 (it was 1 before). Like always (and like delayed_job), a lower priority means it's more important. You can migrate the schema version to 2 to set the new default value on the que_jobs table, though it's only necessary if you're doing your own INSERTs - if you use `MyJob.queue`, it's already taken care of.
548
+ - Added a migration system to make it easier to change the schema when updating Que. You can now write, for example, `Que.migrate!(version: 2)` in your migrations. Migrations are run transactionally.
549
+ - The logging format has changed to be more easily machine-readable. You can also now customize the logging format by assigning a callable to Que.log_formatter=. See the new doc on [logging](https://github.com/que-rb/que/blob/master/docs/logging.md)) for details. The default logger level is INFO - for less critical information (such as when no jobs were found to be available or when a job-lock race condition has been detected and avoided) you can set the QUE_LOG_LEVEL environment variable to DEBUG.
550
+ - MultiJson is now a soft dependency. Que will use it if it is available, but it is not required.
551
+ - Remove Que.stop!.
164
552
 
165
- Previously, a job that was in the middle of a transaction when the process was killed with SIGINT or SIGTERM would have had its work committed prematurely.
553
+ Using Thread#raise to kill workers is a bad idea - the results are unpredictable and nearly impossible to spec reliably. Its purpose was to prevent premature commits in ActiveRecord/Sequel when a thread is killed during shutdown, but it's possible to detect that situation on Ruby 2.0+, so this is really better handled by the ORMs directly. See the pull requests for [Sequel](https://github.com/jeremyevans/sequel/pull/752) and [ActiveRecord](https://github.com/rails/rails/pull/13656).
166
554
 
167
- * Clean up internals and hammer out several race conditions.
555
+ Now, when a process exits, if the worker pool is running (whether in a rake task or in a web process) the exit will be stalled until all workers have finished their current jobs. If you have long-running jobs, this may take a long time. If you need the process to exit immediately, you can SIGKILL without any threat of commiting prematurely.
168
556
 
169
- ### 0.2.0 (2013-11-30)
557
+ ## 0.4.0 (2014-01-05)
170
558
 
171
- * Officially support JRuby 1.7.5+. Earlier versions may work.
559
+ - Que.wake_all! was added, as a simple way to wake up all workers in the pool.
560
+ - Que.sleep_period was renamed to the more descriptive Que.wake_interval.
561
+ - When queueing a job, Que will wait until the current transaction commits and then wake a background worker, if possible. This allows newly queued jobs to be started immediately instead of waiting for a worker to wake up and poll, which may be up to `Que.wake_interval` seconds.
172
562
 
173
- JRuby support requires the use of the `jruby-pg` gem, though that gem seems to currently be incompatible with ActiveRecord, so the ActiveRecord adapter specs don't pass (or even run). It works fine with Sequel and the other adapters, though.
563
+ This feature currently only works with Sequel, since there doesn't seem to be a clean way to do it on ActiveRecord (if anyone can figure one out, please let me know). Note that if you're using ActiveRecord, you can always manually trigger a single worker to wake up and check for work by manually calling Que.wake! after your transaction completes.
564
+ - Add Que.job_stats, which queries the database and returns statistics on the different job classes - for each class, how many are queued, how many are currently being worked, what is the highest error_count, and so on.
565
+ - Add Que.worker_states, which queries the database and returns all currently-locked jobs and info on their workers' connections - what and when was the last query they ran, are they waiting on locks, and so on.
566
+ - Have Que only clear advisory locks that it has taken when locking jobs, and not touch any that may have been taken by other code using the same connection.
567
+ - Add Que.worker_count, to retrieve the current number of workers in the pool of the current process.
568
+ - Much more internal cleanup.
569
+
570
+ ## 0.3.0 (2013-12-21)
174
571
 
175
- * Officially support Rubinius 2.1.1+. Earlier versions may work.
572
+ - Add Que.stop!, which immediately kills all jobs being worked in the process.
176
573
 
177
- * Use `multi_json` so we always use the fastest JSON parser available. (BukhariH)
574
+ This can leave database connections and such in an unpredictable state, and so should only be used when the process is exiting.
575
+ - Use Que.stop! to safely handle processes that exit while Que is running.
178
576
 
179
- * :sync mode now ignores scheduled jobs (jobs queued with a specific run_at).
577
+ Previously, a job that was in the middle of a transaction when the process was killed with SIGINT or SIGTERM would have had its work committed prematurely.
578
+ - Clean up internals and hammer out several race conditions.
180
579
 
181
- ### 0.1.0 (2013-11-18)
580
+ ## 0.2.0 (2013-11-30)
182
581
 
183
- * Initial public release, after a test-driven rewrite.
582
+ - Officially support JRuby 1.7.5+. Earlier versions may work.
184
583
 
185
- Officially support Ruby 2.0.0 and Postgres 9.2+.
584
+ JRuby support requires the use of the `jruby-pg` gem, though that gem seems to currently be incompatible with ActiveRecord, so the ActiveRecord adapter specs don't pass (or even run). It works fine with Sequel and the other adapters, though.
585
+ - Officially support Rubinius 2.1.1+. Earlier versions may work.
586
+ - Use `multi_json` so we always use the fastest JSON parser available. (BukhariH)
587
+ - :sync mode now ignores scheduled jobs (jobs queued with a specific run_at).
186
588
 
187
- Also support ActiveRecord and bare PG::Connections, in or out of a ConnectionPool.
589
+ ## 0.1.0 (2013-11-18)
188
590
 
189
- Added a Railtie for easier setup with Rails, as well as a migration generator.
591
+ - Initial public release, after a test-driven rewrite.
592
+ - Officially support Ruby 2.0.0 and Postgres 9.2+.
593
+ - Also support ActiveRecord and bare PG::Connections, in or out of a ConnectionPool.
594
+ - Added a Railtie for easier setup with Rails, as well as a migration generator.
190
595
 
191
- ### 0.0.1 (2013-11-07)
596
+ ## 0.0.1 (2013-11-07)
192
597
 
193
- * Copy-pasted from an app of mine. Very Sequel-specific. Nobody look at it, let's pretend it never happened.
598
+ - Copy-pasted from an app of mine. Very Sequel-specific. Nobody look at it, let's pretend it never happened.