X Tutup
The Wayback Machine - https://web.archive.org/web/20200912012348/https://github.com/phpredis/phpredis/issues/1245
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

cluster use script command -ERR Unknown SCRIPT subcommand or wrong # of args #1245

Closed
ppanphper opened this issue Sep 29, 2017 · 2 comments
Closed
Assignees
Milestone

Comments

@ppanphper
Copy link

@ppanphper ppanphper commented Sep 29, 2017

Expected behaviour

SCRIPT EXISTS will return an array with TRUE or FALSE for each passed script

Actual behaviour

return false

I'm seeing this behaviour on

  • OS: Centos 6.5
  • Redis: 3.0.7
  • PHP: 5.6.1
  • phpredis: 3.1.3

Steps to reproduce, backtrace or example script

connect redis cluster...

$keys = ['test'];
$args = [100];
$sha1 = "727c0136efce8e1e7b34a5d1a29c87b77a9348ff";
$script = "local count = redis.call('incr',KEYS[1]); if tonumber(count) == 1 then
redis.call('expire',KEYS[1],ARGV[1]); end; return count;";

// 检测脚本是否存在服务端
$scriptExists = $redisObj->script('exists', $sha1);
if(!$scriptExists || !$scriptExists[0]) {
// load脚本
$serverSha1 = $redisObj->script('load', $script);
if($serverSha1 !== $sha1) {
throw new Exception($scriptKey.'脚本的sha1与服务端返回的sha1不一致'.$sha1.'=='.$serverSha1, 999);
}
}
$keyCount = count($keys);
// 不需要键名索引,用数字重新建立索引
$args = array_values(array_merge($keys, $args));
$result = $redisObj->evalSha($sha1, $args, $keyCount);

I've checked

  • [Y�] There is no similar issue from other users
  • Issue isn't fixed in develop branch

Evidence

Cluster

poll([{fd=9, events=POLLIN|POLLPRI|POLLERR|POLLHUP}], 1, 0) = 0 (Timeout)
sendto(9, "*2\r\n$6\r\nSCRIPT\r\n$40\r\n727c0136efce8e1e7b34a5d1a29c87b77a9348ff\r\n", 63, MSG_DONTWAIT, NULL, 0) = 63
poll([{fd=9, events=POLLIN|POLLPRI|POLLERR|POLLHUP}], 1, 0) = 0 (Timeout)
poll([{fd=9, events=POLLIN|POLLERR|POLLHUP}], 1, 500) = 1 ([{fd=9, revents=POLLIN}])
recvfrom(9, "-ERR Unknown SCRIPT subcommand or wrong # of args.\r\n", 8192, MSG_DONTWAIT, NULL, NULL) = 52
poll([{fd=9, events=POLLIN|POLLPRI|POLLERR|POLLHUP}], 1, 0) = 0 (Timeout)
sendto(9, "*2\r\n$6\r\nSCRIPT\r\n$127\r\nlocal count = redis.call('incr',KEYS[1]); if tonumber(count) == 1 then redis.call('expire',KEYS[1],ARGV[1]); end; return count;\r\n", 151, MSG_DONTWAIT, NULL, 0) = 151
poll([{fd=9, events=POLLIN|POLLPRI|POLLERR|POLLHUP}], 1, 0) = 0 (Timeout)
poll([{fd=9, events=POLLIN|POLLERR|POLLHUP}], 1, 500) = 1 ([{fd=9, revents=POLLIN}])
recvfrom(9, "-ERR Unknown SCRIPT subcommand or wrong # of args.\r\n", 8192, MSG_DONTWAIT, NULL, NULL) = 52

Single node

sendto(5, "*3\r\n$6\r\nSCRIPT\r\n$6\r\nEXISTS\r\n$40\r\n727c0136efce8e1e7b34a5d1a29c87b77a9348ff\r\n", 75, MSG_DONTWAIT, NULL, 0) = 75
poll([{fd=5, events=POLLIN|POLLPRI|POLLERR|POLLHUP}], 1, 0) = 0 (Timeout)
poll([{fd=5, events=POLLIN|POLLERR|POLLHUP}], 1, 60000) = 1 ([{fd=5, revents=POLLIN}])
recvfrom(5, "*1\r\n:1\r\n", 8192, MSG_DONTWAIT, NULL, NULL) = 8
poll([{fd=5, events=POLLIN|POLLPRI|POLLERR|POLLHUP}], 1, 0) = 0 (Timeout)
sendto(5, "*5\r\n$7\r\nEVALSHA\r\n$40\r\n727c0136efce8e1e7b34a5d1a29c87b77a9348ff\r\n$1\r\n1\r\n$7\r\ntest_db\r\n$3\r\n100\r\n", 93, MSG_DONTWAIT, NULL, 0) = 93
poll([{fd=5, events=POLLIN|POLLPRI|POLLERR|POLLHUP}], 1, 0) = 0 (Timeout)
poll([{fd=5, events=POLLIN|POLLERR|POLLHUP}], 1, 60000) = 1 ([{fd=5, revents=POLLIN}])
recvfrom(5, ":1\r\n", 8192, MSG_DONTWAIT, NULL, NULL) = 4

@ppanphper
Copy link
Author

@ppanphper ppanphper commented Sep 29, 2017

Cluster

cluster

Single node
singlenode

@yatsukhnenko yatsukhnenko added the bug label Sep 29, 2017
@yatsukhnenko yatsukhnenko self-assigned this Sep 29, 2017
@yatsukhnenko yatsukhnenko added this to the 4.0.0 milestone Sep 29, 2017
@yatsukhnenko
Copy link
Member

@yatsukhnenko yatsukhnenko commented Oct 4, 2017

@ppanphper, btw script is so-called direted command. This mean that first parameter should be a key or [host,port] array to route command to node directly

@yatsukhnenko yatsukhnenko removed the bug label Oct 4, 2017
yatsukhnenko added a commit that referenced this issue Oct 4, 2017
Issue #1245
Move building `script` command logic to `redis_build_script_cmd`
and use it in Redis and RedisCluster objects.
Fix arginfo for `RedisCluster::script`.
Fix memory leak in `cluster_raw_cmd` when `cluster_cmd_get_slot` fails.
yatsukhnenko added a commit that referenced this issue Oct 5, 2017
Issue #1245
Move building `script` command logic to `redis_build_script_cmd`
and use it in Redis and RedisCluster objects.
Fix arginfo for `RedisCluster::script`.
Fix memory leak in `cluster_raw_cmd` when `cluster_cmd_get_slot` fails.
yatsukhnenko added a commit that referenced this issue Oct 5, 2017
Issue #1245
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.
X Tutup