Tencent / Tendis

Tendis is a high-performance distributed storage system fully compatible with the Redis protocol.
http://tendis.cn
Other
2.92k stars 319 forks source link

lua脚本执行有相关错误日志:expected failed:-ERR:6,msg:NotFound #258

Closed smile689 closed 6 months ago

smile689 commented 9 months ago

Description

日志中执行lua脚本报错日志如下: I1211 15:05:06.715695 961425 script_manager.cpp:36] new LuaState, threadid: 139975521158912 _mapLuaState size: 18 E1211 15:05:06.715847 961425 script_manager.cpp:140] expected failed:-ERR:6,msg:NotFound: /data/tendis_bin/workspace/tendisplus-master-release/pipeline_376/tendisplus/src/tendisplus/script/script_manager.cpp 140 script_manager.cpp:140找不到,是有什么脚本目录配置么

Expected Behavior

Current Behavior

Possible Solution

Steps to Reproduce (for bugs)

Context

Your Environment

raffertyyu commented 9 months ago

请问方便发下具体的命令 以及是否可以复现吗。

smile689 commented 9 months ago

@raffertyyu 其实就是参照了redission的方法。项目代码里面具体的lua脚本就是如下几段: --- 获取锁 "if (redis.call('exists', KEYS[1]) == 0) " + "then redis.call('hset', KEYS[1],ARGV[1], 1); " + "redis.call('pexpire', KEYS[1], ARGV[2]); " + "return nil; end; " + "if (redis.call('hexists', KEYS[1], ARGV[1]) == 1) " + "then redis.call('hincrby', KEYS[1], ARGV[1], 1); " + "redis.call('pexpire', KEYS[1], ARGV[2]); " + "return nil; end; " + "return redis.call('pttl', KEYS[1]);"

--- 释放锁 "if (redis.call('exists', KEYS[1]) == 0) then return 0; end; " + "if (redis.call('hexists', KEYS[1], ARGV[1]) == 0) then return 0; end; " + "local counter = redis.call('hincrby', KEYS[1], ARGV[1], -1); " + "if (counter > 0) then redis.call('pexpire', KEYS[1], ARGV[2]); return 1; " + "else redis.call('del', KEYS[1]); return 1; end;"

实际查看日志,目前正常一直会有这样的日志。

raffertyyu commented 9 months ago

我看了一下代码,这里是tendis 在执行evalsha的时候没找到对应的脚本打的日志,一般是由于没有提前执行script load 导致的。属于正常现象,确实不应该打日志。后续版本我去掉这个日志提示。

smile689 commented 6 months ago

好的,了解。多谢