Conversation
ZimbiX
left a comment
There was a problem hiding this comment.
LGTM from a quick read. I'll have a look at whether we need to check the version in any other queries
ZimbiX
left a comment
There was a problem hiding this comment.
Further changes are needed. Polling mode works (any v2 jobs enqueued prior to starting que remain un-run), but notify mode still runs a job with the wrong que_version.
Test
With app.rb of:
require 'bundler/setup'
require 'sequel'
require 'que'
DB = Sequel.connect(ENV['DATABASE_URL'])
Que.connection = DB
Que.migrate!(version: 5)
class MyJob < Que::Job
def run
puts 'Running MyJob'
end
endStart Que:
./auto/dev bash -c 'RUBYOPT= bundle exec ./bin/que ./app.rb'Then enqueue a Que v2 job with SQL:
./auto/psql -c "insert into que_jobs (job_class, que_version) values ('MyJob', 2);"Result:
Running MyJob
|
We should add specs for the behaviour too |
Nice @ZimbiX, yes we will need some more thorough tests for this. |
|
I've added a failing spec. I haven't had an easy time with the implementation. I see there as being a couple of options for addressing the notify ingestion:
|
|
I thought I'd first have a go at updating Now the It passes the specs I added. Manually tested with poll, notify, and threads - working great! 🎉 Note that when migrating while an old worker is running, unfortunately the following error occurs in the worker: I suspect this is unavoidable, and we should just advise that if you want to avoid the error, to briefly shut down the workers while the migration is taking place. Otherwise, it should be fine once restarted by the supervisor (e.g. Kubernetes). |
|
Commands used in testing: # Env for all terminals:
export DATABASE_URL=postgres://que:que@localhost:5697/que-test
export PGHOST=localhost PGPORT=5697 PGUSER=que PGPASSWORD=que PGDATABASE=que-test
# Setup:
docker ps -aq | xargs -r docker stop && docker container ls -aq | xargs -r docker rm && docker volume rm -f que_db-data && docker-compose up -d db # reset db
ruby -r bundler/setup -r que -r sequel -e "Que.connection = Sequel.connect(ENV['DATABASE_URL']); Que.migrate!(version: 5)"
# Terminal 1:
bundle exec ./bin/que --min-buffer-size=1 --max-buffer-size=1 --worker-count=2 --poll-interval=1 ./app.rb
# Terminal 2:
# Update the version in `lib/que/version.rb` to `2.0.0`, then start a second worker:
bundle exec ./bin/que --min-buffer-size=1 --max-buffer-size=1 --worker-count=2 --poll-interval=1 ./app.rb
# Terminal 3:
psql -c "insert into que_jobs (job_class, que_version) values ('MyJobForQue1', 1), ('MyJobForQue1', 1), ('MyJobForQue1', 1), ('MyJobForQue1', 1), ('MyJobForQue2', 2), ('MyJobForQue2', 2), ('MyJobForQue2', 2), ('MyJobForQue2', 2)"
require 'bundler/setup'
require 'sequel'
require 'que'
DB = Sequel.connect(ENV['DATABASE_URL'])
Que.connection = DB
class MyJobForQue1 < Que::Job
def run
puts 'Running MyJobForQue1'
end
end
class MyJobForQue2 < Que::Job
def run
puts 'Running MyJobForQue2'
end
endTo run just the spec that was failing: TEST=lib/que/locker.spec.rb TESTOPTS="--name='/with listen only/' -v" bundle exec rake spec |
464b2d9 to
ffc4be2
Compare
|
Rebased to resolve a merge conflict in the version file. |
Co-authored-by: Rob Harrington <oeoeaio@gmail.com>
This can be used to indicate which version of the gem enqueued a job Co-authored-by: Rob Harrington <oeoeaio@gmail.com>
Co-authored-by: Rob Harrington <oeoeaio@gmail.com>
…, incl. a failing one for listen To run just the failing spec: ```bash DATABASE_URL=postgres://que:que@localhost:5697/que-test TEST=lib/que/locker.spec.rb TESTOPTS="--name='/with listen only/' -v" bundle exec rake spec ```
… to take into account que_jobs.que_version All that's changed from the previous version of `que_job_notify` is the addition of `AND ql.que_version = NEW.que_version`, in order to notify only a worker which has a Que version that matches what was used to schedule the job.
…till pass when the major version gets bumped
This more accurately reflects its purpose
To allow control over when it needs to change, rather than with every major version
e7df05d to
60af431
Compare
|
Rebased to resolve a merge conflict around the startup message. |
oeoeaio
left a comment
There was a problem hiding this comment.
Yep, looks good, let's do it.
4a6577b to
e186c8f
Compare
|
Note: I've changed the advice around 3rd-party code using |

This is a change best made prior to merging #319.
We've added the
job_schema_versioncolumn to theque_jobstable.This will allow us to:
que_versionas 2We're thinking this will require a major version bump due to the additional DB migrations but we're open to suggestions.