-
-
Notifications
You must be signed in to change notification settings - Fork 814
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
Simplify and improve performance of query to insert updated cache #21943
Conversation
(Standard links)
|
@mattwire perhaps the site you deployed this on does not have Test failures are showing:
|
268d9a6
to
55d2142
Compare
Thanks @colemanw now fixed to be |
@mattwire yeh and also the MariaDB |
55d2142
to
10a7c25
Compare
Jenkins re test this please |
@johntwyman you may be interested in this |
Just noting that on MariaDB 10.3.28 with this patch applied, cache locking did not work properly. Cache lock errors occurred. |
@agileware-justin Can you confirm what cache lock errors you got? Ideally a backtrace or similar.
|
@mattwire sure thing.
|
@mattwire do you plan to work on this work? If not it would be better to close this PR. |
@jaapjansma Yes there are a few people reviewing / running this and the other ACL/GroupContact cache PRs without problems. @agileware-justin I've looked that the backtrace but can't see how this PR would cause that issue. Could it be possible that the trigger for your cache lock error was hidden before by a (groupcontact) cache lock that is now solved so it is "getting further in the code"? I can see that it triggered in your backtrace as a result of a full cache flush triggered via |
@mattwire if you are confident that the errors are unrelated then happy to accept your assessment. I guess what is missing here is some detail about what the success criteria is for this PR, what should people be testing and looking for to confirm this is working correctly in their environment. |
I've managed to pull some benchmarks on both #21993 & #21943 How did i conduct the benchmarksI've executed the same benchmark 4 times for each scenario (stated below) over a civicrm installation with approx 320 smartgroups and a few ACL rules (less than 10). However, the benchmark was being limited to 100 smartgroups per run, in order to avoid too much cpu stress. After each scenario was finished, I've calculated the average time per completion task per scenario along with a percentage of performance increase or decrease I used benchmarktools to execute the benchmarks, by calling this command: The 4 scenarios
The 4 benchmarks
Results
Personal notes
I hope the above helps. |
FYI our tests haven't been as well organised as @VangelisP but we've seen nothing to indicate this PR causes problems. Most notably, no deadlocks, no failed INSERTs, etc., arround the civicrm_group_contact_cache table. |
@johntwyman just wondering if your "test environ" was processing donations, memberships, sending mailings as well as doing the cache rebuilds at the time of testing? |
@agileware-justin not really, no. Just specifically focusing on smart group cache builds, cache clears, etc. |
I have had this PR running on a production site for a week with several concurrent users (~120/week) and not had any issues. Using Multisite so using the |
Overview
Both
INSERT IGNORE
andSELECT DISTINCT
reduce performance of queries significantly because of the way they work internally (see various articles online).We originally had
INSERT IGNORE
to guard against a lock not working properly (they used to be unreliable) when updating thecivicrm_group_contact_cache
table but that is not necessary anymore as we've got to a point where the caching code is much more sensible.SELECT DISTINCT
was guarding against there being duplicatecontact_id
s in the temporary cache table. That also should not be happening but requires further validation of a more complex function to ensure that is the case. Changing toGROUP BY
has the same effect and is generally more performant.Before
Use of
INSERT IGNORE
andSELECT DISTINCT
.After
Use of
INSERT
andGROUP BY
for reasons described above.Technical Details
Described above.
Comments
I have had this deployed on a client site for some time with no obvious issues.