-
-
Notifications
You must be signed in to change notification settings - Fork 725
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
replace hiredis gem with hiredis-client #11708
Conversation
The tests on 18035175968 are failing now due to a change in the behavior of the Redis client (reference) Failure/Error: Rails.cache.delete(@payment_method.calculator.preference_cache_key(key))
TypeError:
Unsupported command argument type: NilClass
command.map! do |element|
case element
when String
element
when Integer, Float, Symbol
element.to_s
else
raise TypeError, "Unsupported command argument type: #{element.class}"
end
end Do we sill want to upgrade? Tests on 18036538555 are passing on my local environment, I don't know why they not passing on the pipeline. |
Thanks for investigating this. I wonder why we don't use the redis gem directly. @mkllnk do you have any insights you can share? Otherwise, I agree with your approach, it makes sense to update our code to prevent sending |
8f757f6
to
22e878a
Compare
22e878a
to
d6890e9
Compare
Things may have changed but we tried this before and it caused connection problems in production: We need to investigate this further. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is so confusing. 😵
I just went through the different gems to find out what is doing what and my findings are:
- We depend on the redis gem. That's all we actually need.
- The hiredis gem was added for better performance but could be removed if it causes problems.
- The redis gem used to include a hiredis driver. So we would use redis which would know how to leverage hiredis for better performance.
- Version 5 of redis removed the hiredis driver and that causes the LoadError.
- At the same time, it started using the redis-client gem which does have a hiredis driver in its "companion gem" hiredis-client.
From the readme of the redis-client gem, the upgrade path would just be to add the hiredis-client gem while keeping the hiredis gem which is the thing that does the actual work. It doesn't mention any additional require statements. I would think that bundler requires it already and the default driver is set automatically. I was able to confirm that by calling RedisClient.default_driver
in the console.
I will share where I got to. But there's another issue still open:
We may need to test this on a newer staging server for a bit to see if we get that error again. Last messages on that issue suggest that even after switching to hiredis-client that error was still there. So if we don't have a particular reason to upgrade redis then maybe we can keep the current version or dump hiredis altogether hoping that the default redis is catching up on the performance.
I think that I'm still confused. I tried this branch now and everything seems to work even after uninstalling hiredis. And it's using the hiredis-client. Maybe the hiredis interface comes with the redis server and redis-client has everything it needs to use it? Only a performance benchmark could tell us if it actually works. |
I did a quick benchmark. Without hiredis-client: r = RedisClient.config.new_client
t0=Time.now; 100_000.times { r.call("SET", "foo", "bar") }; puts Time.now - t0;
# 4.572544891 With hiredis-client: t0=Time.now; 100_000.times { r.call("SET", "foo", "bar") }; puts Time.now - t0;
# 3.840093155 In this simple test, we reduce execution time by 16%. Let's go with this. I'll just add a commit for cleaning up. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, thanks for looking into all of this Maikel.
Based on that info, this seems to be the right approach, and specs pass!
So we can try deploying to staging. I'd suggest all three servers given the issues had before.
In addition, it seems worth doing some testing. I didn't see any mention on that old PR about what actions caused the issues, but Maikel previously suggested bulk invoice printing which covers cable_ready, so I suggest we try that.
Deploy to Staging:
Died after waiting 5 mins for task to complete. Why does that "transient data" step take so long anyway?
Success! 🤷 |
Testing [au-staging]https://staging.openfoodnetwork.org.au/admin/orders Any other testing necessary? If not, and if deploy to all staging servers succeeds, shall we merge? |
The previous pull request was merged and then we noticed a flaky spec. The use of cable_ready has been increased since and we ironed out a few specs to work more reliably with reflexes. So I'm more certain now that the error would show up more consistently instead of just being flaky. Plus your testing, it all seems good. Let's merge. |
We need to revert this again. Lots of test failures. |
What? Why?
In this PR, the dependabot is trying to upgrade the redis library to 5.0.8. The tests are failing due to what looks like a compatibility issue between
redis
andhiredis
(the latest release was in 2018).I found that
hiredis-client
is used in the example given on redis gem documentation.In this PR, I want to check if replace
hiredis
withhiredis-client
will solve the issue.What should we test?
Release notes
Changelog Category (reviewers may add a label for the release notes):
The title of the pull request will be included in the release notes.
Dependencies
Documentation updates