Skip to content

Allow executing scripts inside queueing mode  #1989

Closed
@Batanick

Description

@Batanick

Hey guys!

Right now it's not allowed to execute Lua scripts from MULTI block, due to check in the JedisScriptingCommands.

As far as I know, this behavior is allowed by Redis

127.0.0.1:6379> MULTI
OK
127.0.0.1:6379> eval "return 42" 0
QUEUED
127.0.0.1:6379> EXEC
1) (integer) 42

and WATCH is also working correctly in such circumstances

127.0.0.1:6379> incr test
(integer) 2
127.0.0.1:6379> watch test
OK
127.0.0.1:6379> multi
OK
# MODIFYING test value from a different client here 
127.0.0.1:6379> eval "return 42" 0
QUEUED
127.0.0.1:6379> exec
(nil)

To give you some context we have a use case when we have a

  • user_data
  • counter
    The user_data that needs to be checked inside app logic (cannot move it to lua :( ), modified and committed together with the counter update

We want to process this in the following manner (pseudo code here):

  1. WATCH user_data
  2. GET user_data
  3. Do some application-level checks and magic
  4. Start MULTI
  5. Execute a script that will decrement the counter and update user_data
  6. Run EXEC

Unfortunately, this is failing right now with

2021-03-03 12:19:28.877 ERROR 36671 --- [    Test worker] c.d.magpie.service.AssignShiftAction     : java.lang.UnsupportedOperationException
	at org.springframework.data.redis.connection.jedis.JedisScriptingCommands.eval(JedisScriptingCommands.java:124)
	at org.springframework.data.redis.connection.DefaultedRedisConnection.eval(DefaultedRedisConnection.java:1523)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:567)
	at org.springframework.data.redis.core.CloseSuppressingInvocationHandler.invoke(CloseSuppressingInvocationHandler.java:61)

Is this intended behavior or this check can be removed?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions