-
-
Notifications
You must be signed in to change notification settings - Fork 58
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
Using Rqueue with ReadFrom.REPLICA_PREFERRED fails #19
Comments
Hi @tuneyou Rqueue relies on Spring heavily for read/write, need to see what's causing this issue. Also what's the error you're getting? |
Of Course :) Lettuce Conf: @bean Redis configuration: Master-slave standalone Error: org.springframework.data.redis.RedisSystemException: Error in execution; nested exception is io.lettuce.core.RedisCommandExecutionException: ERR Error running script (call to f_cabaad845bb1fbf876872b4bb21f919f895cd53e): @user_script:14: @user_script: 14: -READONLY You can't write against a read only slave. |
Hmm, I was looking into this. Can you use master preferred? I see it will bring performance penalty the system, this problem is coming due to the underlying code in the spring-data that assumes that script has to be run on slave nodes for some reason, will dig into details why that's the case. You can use two different redis connection, if you really want to use read preferred for your application, as of now I have to say Rqueue requires Master only. |
Thank you very much for your prompt responses. Thank you very much! |
Can you provide more details about this? I would like to see what's causing this to happen, if visibilityTimeout is too small then only this is possible, in that case you should increase visibility timeout. On the other note, Rqueue very rarely reads from, due to atomic operation, most of the times it reads and writes in the same call. |
BTW,
My need is that each request will be handled only once, it does happen when using only 1 server, but on N servers, there are N consumers for same message, and according to redis logic, it sends the message to everyone, thus, this solution wasn't good for me. |
As long as your Redis is alive, data will be there, it won't be lost. If Redis dies and you didn't have enable disk persistent data would be lost. So it relies on the Redis, if data persist there then it will be able to handle all fallbacks. Also I didn't understand one of your point, if you've cluster setup then you can write to only master nodes not to all. So there's no chance of utilising entire Redis setup. |
Yes, it automatically writes only to master, but prefer reading from slave. |
There seems to be some issue, look at this ticket. |
Interesting... what do you suggest besides putting MATER PREFERRED. |
I would suggest to use MASTER_PREFERRED and provide an additional connection factory to Rqueue to deal with this problem. Other part of the applications can continue to use REPLICA_PREFERRED. I don't have any other workaround apart from going back doing some transaction stuff and changing again entire code. That would also require master connection. From the number of read/writes perspective, Rqueue does almost same number of read and writes, so I'm not gaining much thing even by providing REPLICA_PREFERRED. |
I've tried this, but the code wasn't compiled.
|
What's the compilation error? It should compile perfectly. |
when I change it to this: @bean
I get: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'messageService': Unsatisfied dependency expressed through field 'rqueueMessageSender'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'rqueueMessageSender' defined in class path resource [com/github/sonus21/rqueue/spring/RqueueListenerConfig.class]: Unsatisfied dependency expressed through method 'rqueueMessageSender' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'rqueueMessageTemplate' defined in class path resource [com/github/sonus21/rqueue/spring/RqueueListenerConfig.class]: Unsatisfied dependency expressed through method 'rqueueMessageTemplate' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'rqueueConfig' defined in class path resource [com/github/sonus21/rqueue/spring/RqueueListenerConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.github.sonus21.rqueue.config.RqueueConfig]: Factory method 'rqueueConfig' threw exception; nested exception is java.lang.NullPointerException |
Lettuce connection factory is not created correctly, you need to call |
Hello Sonus, Thanks :) |
Hello
When you're using custom executor then you should set this number as What would happen if I set this to very high value? The If you don't set this then it assumes that you want to use default size that's 2 threads per listeners. |
Currently this is my code: @bean I still didn't understand what's the relation between those paramters. Thanks :) |
This tells how many workers should be running at any point of time, so you could be running 50 threads at some point of times.
This tells that we should always have 20 threads ready for workers.
This tells that we can create maximum 100 threads, and as the execution completed they are recycled for re-usage and some of them would be discarded to reach
This number says even though we have 100 runnings threads we can have 100 task waiting in the queue, that can be dequeued and executed by the existing thread as soon as they complete the task. Now coming back to How many queues do you have? MaxNumWorkers = 100 (MaxPoolSize) + 100(QueueCapacity) - N But I have worries, really you should be running 100 threads for your use-case. |
Perfect, thank you sonus! |
Would you mind, if I can add your web/company name in the new section Used by? You can also raise a PR for the same. |
Of course you can :)
…On Fri, May 29, 2020, 16:50 Sonu Kumar ***@***.***> wrote:
Would you mind, if I can add your web/company name in the new section Used
by? You can also raise a PR for the same.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#19 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AHBAKJV5K7URXJ3G63YX7IDRT64RTANCNFSM4M66IQYA>
.
|
Thanks, I have added :) |
Hello Sonus, I am trying to do the same, but on bootup the application throws the below error. Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'simpleRqueueListenerContainerFactory' defined in class path resource [com/api/changejar/config/redis/RedisStandaloneConfig.class]: Unsatisfied dependency expressed through method 'simpleRqueueListenerContainerFactory' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'rqueueMessageHandler' defined in class path resource [com/github/sonus21/rqueue/spring/boot/RqueueListenerAutoConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.github.sonus21.rqueue.listener.RqueueMessageHandler]: Circular reference involving containing bean 'com.github.sonus21.rqueue.spring.boot.RqueueListenerAutoConfig' - consider declaring the factory method as static for independence from its containing instance. Factory method 'rqueueMessageHandler' threw exception; nested exception is java.lang.NullPointerException
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'rqueueMessageHandler' defined in class path resource [com/github/sonus21/rqueue/spring/boot/RqueueListenerAutoConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.github.sonus21.rqueue.listener.RqueueMessageHandler]: Circular reference involving containing bean 'com.github.sonus21.rqueue.spring.boot.RqueueListenerAutoConfig' - consider declaring the factory method as static for independence from its containing instance. Factory method 'rqueueMessageHandler' threw exception; nested exception is java.lang.NullPointerException
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.github.sonus21.rqueue.listener.RqueueMessageHandler]: Circular reference involving containing bean 'com.github.sonus21.rqueue.spring.boot.RqueueListenerAutoConfig' - consider declaring the factory method as static for independence from its containing instance. Factory method 'rqueueMessageHandler' threw exception; nested exception is java.lang.NullPointerException Caused by: java.lang.NullPointerException: null |
Hello,
When using ReadFrom.REPLICA_PREFERRED, it keeps trying to write to slave server, instead of just reading from it.
The text was updated successfully, but these errors were encountered: