Skip to content

2.0: drop node 4/6, callbacks; use ioredis#317

Closed
skeggse wants to merge 9 commits intomasterfrom
2.0-2020
Closed

2.0: drop node 4/6, callbacks; use ioredis#317
skeggse wants to merge 9 commits intomasterfrom
2.0-2020

Conversation

@skeggse
Copy link
Copy Markdown
Member

@skeggse skeggse commented Nov 13, 2020

I took #112 and rebased it against the default branch - phew!

I probably preserved way more of the individual commits than I needed to 😁 (edit: still reachable from 6693a0c)

Blocking TODOs:

  • update README
  • fix code coverage
  • provide some usability guidance if attempting to pass in a node_redis client
  • validate ioredis client abort and quit behaviors
  • figure out whether we need to break anything to address Reproducible: bee-queue loses track of jobs #189 - likely will want to change defaults

Might release this as a 2.0 alpha so our friends over @mixmaxhq can evaluate it in wild, if they're willing.

@LewisJEllis had some fantastic ideas about next steps in #112, and I look forward to pursuing them after we've landed the simplest possible 2.0 that prevents further breakage.

I'll post a review in a minute eventually that calls out some concerns.

See also #104. Fixes #16 and closes #21.

@skeggse skeggse added this to the 2.0.0 milestone Nov 13, 2020
@skeggse skeggse requested review from LewisJEllis and shils November 13, 2020 06:44
@skeggse skeggse self-assigned this Nov 13, 2020
@skeggse skeggse force-pushed the 2.0-2020 branch 2 times, most recently from 6693a0c to 695236a Compare November 13, 2020 08:52
@skeggse skeggse force-pushed the 2.0-2020 branch 2 times, most recently from 4a02384 to a585e85 Compare November 13, 2020 08:56
* switch to `ioredis`
* drop callback support

BREAKING CHANGE: drop node 4 and 6, switch to ioredis, drop callback
support.
@skeggse skeggse changed the title 2.0 2.0: drop node 4/6, callbacks; use ioredis Nov 13, 2020
@shils
Copy link
Copy Markdown
Collaborator

shils commented Nov 13, 2020

Very exciting, I'd love to evaluate this in the @mixmaxhq wilderness.

Comment on lines +701 to +708
// TODO: what DO
// TODO: reintroduce tests
if (cb) {
promise.then(
(value) => process.nextTick(() => cb(null, value)),
(err) => process.nextTick(() => cb(err))
);
}
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this is sad, and I would like to find another solution. The checkStalledJobs method supports a callback so that the library user may receive callbacks for all attempted stall checks - not just the first. Removing the callback doesn't permit us to propagate any useful information, as the process won't really finish until Queue#close is called.

Perhaps we use events and emit an event? How do we handle errors in that case?

Comment on lines +764 to +788
const final = Promise.all(
jobs.map((job) => {
const defer = helpers.defer();
return job
._save((evalArgs) => {
this._evalScriptOn(batch, evalArgs);
defers.push(defer);
return defer.promise;
})
.catch((err) => {
// Catch both errors from defer.reject below (from the EVALSHA), and
// from any serialization failures.
errors.set(job, err);
});
})
);
const results = await batch.exec();
for (const [defer, [error, jobId]] of helpers.zip(defers, results)) {
if (error) {
defer.reject(error);
} else {
defer.resolve(jobId);
}
return helpers.callAsync((done) => batch.exec(done)).then(() => errors);
});
}
await final;
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ioredis has abysmal support for pipelining as the pipeline commands don't return promises but instead return the pipeline for chaining. This means we have to manually identify which of the jobs each command corresponds to :\

lib/redis.js Outdated
isNewClient = false;
}
} else {
client = Redis.createClient(settings);
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is deprecated, but we override it in tests and can't replace the bare function as easily as we can the createClient export.

Comment on lines +95 to +97
// HACK: flushQueue is, according to ioredis, private. This is unfortunate,
// because we need this in order to properly clean up during brpoplpush
// commands.
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather gross. Other options?

Comment on lines +109 to 114
function errorCode(err) {
rBoundary.lastIndex = 1;
const { message } = err,
match = rBoundary.exec(err.message);
return err.message.slice(0, match ? match.index : undefined);
}
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably worth submitting upstream, as this is a nice feature of NodeRedis and impacts #316

Comment on lines +119 to +120
if (name === 'Redis') return 'ioredis';
if (name === 'RedisClient') return 'NodeRedis';
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enums how do they work

Comment on lines 613 to 614
// invariant: in this code path, this.running < this.concurrency, always
// after spoolup, this.running + this.queued === this.concurrency
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very much would like to replace this with a more maintainable pattern that specifically handles this concurrency management.

@compwright
Copy link
Copy Markdown
Collaborator

Has conflicts and is abandoned, closing.

@compwright compwright closed this Nov 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Replace node_redis with ioredis

4 participants