You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Error: NOSCRIPT No matching script. Please use EVAL. #27
I'm opening a new issue - related to #24 b/c 24 is closed, but unresolved, as far as I can tell.
I'm trying to migrate from kue to bee-queue, and when I start up the app, it throws this error:
Error: NOSCRIPT No matching script. Please use EVAL.
at ReplyParser.<anonymous> (/Users/davis/git/warehouse-web/node_modules/bee-queue/node_modules/redis/index.js:320:31)
at ReplyParser.emit (events.js:107:17)
at ReplyParser.send_error (/Users/davis/git/warehouse-web/node_modules/bee-queue/node_modules/redis/lib/parser/javascript.js:298:10)
at ReplyParser.execute (/Users/davis/git/warehouse-web/node_modules/bee-queue/node_modules/redis/lib/parser/javascript.js:183:22)
at RedisClient.on_data (/Users/davis/git/warehouse-web/node_modules/bee-queue/node_modules/redis/index.js:550:27)
at Socket.<anonymous> (/Users/davis/git/warehouse-web/node_modules/bee-queue/node_modules/redis/index.js:105:14)
at Socket.emit (events.js:107:17)
at readableAddChunk (_stream_readable.js:163:16)
at Socket.Readable.push (_stream_readable.js:126:10)
at TCP.onread (net.js:538:20) +2ms
...which I understand to mean Redis is saying the Lua scripts are not cached, so they'll need to be EVAL'd instead. This should be true since I'm just trying bee-queue for the first time.
However, I also pulled the proposed fix from #24commit here
OK, after I uninstalled @mllongze fork, and then re-installed the last official npm release, and having pre-installed the scripts directly via redis-cli, it seems to have gotten past the issue.
Hmm, this is a bit strange. Are you waiting for the ready queue event? It's possible to beat the caching check to the punch by not waiting for that event, but even if you're not waiting for that event, I wouldn't expect you to run into this problem if you've manually cached the scripts. There's a procedure to check if the scripts are cached on first connection, and to cache them if they're missing (and only if they're missing, so you shouldn't be running into any sort of "tried doing something halfway through the cache repopulation" issue). I'm a bit puzzled because the only time I've run into the NOSCRIPT error myself has been after a restart of Redis while Node is still running (as was the case in #24); I've never run into it on a clean startup of Node.
The Lua script caching being something I haven't seen other node/redis task queues utilize, of course I run into troubles with it. It seems like it would be reasonable to automatically queue commands until that ready event fires, so as to avoid some situations like this, but I'm not convinced that that would solve whatever's happening here. I'll have to do some investigation; I haven't used bee-queue on Redis 3.x yet, but hopefully that isn't the issue.
Also, I just verified that those three cache shas are the same as on my production instances of bee-queue (or, well, instances of Redis that back bee-queue).
Your steps that ended up fixing it make me wonder if that fix to #24 introduced something strange. I'll have to look at it more closely. Everything modulo that fork can be explained by the "beating the caching procedure to the punch" bit, but for it to continue failing after manually caching them is puzzling. It sounds like it only continued to fail after manual caching if you were on that fork, though, correct?
I'm wondering if the following two sequences play out as described:
With [email protected]: wipe redis, start node -> NOSCRIPT error, manually cache, start node -> works?
With #24 fork: wipe redis, start node -> NOSCRIPT error, manually cache, start node -> still NOSCRIPT error?
I can't verify this right now, but will try it tonight.
Yes, after manually installing them in the cache, it continued to fail with that fork. When I switched back to the latest official release, it started working again.
I wrote that test script above and just copied your source that creates client side hashes and printed them, and also verified they are the same as what is in redis.
Okay, great, thanks for confirming. Also, are you waiting for the ready event? If not, then I think I have a hypothesis for what's going on. There are probably two things to do:
Implement the fix to Redis Server Crash reconnect error? #24 but be careful not to introduce a new bug (whatever you seem to have encountered after manually caching with the fork) in doing so
Automatically queue commands issued before the ready event, so as to avoid NOSCRIPT errors in certain situations on startup (what I think you encountered at the beginning of all this)
Ah, I had a callback for the ready event, but I didn't actually wait for it until the rest of the stuff bootstraps itself. So, yea, that may have a big part of the issue?
I've done some further testing, and it seems if you wait for the ready event before you try to call Queue.process or Queue.createJob it works as expected. If you prematurely use those APIs, it seems to fail with this error.
I have several different producer / consumer scripts, so I just need to go through them all and ensure each one waits for ready before trying to use the Queue api.
Yea, I got tricked by another one. I was doing something like this:
varqueue;// get queuemodule.exports=function(done){if(queue){returnqueue;}queue=newQueue('foo',{/* params */});queue.on('ready',function(){done();});// this line can throw EVALSHA/EVAL error if scripts aren't loaded, tooqueue.checkStalledJobs(5000);}
Yep, that all seems like expected behavior. The ready event is documented here, but I do think it's a bit tucked away and possibly downplayed too much relative to how much of a caveat it can be. I think the plan to have the library automatically queue any commands called before the ready event should avoid these situations altogether. I've opened an issue to track that feature, which should come this weekend.
In my case, the problem appears to be caused by Redis Cluster. When the command 'loadScriptIfMissing' is executed, half of the commands are executed on one shard and the other half on another. As a result, the shards do not have all of the scripts loaded, resulting in 'EVALSHA' failing. I figured this out by running the MONITOR command on all shards.
Because I am not a Redis expert, can someone please confirm this hypothesis and provide a solution?
Thanks
Activity
davisford commentedon Dec 8, 2015
I tried to load the scripts manually:
scripts are loaded:
...but when I run, same error. Do those sha1 match?
davisford commentedon Dec 8, 2015
Executing this test script indicates the shas are the same:
Outputs:
What am I missing?
davisford commentedon Dec 8, 2015
OK, after I uninstalled @mllongze fork, and then re-installed the last official npm release, and having pre-installed the scripts directly via redis-cli, it seems to have gotten past the issue.
LewisJEllis commentedon Dec 8, 2015
Hmm, this is a bit strange. Are you waiting for the ready queue event? It's possible to beat the caching check to the punch by not waiting for that event, but even if you're not waiting for that event, I wouldn't expect you to run into this problem if you've manually cached the scripts. There's a procedure to check if the scripts are cached on first connection, and to cache them if they're missing (and only if they're missing, so you shouldn't be running into any sort of "tried doing something halfway through the cache repopulation" issue). I'm a bit puzzled because the only time I've run into the NOSCRIPT error myself has been after a restart of Redis while Node is still running (as was the case in #24); I've never run into it on a clean startup of Node.
The Lua script caching being something I haven't seen other node/redis task queues utilize, of course I run into troubles with it. It seems like it would be reasonable to automatically queue commands until that ready event fires, so as to avoid some situations like this, but I'm not convinced that that would solve whatever's happening here. I'll have to do some investigation; I haven't used bee-queue on Redis 3.x yet, but hopefully that isn't the issue.
LewisJEllis commentedon Dec 8, 2015
Also, I just verified that those three cache shas are the same as on my production instances of bee-queue (or, well, instances of Redis that back bee-queue).
LewisJEllis commentedon Dec 8, 2015
Your steps that ended up fixing it make me wonder if that fix to #24 introduced something strange. I'll have to look at it more closely. Everything modulo that fork can be explained by the "beating the caching procedure to the punch" bit, but for it to continue failing after manually caching them is puzzling. It sounds like it only continued to fail after manual caching if you were on that fork, though, correct?
I'm wondering if the following two sequences play out as described:
With [email protected]: wipe redis, start node -> NOSCRIPT error, manually cache, start node -> works?
With #24 fork: wipe redis, start node -> NOSCRIPT error, manually cache, start node -> still NOSCRIPT error?
I can't verify this right now, but will try it tonight.
davisford commentedon Dec 8, 2015
Yes, after manually installing them in the cache, it continued to fail with that fork. When I switched back to the latest official release, it started working again.
I wrote that test script above and just copied your source that creates client side hashes and printed them, and also verified they are the same as what is in redis.
LewisJEllis commentedon Dec 8, 2015
Okay, great, thanks for confirming. Also, are you waiting for the
readyevent? If not, then I think I have a hypothesis for what's going on. There are probably two things to do:readyevent, so as to avoid NOSCRIPT errors in certain situations on startup (what I think you encountered at the beginning of all this)davisford commentedon Dec 8, 2015
Ah, I had a callback for the
readyevent, but I didn't actually wait for it until the rest of the stuff bootstraps itself. So, yea, that may have a big part of the issue?davisford commentedon Dec 10, 2015
I've done some further testing, and it seems if you wait for the ready event before you try to call
Queue.processorQueue.createJobit works as expected. If you prematurely use those APIs, it seems to fail with this error.I have several different producer / consumer scripts, so I just need to go through them all and ensure each one waits for
readybefore trying to use theQueueapi.Seems like a doc fix would be sufficient?
davisford commentedon Dec 10, 2015
Yea, I got tricked by another one. I was doing something like this:
LewisJEllis commentedon Dec 10, 2015
Yep, that all seems like expected behavior. The
readyevent is documented here, but I do think it's a bit tucked away and possibly downplayed too much relative to how much of a caveat it can be. I think the plan to have the library automatically queue any commands called before thereadyevent should avoid these situations altogether. I've opened an issue to track that feature, which should come this weekend.skeggse commentedon Aug 9, 2017
As of
1.0.0, allQueueinternals should wait for the scripts to load prior to issuing commands that use said scripts.yss14 commentedon Nov 6, 2018
So what's the solution for this problem? Had this problem a few times in the last weeks on our production instances which all rely on bee-queue.
AmeyMore98 commentedon Dec 18, 2022
Hey, any fix for this?
AmeyMore98 commentedon Dec 18, 2022
In my case, the problem appears to be caused by Redis Cluster. When the command 'loadScriptIfMissing' is executed, half of the commands are executed on one shard and the other half on another. As a result, the shards do not have all of the scripts loaded, resulting in 'EVALSHA' failing. I figured this out by running the
MONITORcommand on all shards.Because I am not a Redis expert, can someone please confirm this hypothesis and provide a solution?
Thanks
compwright commentedon Dec 19, 2022
@AmeyMore98 that seems like a somewhat different error than was reported here, please open a new issue on the cluster issue. Thanks!