Closed as not planned
Description
Expected Behavior
When using Script.Run()
within a Redis pipeline/transaction, if a script hasn't been loaded (triggering NOSCRIPT), the method should automatically fall back to EVAL as it does in non-pipeline contexts. This is the documented behavior in the Run()
method comment: "Run optimistically uses EVALSHA to run the script. If script does not exist it is retried using EVAL."
Current Behavior
When using Script.Run()
within a pipeline/transaction, the NOSCRIPT fallback mechanism fails to work. The pipeline execution fails with "NOSCRIPT No matching script. Please use EVAL" instead of automatically falling back to EVAL.
Steps to Reproduce
- Create a new Redis client and flush existing scripts
- Create a pipeline
- Attempt to run a script using
Script.Run()
within the pipeline - Execute the pipeline
Minimal reproduction:
package main
import (
"context"
"testing"
"github.com/redis/go-redis/v9"
"github.com/stretchr/testify/assert"
)
func TestScriptRunPipelineFallback(t *testing.T) {
ctx := context.Background()
client := redis.NewClient(&redis.Options{
Addr: "localhost:6379",
})
defer client.Close()
err := client.ScriptFlush(ctx).Err()
assert.NoError(t, err)
script := redis.NewScript(`
return ARGV[1]
`)
pipe := client.TxPipeline()
script.Run(ctx, pipe, []string{}, "test_value")
_, err = pipe.Exec(ctx)
assert.NoError(t, err) // This fails with NOSCRIPT error
}
Context (Environment)
- go-redis version: v9
- Go version: 1.23.2
Metadata
Metadata
Assignees
Labels
No labels