From 1e335947555762d0e8ddeca83e2deb3d923b7f73 Mon Sep 17 00:00:00 2001 From: Russell Smith Date: Wed, 3 Jul 2019 15:58:57 -0700 Subject: [PATCH 1/3] Make QC fail with versions of PG < 9.6, add notes in readme and changelog --- CHANGELOG.md | 4 +++- README.md | 29 ++++++++++++++--------------- lib/queue_classic/config.rb | 1 - lib/queue_classic/conn_adapter.rb | 6 +++++- lib/queue_classic/queue.rb | 3 +-- lib/queue_classic/version.rb | 2 +- 6 files changed, 24 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 96fd439a..a7862fd9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -## Unreleased +## Unreleased, 3.3.0 - Fixed a bug in the offset calculation of `.enqueue_at`. - Use the jsonb type for the args column from now on. If not available, fall back to json or text. - `enqueue`, `enqueue_at`, `enqueue_in` return job hash with id. @@ -8,6 +8,8 @@ - Change ruby versions tested in Travis to currently supported ones. - Switched project to use CircleCI, as it's way more consistent speed wise - Automatically retry after a connection reset #294 +- Change to only support >= Postgres 9.6. We will be bringing in newer changes and testing on only 9.6+ going forward. +- Change to only support currently supported Ruby versions: 2.4, 2.5 and 2.6. ## Version 3.0.0rc - Improved signal handling diff --git a/README.md b/README.md index d1caf1c2..50a8e6d1 100644 --- a/README.md +++ b/README.md @@ -184,13 +184,14 @@ $ ruby -r queue_classic -e "QC::Worker.new.work" Declare dependencies in Gemfile. ```ruby -source "https://rubygems.org" -gem "queue_classic" +source 'https://rubygems.org' do + gem 'queue_classic' +end ``` Add the database tables and stored procedures. -``` +```bash rails generate queue_classic:install bundle exec rake db:migrate ``` @@ -221,14 +222,15 @@ Starting with with queue_classic 3.1, Rails is automatically detected and its co If you don't want to use the automatic database connection, set this environment variable to false: `export QC_RAILS_DATABASE=false` -**Note on using ActiveRecord migrations:** If you use the migration, and you wish to use commands that reset the database from the stored schema (e.g. `rake db:reset`), your application must be configured with `config.active_record.schema_format = :sql` in `config/application.rb`. If you don't do this, the PL/pgSQL function that queue_classic creates will be lost when you reset the database. +**Note on using ActiveRecord migrations:** If you use the migration, and you wish to use commands that reset the database from the stored schema (e.g. `rake db:reset`), your application must be configured with `config.active_record.schema_format = :sql` in `config/application.rb`. If you don't do this, the PL/pgSQL function that queue_classic creates will be lost when you reset the database. #### Other Ruby apps -By default, queue_classic will use the QC_DATABASE_URL falling back on DATABASE_URL. The URL must be in the following format: `postgres://username:password@localhost/database_name`. If you use Heroku's PostgreSQL service, this will already be set. If you don't want to set this variable, you can set the connection in an initializer. **QueueClassic will maintain its own connection to the database.** This may double the number of connections to your database. +By default, queue_classic will use the QC_DATABASE_URL falling back on DATABASE_URL. The URL must be in the following format: `postgres://username:password@localhost/database_name`. If you use Heroku's PostgreSQL service, this will already be set. If you don't want to set this variable, you can set the connection in an initializer. **QueueClassic will maintain its own connection to the database.** This may double the number of connections to your database. ## Upgrade from earlier versions + If you are upgrading from a previous version of queue_classic, you might need some new database columns and/or functions. Luckily enough for you, it is easy to do so. ### Ruby on Rails @@ -265,16 +267,18 @@ By default queue_classic does not talk very much. If you find yourself in a situation where you need to know what's happening inside QC, there are two different kind of logging you can enable: DEBUG and MEASURE. ### Measure + This will output the time to process and that kind of thing. To enable it, set the `QC_MEASURE`: -``` +```bash export QC_MEASURE="true" ``` ### Debug + You can enable the debug output by setting the `DEBUG` environment variable: -``` +```bash export DEBUG="true" ``` @@ -287,18 +291,13 @@ If you think you have found a bug, feel free to open an issue. Use the following 3. List what actually happened. 4. Provide sample codes & commands which will reproduce the problem. -If you have general questions about how to use queue_classic, send a message to the mailing list: - -https://groups.google.com/d/forum/queue_classic - ## Hacking on queue_classic ### Dependencies -* Ruby 1.9.2 -* Postgres ~> 9.0 -* Rubygem: pg ~> 0.11.0 -* For JRuby, see [queue_classic_java](https://github.com/bdon/queue_classic_java) +* Ruby 2.4, 2.5 or 2.6 +* Postgres ~> 9.6 +* Rubygem: pg ~> 0.17 ### Running Tests diff --git a/lib/queue_classic/config.rb b/lib/queue_classic/config.rb index 4f22ecbc..778774de 100644 --- a/lib/queue_classic/config.rb +++ b/lib/queue_classic/config.rb @@ -58,7 +58,6 @@ def fork_worker? # The worker class instantiated by QC's rake tasks. def default_worker_class - @worker_class ||= (ENV["QC_DEFAULT_WORKER_CLASS"] && Kernel.const_get(ENV["QC_DEFAULT_WORKER_CLASS"]) || QC::Worker) diff --git a/lib/queue_classic/conn_adapter.rb b/lib/queue_classic/conn_adapter.rb index 69c528a0..622e15e5 100644 --- a/lib/queue_classic/conn_adapter.rb +++ b/lib/queue_classic/conn_adapter.rb @@ -81,6 +81,11 @@ def establish_new if conn.status != PG::CONNECTION_OK QC.log(:error => conn.error) end + + if conn.server_version < 96000 + raise "This version of Queue Classic does not support Postgres older than 9.6. If you need that support, please use an older version." + end + conn.exec("SET application_name = '#{QC.app_name}'") conn end @@ -106,6 +111,5 @@ def db_url raise(ArgumentError, "missing QC_DATABASE_URL or DATABASE_URL") @db_url = URI.parse(url) end - end end diff --git a/lib/queue_classic/queue.rb b/lib/queue_classic/queue.rb index da58e69a..79aca3f9 100644 --- a/lib/queue_classic/queue.rb +++ b/lib/queue_classic/queue.rb @@ -5,8 +5,8 @@ module QC # The queue class maps a queue abstraction onto a database table. class Queue - attr_reader :name, :top_bound + def initialize(name, top_bound=nil) @name = name @top_bound = top_bound || QC.top_bound @@ -132,6 +132,5 @@ def count r["count"].to_i end end - end end diff --git a/lib/queue_classic/version.rb b/lib/queue_classic/version.rb index 06ffa2e4..779af3ba 100644 --- a/lib/queue_classic/version.rb +++ b/lib/queue_classic/version.rb @@ -1,3 +1,3 @@ module QC - VERSION = "3.2.0.RC1" + VERSION = "3.3.0.ALPHA" end From 4b9c0624b7d264b9b402eb10bf6d9735e43f2274 Mon Sep 17 00:00:00 2001 From: Russell Smith Date: Wed, 3 Jul 2019 16:05:56 -0700 Subject: [PATCH 2/3] Add output of the vesion you are running --- lib/queue_classic/conn_adapter.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/queue_classic/conn_adapter.rb b/lib/queue_classic/conn_adapter.rb index 622e15e5..eebabe8b 100644 --- a/lib/queue_classic/conn_adapter.rb +++ b/lib/queue_classic/conn_adapter.rb @@ -83,7 +83,7 @@ def establish_new end if conn.server_version < 96000 - raise "This version of Queue Classic does not support Postgres older than 9.6. If you need that support, please use an older version." + raise "This version of Queue Classic does not support Postgres older than 9.6 (96000). This version is #{conn.server_version}. If you need that support, please use an older version." end conn.exec("SET application_name = '#{QC.app_name}'") From 3b3d124c62e9af3f18cbeffed2e46b182bdc4bf1 Mon Sep 17 00:00:00 2001 From: Russell Smith Date: Wed, 3 Jul 2019 16:10:32 -0700 Subject: [PATCH 3/3] Use 90600 as the min vesion --- lib/queue_classic/conn_adapter.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/queue_classic/conn_adapter.rb b/lib/queue_classic/conn_adapter.rb index eebabe8b..f05b68b3 100644 --- a/lib/queue_classic/conn_adapter.rb +++ b/lib/queue_classic/conn_adapter.rb @@ -82,8 +82,8 @@ def establish_new QC.log(:error => conn.error) end - if conn.server_version < 96000 - raise "This version of Queue Classic does not support Postgres older than 9.6 (96000). This version is #{conn.server_version}. If you need that support, please use an older version." + if conn.server_version < 90600 + raise "This version of Queue Classic does not support Postgres older than 9.6 (90600). This version is #{conn.server_version}. If you need that support, please use an older version." end conn.exec("SET application_name = '#{QC.app_name}'")