-
-
Notifications
You must be signed in to change notification settings - Fork 825
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
Don't clear the GroupContactCache until we're ready to insert the new version #21384
Conversation
(Standard links)
|
581b1ad
to
712855a
Compare
@mattwire Looking at it I think maybe we should instead just remove
Obviously this code has history but I think the only reason to call |
@eileenmcnaughton Yes, I've made lot's of iterations over this code and I know you have recently too. So I think this is just a further iteration now it's a bit clearer. I do like the idea of having the actual clear in it's own function rather than hidden inside the |
@mattwire OK - I think I'm following now. So what we are 'losing' in this approach is the idea that we don't set the cache_date to NULL unless we are sure it has cleared properly. But I think the theory is that it doesn't matter - as long as it is 'invalid' it won't be used again until it is updated. So we don't need that bit. So I think I'm OK with this but ideally you would deploy it in production for a wee while & then we merge. As an aside - there was an idea that it is possible to spawn a process after the browser is released & we could transfer the temp table to the cache table in a shutdown process after results have been delivered. However, I haven't managed to figure out if that really is possible or just something @totten thought was possible. |
@eileenmcnaughton This has been in production for 10 days now and is working well. I'm still seeing some deadlocks but they're now consistently when the Marking as |
OK I read through this again and I think it's right. Let's merge If we can figure out what is conflicting with the |
@pfigel fyi |
Thanks @eileenmcnaughton I may not be able to get further than #21430 in investigating as funding for this round has pretty much run out. But will see if there are any further clues in the logs etc. |
Overview
See technical details below. We appear to be clearing group_contact_cache multiple times and may be partially responsible for deadlocks I'm still seeing on a client site.
Before
Clear the contact cache and reset cache date part way through build of temp table for new cache.
After
Cache invalidated before build, cleared before update.
Technical Details
Previously we were clearing the cache twice:
CRM_Contact_BAO_GroupContactCache::load()
callsbuildGroupContactTempTable()
which callsinsertGroupContactsIntoTempTable()
which calledclearGroupContactCache()
which removed data from the cache table and cleared the cache date.updateCacheFromTempTable()
had it's own version of the query to remove data from the cache table but the data should have already been removed by 1. above and will only exist if we have processes running in parallel to rebuild the caches.Now we explicitly clear the cache once only:
CRM_Contact_BAO_GroupContactCache::load()
callsbuildGroupContactTempTable()
which callsinsertGroupContactsIntoTempTable()
.clearGroupContactCache()
is called explicitly but does not reset the cache date and does not need to run within a transaction.updateCacheFromTempTable()
does not need to do any cache clearing and just inserts directly.Comments
@eileenmcnaughton