Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make QC fail with versions of PG < 9.6, add notes in readme and chang… #307

Merged
merged 3 commits into from
Jul 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
# 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.
- Fixed unlock query for versions below Postgres 9.2
- 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
Expand Down
29 changes: 14 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"
```

Expand All @@ -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

Expand Down
1 change: 0 additions & 1 deletion lib/queue_classic/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
6 changes: 5 additions & 1 deletion lib/queue_classic/conn_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ def establish_new
if conn.status != PG::CONNECTION_OK
QC.log(:error => conn.error)
end

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}'")
conn
end
Expand All @@ -106,6 +111,5 @@ def db_url
raise(ArgumentError, "missing QC_DATABASE_URL or DATABASE_URL")
@db_url = URI.parse(url)
end

end
end
3 changes: 1 addition & 2 deletions lib/queue_classic/queue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -132,6 +132,5 @@ def count
r["count"].to_i
end
end

end
end
2 changes: 1 addition & 1 deletion lib/queue_classic/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module QC
VERSION = "3.2.0.RC1"
VERSION = "3.3.0.ALPHA"
end