-
-
Notifications
You must be signed in to change notification settings - Fork 827
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
dev/core#4501 Redis - fix ttl on prev-next cache #27115
Conversation
Since this stuff needs a re-jig it seems good to switch to a function first
Thank you for contributing to CiviCRM! ❤️ We will need to test and review the PR. 👷 Introduction for new contributors
Quick links for reviewers |
@seamuslee001 @johntwyman this is probably the more useful one - along with possibly #27113 |
Currently our Redis cache is reasonably small so I'm not seeing an absurdly high number of keys, as occasionally we go so far as to issue a So I'm all for this change. Thanks @eileenmcnaughton |
@johntwyman yes ' eventually' is probably fair - this has taken years to get to this point for us |
It turns out we aren't setting this :-( I have put most of the detail in the upstream PR civicrm/civicrm-core#27115 Note that I have now cleared out all the keys on prod that have accumulated over x years since we started using redis & delete_deleted_contacts now takes seconds rather than minutes. This will stop them accumalting again. I didn't retain the change to the ttl as the problem was not the difference betwen keys being kept for 1 hour vs 6 hours but rather 6 hours vs 6 years.... Bug: T247347 Change-Id: Ic35b4cd0dd393d108b6c7a61abde3801615a1207
@totten we have just deployed this in production & I can confirm that the ttl is now being set on the prevnext redis keys! |
@eileenmcnaughton That's pretty cool. I did some Aside: Hadn't seen the redis Tests are passing. Changes are focused on Redis + PrevNext, so I don't think there's much else to test. Let's merge it |
thanks @totten - I actually have an action for parsing Redis monitor output - https://github.com/eileenmcnaughton/org.wikimedia.systemtools/blob/master/Civi/Api4/Redislog.php#L32 - it also has some parsing for the query log - https://wikitech.wikimedia.org/wiki/Fundraising/Internal-facing/CiviCRM#Performance_tracking - which is what I use for getting to the bottom of performance issues |
Overview
Redis - fix ttl on prev-next cache
Before
The ttl is not being set on the prevnext keys when the cache in use is
Redis
. This can been seen by doing a search in the UI via basic search or advanced search (but not search kit) and then opening upredis-cli
.In redis-cli you can find the keys created using the keys command
The ttpl for those keys can be seen with the ttl command - ie
Without this patch the
ttl
is always -1After
Afterwards the ttl should have a value at all times - note that I testing searching along with selecting & unselecting specific contacts and deleting a contact from within the set
Technical Details
The expires was being set on the key before it was created - not doing anything. I could not find any evidence that it is possible to create an empty key & hence concluded we have to set expires first key-add. It seems redis-cli accepts expires as part of the
set
command and I think our php library supports that for the basic set - but not all the variantsComments
tips
Redis
on a system with a password try something like this in .profileYou can also count them like this ....