Skip to content

Commit

Permalink
PLT-4618: Add test about very large task
Browse files Browse the repository at this point in the history
Confirmed very large task (tasks whose data is ungzipped) makes DELETE
query degraded.

BEFORE (v0.8.45):

PerfectQueue::Backend::RDBCompatBackend
  #acquire
    very large jobs
D, [2016-03-22T18:35:03.678637 #24939] DEBUG -- : (0.000095s) SET @@wait_timeout = 2147483
D, [2016-03-22T18:35:03.678802 #24939] DEBUG -- : (0.000094s) SET SQL_AUTO_IS_NULL=0
D, [2016-03-22T18:35:03.680263 #24939] DEBUG -- : (0.001333s) BEGIN
D, [2016-03-22T18:35:03.680539 #24939] DEBUG -- : (0.000154s) SELECT GET_LOCK('test_queues', 60) locked
D, [2016-03-22T18:35:07.899606 #24939] DEBUG -- : (4.218841s) DELETE FROM `test_queues` WHERE timeout <= 1458639303 AND created_at IS NULL
D, [2016-03-22T18:35:07.899785 #24939] DEBUG -- : (0.000088s) COMMIT
D, [2016-03-22T18:35:07.900490 #24939] DEBUG -- : (0.000066s) SET @@wait_timeout = 2147483
D, [2016-03-22T18:35:07.900589 #24939] DEBUG -- : (0.000067s) SET SQL_AUTO_IS_NULL=0
D, [2016-03-22T18:35:07.900732 #24939] DEBUG -- : (0.000074s) BEGIN
D, [2016-03-22T18:35:07.900905 #24939] DEBUG -- : (0.000096s) SELECT GET_LOCK('test_queues', 60) locked
D, [2016-03-22T18:35:08.266121 #24939] DEBUG -- : (0.364732s) SELECT id, timeout, data, created_at, resource
FROM `test_queues`
WHERE timeout <= 1458639303 AND timeout <= 1458639303 AND created_at IS NOT NULL
ORDER BY timeout ASC
LIMIT 10

D, [2016-03-22T18:35:08.637478 #24939] DEBUG -- : (0.225528s) UPDATE `test_queues` SET timeout=1458639345 WHERE id IN ('4f52ab9c-f011-11e5-91d1-61143f034f84','4f5cd004-f011-11e5-91d1-61143f034f84','4f666934-f011-11e5-91d1-61143f034f84','4f70283e-f011-11e5-91d1-61143f034f84','4f7a85ea-f011-11e5-91d1-61143f034f84','4f8413d0-f011-11e5-91d1-61143f034f84','4f8d37c6-f011-11e5-91d1-61143f034f84','4f96000e-f011-11e5-91d1-61143f034f84','4fa0e604-f011-11e5-91d1-61143f034f84','4fac8cca-f011-11e5-91d1-61143f034f84') AND created_at IS NOT NULL
D, [2016-03-22T18:35:08.639395 #24939] DEBUG -- : (0.001794s) COMMIT
      returns a task

AFTER (v0.8.46):

PerfectQueue::Backend::RDBCompatBackend
  #acquire
    very large jobs
D, [2016-03-22T18:33:20.249724 #24776] DEBUG -- : (0.000090s) SET @@wait_timeout = 2147483
D, [2016-03-22T18:33:20.253954 #24776] DEBUG -- : (0.004107s) SET SQL_AUTO_IS_NULL=0
D, [2016-03-22T18:33:20.291939 #24776] DEBUG -- : (0.037849s) DELETE FROM `test_queues` WHERE timeout <= 458639200 AND created_at IS NULL
D, [2016-03-22T18:33:20.293357 #24776] DEBUG -- : (0.000102s) SET @@wait_timeout = 2147483
D, [2016-03-22T18:33:20.293484 #24776] DEBUG -- : (0.000077s) SET SQL_AUTO_IS_NULL=0
D, [2016-03-22T18:33:20.293660 #24776] DEBUG -- : (0.000112s) SELECT GET_LOCK('test_queues', 60) locked
D, [2016-03-22T18:33:20.655361 #24776] DEBUG -- : (0.361516s) SELECT id, timeout, data, created_at, resource
FROM `test_queues`
WHERE 1300000000 < timeout AND timeout <= 1458639200 AND timeout <= 1458639200
      AND created_at IS NOT NULL
ORDER BY timeout ASC
LIMIT 10

D, [2016-03-22T18:33:21.019104 #24776] DEBUG -- : (0.214267s) UPDATE `test_queues` SET timeout=1458639242 WHERE timeout <= 1458639200 AND id IN ('11c0c1b0-f011-11e5-91d1-61143f034f84','11cb220e-f011-11e5-91d1-61143f034f84','11d5c07e-f011-11e5-91d1-61143f034f84','11def70c-f011-11e5-91d1-61143f034f84','11e941b2-f011-11e5-91d1-61143f034f84','11f29708-f011-11e5-91d1-61143f034f84','11fb71c0-f011-11e5-91d1-61143f034f84','1204450c-f011-11e5-91d1-61143f034f84','120d6e16-f011-11e5-91d1-61143f034f84','1216833e-f011-11e5-91d1-61143f034f84') AND created_at IS NOT NULL
      returns a task
  • Loading branch information
nurse committed Mar 22, 2016
1 parent 4aa04fb commit 13f0079
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions spec/rdb_stress.rb
Expand Up @@ -25,6 +25,7 @@
let (:task_token){ Backend::RDBCompatBackend::Token.new(key) }
let (:alive_time){ 42 }
let (:max_acquire){ 10 }

context 'some tasks' do
before do
sql = nil
Expand All @@ -51,5 +52,28 @@
expect(ary[0]).to be_an_instance_of(AcquiredTask)
end
end

context 'very large jobs' do
before do
sql = nil
sql = 'INSERT `test_queues` (id, timeout, data, created_at, resource) VALUES'
data = %<UNCOMPRESS(UNCOMPRESS(FROM_BASE64('6B8AAHic7c6xCYNQFEDRh8HGAawjmAmEOE7WsPziGoJ1xnAJLbJCVgiJbpBOkHOqW96IFN34nvvYpOvyuZXPIgAAAICTS6/hku1RfR9tffQNAAAA8Icxb+7r9AO74A1h')))>
200.times do |i|
t = now - 600 + i/1000
sql << "(UUID(),#{t},#{data},#{t},NULL),"
end
db.db.run sql.chop!
db.db.loggers << Logger.new($stderr)
db.db.sql_log_level = :debug
end
it 'returns a task' do
#db.instance_variable_set(:@cleanup_interval_count, 0)
#expect(db.db.instance_variable_get(:@default_dataset)).to receive(:delete).and_call_original
ary = db.acquire(alive_time, max_acquire, {})
expect(ary).to be_an_instance_of(Array)
expect(ary.size).to eq(10)
expect(ary[0]).to be_an_instance_of(AcquiredTask)
end
end
end
end

0 comments on commit 13f0079

Please sign in to comment.