Skip to content
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

Custom Lua scripts are not loaded in cluster mode #1405

Closed
stavalfi opened this issue Aug 4, 2021 · 3 comments · Fixed by #1497
Closed

Custom Lua scripts are not loaded in cluster mode #1405

stavalfi opened this issue Aug 4, 2021 · 3 comments · Fixed by #1497
Labels

Comments

@stavalfi
Copy link

stavalfi commented Aug 4, 2021

I created a local cluster on my macbook pro with 3-8 nodes using redis-cli and redis-server (From homebrew).

When I shutdown all nodes and re-create them (manually) - 9/10 runs this bug occurs:

const client = new IORedis.Cluster([
  {
    host: 'localhost',
    port: 7000,
  },
])

const scriptName = 'script1'
const script1 = 'return {KEYS[1]}'
client.defineCommand(scriptName, { numberOfKeys: 1, lua: script1 })
console.log(await client[scriptName]('aaaa', 'hi', console.log))

Error

(node:54658) UnhandledPromiseRejectionWarning: ReplyError: NOSCRIPT No matching script. Please use EVAL.
    at parseError (/Users/stavalfi/projects/singer/.yarn/cache/redis-parser-npm-3.0.0-7ebe40abcb-45dbcb05be.zip/node_modules/redis-parser/lib/parser.js:179:12)
    at parseType (/Users/stavalfi/projects/singer/.yarn/cache/redis-parser-npm-3.0.0-7ebe40abcb-45dbcb05be.zip/node_modules/redis-parser/lib/parser.js:302:14)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:54658) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:54658) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

(Very?) Bad Workaround

It took me a while to figure out how to fix it: I need to manually update all nodes about the script

const masters = client.nodes('master')
await Promise.all(
  masters.map(node => Promise.all([node.script('load', script1), node.script('load', persistMollyLiveBmss)])),
)

I'm not sure I can use this fix in production.


More info

Note: In non-cluster runs, all works great: using local,remote,docker redis-servers.

System:
    OS: macOS 10.15.1
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 675.51 MB / 16.00 GB
    Shell: 3.1.2 - /usr/local/bin/fish
  Binaries:
    Node: 14.15.4 - /var/folders/fh/lk3kyv9n29v3w36bqyv_y7d00000gn/T/fnm-shell-5135596/bin/node
    Yarn: 2.4.2 - /var/folders/fh/lk3kyv9n29v3w36bqyv_y7d00000gn/T/fnm-shell-5135596/bin/yarn
    npm: 6.14.10 - /var/folders/fh/lk3kyv9n29v3w36bqyv_y7d00000gn/T/fnm-shell-5135596/bin/npm

ioredis - 4.27.6 and 4.27.7

redis-cli 6.2.4
Redis server v=6.2.4 sha=00000000:0 malloc=libc bits=64 build=f6e7aafbcc3dc4bf

redis.conf for all nodes:

port <some port>
cluster-enabled yes
cluster-config-file nodes.conf
cluster-node-timeout 5000
appendonly no
save ""
@stavalfi stavalfi changed the title script not loaded when using cluster Custom Lua scripts are not loaded in cluster mode Aug 4, 2021
@marcbachmann
Copy link
Collaborator

marcbachmann commented Jan 30, 2022

This could be caused by what I've described in the comment here: #1438 (comment)

Once a server restarts, it doesn't have the script anymore and ioredis only tries to reload them after 60s.

@ioredis-robot
Copy link
Collaborator

🎉 This issue has been resolved in version 4.28.5 🎉

The release is available on:

Your semantic-release bot 📦🚀

@marcbachmann
Copy link
Collaborator

This accidentally got closed. #1499 would fix the behavior

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants