lykmapipo / kue-scheduler

A job scheduler utility for kue, backed by redis and built for node.js
246 stars 47 forks source link

job:undefined when prefix contain colon symbol #96

Open vothanhkiet opened 7 years ago

vothanhkiet commented 7 years ago

When validate expired key, we've already include the prefix, however, when extract the job unique ID, we assume that the expired key has only 3 or 4 parts, therefore, if the prefix contain additional colon symbol, _getJobUUID return undefined value

queue._jobExpiryKeyValidator = new RegExp('^' + queue.options.prefix + ':scheduler:(?!' + lockKey + ')');
  var uuid;

  var splits = key.split(':');

  //deduce job uuid from job expiry key
  //kue:scheduler:<jobExpirykey>
  if (splits.length === 3) {
    uuid = splits[2];
  }

  //deduce job uuid from job data key
  //kue:scheduler:data:<jobExpirykey>
  if (splits.length === 4) {
    uuid = splits[3];
  }

Solution: can we use the last part as UUID ?

  var splits = key.split(':');

  splits = _.filter(splits, function(o) { return o !== ''; });
  if(splits.length > 0){
    uuid = splits[splits.length - 1];
  }
lykmapipo commented 7 years ago

@vothanhkiet I will appreciate PR.

schmod commented 7 years ago

why did we lock dependencies?

among other things, this locked us into a dangerously-broken version of Redlock (v2.1.1)

samhunta commented 7 years ago

@schmod This may solve your problem - https://github.com/lykmapipo/kue-scheduler/pull/101

schmod commented 7 years ago

indeed, it probably would! FWIW, I've had good luck with Redlock 3.0.0.

samhunta commented 7 years ago

@schmod I've tried Redlock 3.0.0 with no luck, not sure why :/