Skip to content
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#90 Disable Only Full Group By sql mode on specific queries t… #12043

Merged
merged 1 commit into from
Apr 29, 2018

Conversation

seamuslee001
Copy link
Contributor

…o get tests to pass so we can switch to using MySQL 5.7 for PR Tests

Overview

This disables the ONLY_FULL_GROUP_BY sql mode on specific queries to get the failed tests here https://test.civicrm.org/job/CiviCRM-Core-Matrix/CIVIVER=master,label=ubuntu1604/lastCompletedBuild/testReport/ to pass

Before

Tests fail on MySQL 5.7

After

Tests Pass

ping @eileenmcnaughton @monishdeb @totten

@eileenmcnaughton
Copy link
Contributor

@seamuslee001 can we leave the reports out of the first iteration of this? I think we can refine it a bit - I would be happy to merge on pass the rest

@seamuslee001
Copy link
Contributor Author

ok i'll move that to another PR

…o get tests to pass so we can switch to using MySQL 5.7 for PR Tests
@seamuslee001
Copy link
Contributor Author

@eileenmcnaughton done now

@eileenmcnaughton
Copy link
Contributor

I'm happy if jenkins is

@seamuslee001
Copy link
Contributor Author

merging as per merge on pass

@seamuslee001 seamuslee001 merged commit 26adcf7 into civicrm:master Apr 29, 2018
@eileenmcnaughton
Copy link
Contributor

Will be interesting to see test run overnight

@seamuslee001
Copy link
Contributor Author

@eileenmcnaughton there are 3 groups of test failures these which = about 2 tests failures, then there are the reports that = about 4 test failures and then there are the 2 international strings API call failures

$dao->query($query);

CRM_Core_DAO::enableFullGroupByMode();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy if jenkins is

Agree and disagree with this comment.

The idea of temporarily disabling ONLY_FULL_GROUP_BY seems good. (I originally voted to disable it across all of Civi... so doing it in a narrower way is also OK.)

The implementation in this PR feels a little a leaky -- e.g. if the system starts in
ONLY_FULL_GROUP_BY=on, then this correctly restores it. However, if the system starts without ONLY_FULL_GROUP_BY=off, then this incorrectly switches us to ONLY_FULL_GROUP_BY=on. A leak like this can influence other code.

In practice, TrackableURLOpen is generally called on its own (without a lot of other business logic), so a leak isn't likely to be symptomatic. The main time we care about leaks is in running unit-tests. Thus, I mostly agree with @Eileen's point -- if it works in the tests, then it's OK.

However, TrackableURLOpen is a bit special in how very isolated the use-case is. If you were to reproduce this coding pattern in other contexts, then there'd be more risk of a leak producing symptoms.

Which is a long-winded way of saying... this passes and it's OK, but when making a temporary change to global state in the future, let's try to be a little more strict about cleanup.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@totten will it turn it back on tho? i think by the inclusion of the checking of this function https://github.com/civicrm/civicrm-core/blob/master/CRM/Utils/SQL.php#L114 in the turning back on function will mean that ONLY if its in the global defaults and its not present at the moment will the ONLY_FULL_GROUP_BY mode be added back to the sessions sql_modes

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@seamuslee001 @totten should the function name be changed to reenableFullGroupByModeIfConfigured or something to better match what it does?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would be fine with that

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's worth getting this right because I believe this approach should be our first line of defence against breakage in full group by mode & once we stop seeing new ones we should start to slowly & with many tests tackle the root cause of the queries. We have had too many resulting breakages up until now from full group by fixes for me to be comfortable with fixing the queries largely in isolation.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@seamuslee001 but don't you hate the way re-enable doesn't camel well?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, good call in pointing circa line 114. I didn't realize that it was based on the default (aka @@global.sql_mode). Agree it's not a functional problem and just a misinterpretation of the function's intent -- reenableFullGroupByModeIfConfigured() does seem more astute description.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants