radix: EvalAction never runs EVAL, only EVALSHA

When I run my EvalAction.Cmd(), it always fails with the following “NOSCRIPT” error:

NOSCRIPT No matching script. Please use EVAL.

Here’s a snippet that shows how I’m using it (I cannot show the real code since this is for work):

var data string
if err := pool.Do(script.Cmd(&data, "MYKEY", strconv.FormatInt(time.Now().Unix(), 10))); err != nil {
	return nil, fmt.Errorf("failed to run Lua script: %v", err)
}
if data == "" {
	return nil, nil
}

Where pool is a *radix.Pool and script is a radix.EvalScript.

While troubleshooting, I modified some code in action.go locally to get more debug info. Here’s the code with my changes (just MarshalRESP and Run):

func (ec *evalAction) MarshalRESP(w io.Writer) error {
	fmt.Printf("evalAction.MarshalRESP: %+v\n", ec) // ADDED

	// EVAL(SHA) script/sum numkeys args...
	if err := (resp2.ArrayHeader{N: 3 + len(ec.args)}).MarshalRESP(w); err != nil {
		return err
	}

	var err error
	if ec.eval {
		fmt.Println("USING EVAL") // ADDED
		err = marshalBulkStringBytes(err, w, eval)
		err = marshalBulkString(err, w, ec.script)
	} else {
		fmt.Println("NOT USING EVAL") // ADDED
		err = marshalBulkStringBytes(err, w, evalsha)
		err = marshalBulkString(err, w, ec.sum)
	}

	err = marshalBulkString(err, w, strconv.Itoa(ec.numKeys))
	for i := range ec.args {
		err = marshalBulkString(err, w, ec.args[i])
	}
	return err
}

func (ec *evalAction) Run(conn Conn) error {
	run := func(eval bool) error {
		ec.eval = eval
		fmt.Println("evalAction func run eval=", eval) // ADDED
		fmt.Printf("evalAction: %+v\n", ec) // ADDED
		if err := conn.Encode(ec); err != nil {
			return err
		}
		return conn.Decode(resp2.Any{I: ec.rcv})
	}

	err := run(false)
	if err != nil && strings.HasPrefix(err.Error(), "NOSCRIPT") {
		err = run(true)
	}
	return err
}

This is the (script redacted) log output I get when I run the test code snippet:

evalAction func run eval= false
evalAction: &{EvalScript:{script:REDACTED
 sum:5bad24f2ee4390d367eee730d6a0645a409d1e61 numKeys:1} args:[MYKEY 1563817342] rcv:0xc000150350 eval:false}
evalAction.MarshalRESP: &{EvalScript:{script:REDACTED sum:5bad24f2ee4390d367eee730d6a0645a409d1e61 numKeys:1} args:[MYKEY 1563817342] rcv:0xc000150350 eval:false}
NOT USING EVAL
evalAction func run eval= true
evalAction: &{EvalScript:{script:REDACTED sum:5bad24f2ee4390d367eee730d6a0645a409d1e61 numKeys:1} args:[MYKEY 1563817342] rcv:0xc000150350 eval:true}
failed to run Lua script: NOSCRIPT No matching script. Please use EVAL.

And in addition, here’s the MONITOR output from the Redis instance (redacted where confidential):

1563818548.404515 EVALSHA 5bad24f2ee4390d367eee730d6a0645a409d1e61 1 MYKEY 1563818548
1563818551.638893 INFO
1563818561.649949 INFO
1563818571.727928 INFO

So it almost looks like it never gets re-run. Weird.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 18 (11 by maintainers)

Commits related to this issue

Most upvoted comments

@mediocregopher I wasn’t super attached to the PR 👍 I really want to thank both you and @nussjustin for the quick responses and the effort you put into fixing this. You guys are awesome 🥇