kue-scheduler icon indicating copy to clipboard operation
kue-scheduler copied to clipboard

job:undefined when prefix contain colon symbol

Open vothanhkiet opened this issue 7 years ago • 5 comments

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];
  }

vothanhkiet avatar Jun 04 '17 11:06 vothanhkiet

@vothanhkiet I will appreciate PR.

lykmapipo avatar Jun 09 '17 14:06 lykmapipo

why did we lock dependencies?

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

schmod avatar Jun 27 '17 19:06 schmod

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

samhunta avatar Jun 28 '17 22:06 samhunta

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

schmod avatar Jun 29 '17 13:06 schmod

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

samhunta avatar Jun 29 '17 21:06 samhunta