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

lua scripts readonly error on slave replica #4130

Open
imhun opened this issue Nov 14, 2024 · 5 comments
Open

lua scripts readonly error on slave replica #4130

imhun opened this issue Nov 14, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@imhun
Copy link

imhun commented Nov 14, 2024

Describe the bug
A clear and concise description of what the bug is.

org.redisson.client.RedisException: ERR Error running script (call to 149c5a8bf18676fd99e9e6e24923bd64d9b62f94):
@user_script:2: -READONLY You can't write against a read only replica..
channel: [id: 0xd5d027a5, L:/100.64.0.3:58328 - R:dev.ip.local/172.18.78.49:16380]
command: (EVAL),
params: [if ((redis.call('exists', KEYS[1]) == 0) or (redis.call('hexists', KEYS[1], ARGV[2]) == 1)) then redis.call('hincrby', KEYS[1], ARGV[2], 1); redis.call('pexpire', KEYS[1], ARGV[1]); return nil; end; return redis.call('pttl', KEYS[1]);, 1, fabric.Lock.OPERATION_LOG.lock, 5000, 2f3c8128-65f1-42e8-8b6a-4c910db0b75d:183],
promise: java.util.concurrent.CompletableFuture@2b83f94d[Not completed, 1 dependents]
at org.redisson.client.handler.CommandDecoder

To Reproduce
Steps to reproduce the behavior:
lua scripts:

if ((redis.call('exists', KEYS[1]) == 0) or (redis.call('hexists', KEYS[1], ARGV[2]) == 1)) then 
redis.call('hincrby', KEYS[1], ARGV[2], 1); 
redis.call('pexpire', KEYS[1], ARGV[1]); 
return nil; 
end;
return redis.call('pttl', KEYS[1]);

See error
@user_script:2: -READONLY You can't write against a read only replica.. channel

Expected behavior
no error

Environment (please complete the following information):

  • OS: [ Alibaba Cloud Linux 3 ]
  • Kernel: # Command: uname -a
  • Linux dragonfly-1 5.10.134-14.al8.aarch64 finalize blpop algorithm #1 SMP Thu Apr 27 16:43:40 CST 2023 aarch64 aarch64 aarch64 GNU/Linux
  • Containerized?: [ Kubernetes]
    dragonfly-operator 1.1.8,2 replica
  • Dragonfly Version: [1.25.1]

Reproducible Code Snippet

# Minimal code snippet to reproduce this bug

Additional context
Add any other context about the problem here.

@imhun imhun added the bug Something isn't working label Nov 14, 2024
@romange
Copy link
Collaborator

romange commented Nov 14, 2024

Why it is a bug? hincrby and pexpire are not allowed on replica.

@imhun
Copy link
Author

imhun commented Nov 14, 2024

that should be sent to the primary, and the client does not know which is the primary or replica

@romange
Copy link
Collaborator

romange commented Nov 14, 2024

sounds like a configuration issue with your client then. you should connect it to the primary

@imhun
Copy link
Author

imhun commented Nov 15, 2024

lettuce client 6.3
spring boot 3.3
configuration is as follows
image
the following error occurs when the application is started

Caused by: io.lettuce.core.RedisReadOnlyException: READONLY You can't write against a read only replica.
	at io.lettuce.core.internal.ExceptionFactory.createExecutionException(ExceptionFactory.java:144)
	at io.lettuce.core.internal.ExceptionFactory.createExecutionException(ExceptionFactory.java:116)
	at io.lettuce.core.protocol.AsyncCommand.completeResult(AsyncCommand.java:120)
	at io.lettuce.core.protocol.AsyncCommand.complete(AsyncCommand.java:111)
	at io.lettuce.core.protocol.CommandWrapper.complete(CommandWrapper.java:63)
	at io.lettuce.core.protocol.CommandHandler.complete(CommandHandler.java:745)
	at io.lettuce.core.protocol.CommandHandler.decode(CommandHandler.java:680)
	at io.lettuce.core.protocol.CommandHandler.channelRead(CommandHandler.java:597)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
	at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1407)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:440)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
	at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:918)
	at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166)
	at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:788)
	at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:724)
	at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:650)
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:562)
	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:994)
	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)

and redis doesn't have that problem

Is there any special configuration required for dragonflydb?

@romange
Copy link
Collaborator

romange commented Nov 15, 2024

no, if your client is connected to dragonfly to port 16380 and this dragonfly is a master it should just work.

can you post redis-cli -p 16380 -a <passwrd> -h dev.ip.local INFO ALL here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants