perfectqueue 0.8.20 → 0.8.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/ChangeLog CHANGED
@@ -1,4 +1,10 @@
1
1
 
2
+ == 2012-09-11 version 0.8.21
3
+
4
+ * rdb_compat backend uses IS NOT NULL condition instead of >= because RANGE
5
+ partitioning of MySQL doesn't work with non-primary keys
6
+
7
+
2
8
  == 2012-09-08 version 0.8.20
3
9
 
4
10
  * Show log messages when a worker decides next status of a task (finished!,
@@ -47,7 +47,7 @@ module PerfectQueue
47
47
  @sql = <<SQL
48
48
  SELECT id, timeout, data, created_at, resource
49
49
  FROM `#{@table}`
50
- WHERE timeout <= ? AND timeout <= ? AND created_at >= 0
50
+ WHERE timeout <= ? AND timeout <= ? AND created_at IS NOT NULL
51
51
  ORDER BY timeout ASC
52
52
  LIMIT ?
53
53
  SQL
@@ -58,10 +58,10 @@ FROM `#{@table}`
58
58
  LEFT JOIN (
59
59
  SELECT resource AS res, COUNT(1) AS running
60
60
  FROM `#{@table}` AS T
61
- WHERE timeout > ? AND created_at >= 0 AND resource IS NOT NULL
61
+ WHERE timeout > ? AND created_at IS NOT NULL AND resource IS NOT NULL
62
62
  GROUP BY resource
63
63
  ) AS R ON resource = res
64
- WHERE timeout <= ? AND created_at >= 0 AND (max_running-running IS NULL OR max_running-running > 0)
64
+ WHERE timeout <= ? AND created_at IS NOT NULL AND (max_running-running IS NULL OR max_running-running > 0)
65
65
  ORDER BY weight IS NOT NULL, weight DESC, timeout ASC
66
66
  LIMIT ?
67
67
  SQL
@@ -145,7 +145,7 @@ SQL
145
145
  # => Task
146
146
  def submit(key, type, data, options)
147
147
  now = (options[:now] || Time.now).to_i
148
- now = 0 if now < 0
148
+ now = 1 if now < 1 # 0 means cancel requested
149
149
  run_at = (options[:run_at] || now).to_i
150
150
  user = options[:user]
151
151
  user = user.to_s if user
@@ -204,7 +204,7 @@ SQL
204
204
  params = [sql, next_timeout]
205
205
  tasks.each {|t| params << t.key }
206
206
  sql << (1..tasks.size).map { '?' }.join(',')
207
- sql << ") AND created_at >= 0"
207
+ sql << ") AND created_at IS NOT NULL"
208
208
 
209
209
  n = @db[*params].update
210
210
  if n != tasks.size
@@ -223,7 +223,7 @@ SQL
223
223
 
224
224
  # created_at=0 means cancel_requested
225
225
  connect {
226
- n = @db["UPDATE `#{@table}` SET created_at=0 WHERE id=? AND created_at >= 0", key].update
226
+ n = @db["UPDATE `#{@table}` SET created_at=0 WHERE id=? AND created_at IS NOT NULL", key].update
227
227
  if n <= 0
228
228
  raise AlreadyFinishedError, "task key=#{key} does not exist or already finished."
229
229
  end
@@ -242,7 +242,7 @@ SQL
242
242
  key = task_token.key
243
243
 
244
244
  connect {
245
- n = @db["UPDATE `#{@table}` SET timeout=?, created_at=NULL, resource=NULL WHERE id=? AND created_at >= 0", delete_timeout, key].update
245
+ n = @db["UPDATE `#{@table}` SET timeout=?, created_at=NULL, resource=NULL WHERE id=? AND created_at IS NOT NULL", delete_timeout, key].update
246
246
  if n <= 0
247
247
  raise IdempotentAlreadyFinishedError, "task key=#{key} does not exist or already finished."
248
248
  end
@@ -257,12 +257,12 @@ SQL
257
257
  key = task_token.key
258
258
 
259
259
  connect {
260
- n = @db["UPDATE `#{@table}` SET timeout=? WHERE id=? AND created_at >= 0", next_timeout, key].update
260
+ n = @db["UPDATE `#{@table}` SET timeout=? WHERE id=? AND created_at IS NOT NULL", next_timeout, key].update
261
261
  if n <= 0
262
262
  row = @db.fetch("SELECT id, timeout, created_at FROM `#{@table}` WHERE id=? LIMIT 1", key).first
263
263
  if row == nil
264
264
  raise PreemptedError, "task key=#{key} does not exist or preempted."
265
- elsif row[:created_at] == 0
265
+ elsif row[:created_at] <= 0
266
266
  raise CancelRequestedError, "task key=#{key} is cancel requested."
267
267
  elsif row[:timeout] == next_timeout
268
268
  # ok
@@ -310,7 +310,7 @@ SQL
310
310
  if row[:created_at] === nil
311
311
  created_at = nil # unknown creation time
312
312
  status = TaskStatus::FINISHED
313
- elsif row[:created_at] == 0
313
+ elsif row[:created_at] <= 0
314
314
  status = TaskStatus::CANCEL_REQUESTED
315
315
  elsif now && row[:timeout] < now
316
316
  created_at = row[:created_at]
@@ -1,3 +1,3 @@
1
1
  module PerfectQueue
2
- VERSION = "0.8.20"
2
+ VERSION = "0.8.21"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: perfectqueue
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.20
4
+ version: 0.8.21
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-09 00:00:00.000000000 Z
12
+ date: 2012-10-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sequel