-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mget
with Redis.Cluster and enableAutoPipelining: true
causes "Error: All the keys in a pipeline command should belong to the same slot"
#1392
Comments
One possible fix would be to check if a command allowed and had multiple keys. The node_modules/redis-commands/commands.json keyStart != keyStop may be a cheaper to compute heuristic but worse for throughput EDIT: The real issue I was having was the fact this was attempting to hash an array instead of a string for the mget example (or unlink([key1, key2]), etc) // lib/command.ts
/**
* Iterate through the command arguments that are considered keys.
*
* @param {Function} [transform=(key) => key] The transformation that should be applied to
* each key. The transformations will persist.
* @returns {string[]} The keys of the command.
* @memberof Command
*/
private _iterateKeys(
transform: Function = (key) => key
): Array<string | Buffer> {
if (typeof this.keys === "undefined") {
this.keys = [];
if (commands.exists(this.name)) {
const keyIndexes = commands.getKeyIndexes(this.name, this.args);
for (const index of keyIndexes) {
this.args[index] = transform(this.args[index]);
this.keys.push(this.args[index] as string | Buffer);
}
}
}
return this.keys;
} |
Fixes redis#1392 The issue was that this was passing an array instead of a string to cluster-key-slot when `args[0]` was an array Handle pathological cases such as redis.get([], ['key1', 'key2']) by flattening the entire args array.
Fixes redis#1392 The issue was that this was passing an array instead of a string to cluster-key-slot when `args[0]` was an array Handle pathological cases such as redis.get([], ['key1', 'key2']) by flattening the entire args array.
Previously, the building of pipelines ignored the key prefix. It was possible that two keys, foo and bar, might be set into the same pipeline. However, after being prefixed by a configured "keyPrefix" value, they may no longer belong to the same pipeline. This led to the error: "All keys in the pipeline should belong to the same slots allocation group" Similarly, `args[0]` can be a (possibly empty) array which the Command constructor would flatten. Properly compute the first flattened key when autopipelining for a Redis.Cluster instance. Amended version of https://github.com/luin/ioredis/pull/1335/files - see comments on that PR This may fix redis#1264 and redis#1248. Fixes redis#1392
Previously, the building of pipelines ignored the key prefix. It was possible that two keys, foo and bar, might be set into the same pipeline. However, after being prefixed by a configured "keyPrefix" value, they may no longer belong to the same pipeline. This led to the error: "All keys in the pipeline should belong to the same slots allocation group" Similarly, `args[0]` can be a (possibly empty) array which the Command constructor would flatten. Properly compute the first flattened key when autopipelining for a Redis.Cluster instance. Amended version of https://github.com/luin/ioredis/pull/1335/files - see comments on that PR This may fix redis#1264 and redis#1248. Fixes redis#1392
Previously, the building of pipelines ignored the key prefix. It was possible that two keys, foo and bar, might be set into the same pipeline. However, after being prefixed by a configured "keyPrefix" value, they may no longer belong to the same pipeline. This led to the error: "All keys in the pipeline should belong to the same slots allocation group" Similarly, `args[0]` can be a (possibly empty) array which the Command constructor would flatten. Properly compute the first flattened key when autopipelining for a Redis.Cluster instance. Amended version of https://github.com/luin/ioredis/pull/1335/files - see comments on that PR Closes #1264 Closes #1248 Fixes #1392
🎉 This issue has been resolved in version 4.27.7 🎉 The release is available on: Your semantic-release bot 📦🚀 |
## [4.27.7](redis/ioredis@v4.27.6...v4.27.7) (2021-08-01) ### Bug Fixes * **cluster:** fix autopipeline with keyPrefix or arg array ([#1391](redis/ioredis#1391)) ([d7477aa](redis/ioredis@d7477aa)), closes [#1264](redis/ioredis#1264) [#1248](redis/ioredis#1248) [#1392](redis/ioredis#1392)
Discovered while investigating issues similar to ones fixed by #1391
Any command that affects multiple keys is probably also affected (
exists
/del
with more than one key, mset, mget, etc)The text was updated successfully, but these errors were encountered: