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

System Status - Add check to ensure that MySQL timezones are operational #25367

Merged
merged 2 commits into from
Feb 2, 2023

Conversation

totten
Copy link
Member

@totten totten commented Jan 17, 2023

Overview

Add a status check to ensure that MySQL can consistently handle TIMESTAMP data in a timezone-sensitive fashion.

The main issue is that timezone data has to be loaded into MySQL. Many platforms/environments do this automatically, but some don't.

Before

No status check. You may have random trouble because MySQL cannot accurately set the timezone.

After

If MySQL lacks timezone support, then Civi will display a warning:

Screen Shot 2023-01-16 at 10 52 03 PM

Comments

I was ambivalent about whether to target 5.58 or master. The branch is based on a shared commit, so it should be easy to switch if appropriate.

@civibot
Copy link

civibot bot commented Jan 17, 2023

(Standard links)

@civibot civibot bot added the 5.58 label Jan 17, 2023
@seamuslee001
Copy link
Contributor

so @totten how does this improve on https://github.com/civicrm/civicrm-core/blob/master/CRM/Utils/Check/Component/Env.php#L120 or is that much different to that

@totten
Copy link
Member Author

totten commented Jan 17, 2023

I think they're different:

  • checkTimezoneAPIs() tells you that MySQL has enough information to perform TZ conversions and use symbolic timezones (e.g. America/New_York).
  • checkMysqlTime() tells you that PHP and MySQL currently display "now" with matched (or mismatched) values. This does implicitly suggest that they are presenting "now" with the same offset (since, afaik, the base UF integration still uses offset to configure mysql).

They can signal different things, such as

  • UF integration bug would not affect checkTimezoneAPIs() but would affect checkMysqlTime() (eg because it neglects to set one or the other)
  • Missing TZ data would affect checkTimezoneAPIs() but would not affect checkMysqlTime() (eg if both set current TZ by offset)
  • Highly skewed clocks (eg db server has ntpd but webserver doesn't) would affect checkMysqlTime() but not checkTimezoneAPIs()

@demeritcowboy
Copy link
Contributor

Ok the permissions are good. It does though make an initially confusing fatal error entry in your logs for people who don't have timezones installed, but I think that's ok - it's not going to be on every page run, and there's similar spurious log entries for a couple other things in civi.

[error] $Fatal Error Details = Array
(
    [callback] => Array
        (
            [0] => CRM_Core_Error
            [1] => exceptionHandler
        )

    [code] => -1
    [message] => DB Error: unknown error
    [mode] => 16
    [debug_info] => SET @@time_zone = "Europe/Berlin" [nativecode=1298 ** Unknown or incorrect time zone: 'Europe/Berlin']
    [type] => DB_Error
    [user_info] => SET @@time_zone = "Europe/Berlin" [nativecode=1298 ** Unknown or incorrect time zone: 'Europe/Berlin']
    [to_string] => [db_error: message="DB Error: unknown error" code=-1 mode=callback callback=CRM_Core_Error::exceptionHandler prefix="" info="SET @@time_zone = "Europe/Berlin" [nativecode=1298 ** Unknown or incorrect time zone: 'Europe/Berlin']"]
)

One suggestion: Both the converted checks are either on the same side or the other side of DST from where you are "now". Possibly one of them should be in e.g. August, just so it's checking both sides of DST. But that's just extra since the check is really about whether you have zones loaded.

The status check level is warning, but I suppose at some point people on shared hosting without timezones are going to ask what they are expected to do. It's not written in stone yet, and this might give a better idea of who's affected. The survey earlier suggested it might not be too bad.

@demeritcowboy demeritcowboy added the merge ready PR will be merged after a few days if there are no objections label Jan 27, 2023
@totten totten merged commit d9920c5 into civicrm:5.58 Feb 2, 2023
@totten totten deleted the 5.58-check-tz branch February 2, 2023 00:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
5.58 merge ready PR will be merged after a few days if there are no objections
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants