I have our server configured so that MySQL actually returns UTC time, and this is intentional.
However the server itself has its local time configured as PDT.
It seems like an update recently happened where ChkServd is now checking that the server time and MySQL time both use the same time zone, or it thinks there are issues.
I believe this is causing the MySQL server to keep rebooting every time it checks, which seems to be about once every ten minutes.
I would rather keep MySQL set to UTC time which I do in my.cnf:
If I look in /usr/local/cpanel/Cpanel/ServiceManager/Services/Mysql.pm:
You can see how it throws the exception there.
Thoughts? I may have to disable the chkservd monitor on MySQL because of the forced reboots when there are really no issues from what I can tell other than the time zone discrepancy.
If I comment out this code:
Then I get this when running the check:
However the server itself has its local time configured as PDT.
It seems like an update recently happened where ChkServd is now checking that the server time and MySQL time both use the same time zone, or it thinks there are issues.
Code:
# /scripts/restartsrv_mysql --check
(XID 3szs86) The server time and the MySQL® time are different. at /usr/local/cpanel/Cpanel/ServiceManager/Services/Mysql.pm line 156.
I would rather keep MySQL set to UTC time which I do in my.cnf:
Code:
default-time-zone = '+00:00'
Code:
if ( $hasmysql && $dbpassword ) {
no warnings 'once';
local $SIG{"ALRM"} = sub {
die Cpanel::Exception::create( 'ConnectionFailed', \%exception_parameters )->to_string(); ## no extract maketext (variable is metadata; the default message will be used)
};
alarm(30);
my $dbh = eval { Cpanel::MysqlUtils::Connect::get_dbi_handle( 'extra_args' => { 'PrintError' => 0, 'RaiseError' => 0 } ) };
if ( !$dbh ) {
die Cpanel::Exception::create( 'Services::CheckFailed', [ service => $self->{'service'}, message => $DBI::errstr ] );
}
alarm(0);
die Cpanel::Exception::create( 'ConnectionFailed', \%exception_parameters )->to_string() unless $dbh; ## no extract maketext (variable is metadata; the default message will be used)
## check difference between system time and mysql server time
my @lt = localtime( time() );
my $time_str = sprintf( "%04d-%02d-%02d %02d:%02d:%02d", $lt[5] + 1900, $lt[4] + 1, @lt[ 3, 2, 1, 0 ] );
my $sql = qq(SELECT HOUR(TIMEDIFF('$time_str', NOW())) as hour_diff);
my $hour_diff_detected = eval {
alarm(30);
my $sth = $dbh->prepare($sql);
my $rv = $sth->execute();
my $href = $sth->fetchrow_hashref();
alarm(0);
$sth->finish();
$dbh->disconnect();
$mysqlok = 1;
$href->{hour_diff} > 0 ? 1 : 0;
};
alarm(0);
if ($hour_diff_detected) {
die Cpanel::Exception::create( 'Database::ServerTime', \%exception_parameters )->to_string();
}
}
Thoughts? I may have to disable the chkservd monitor on MySQL because of the forced reboots when there are really no issues from what I can tell other than the time zone discrepancy.
If I comment out this code:
Code:
# if ($hour_diff_detected) {
# die Cpanel::Exception::create( 'Database::ServerTime', \%exception_parameters )->to_string();
# }
Code:
# /scripts/restartsrv_mysql --check
The 'mysql' service passed the check: mysql (/usr/sbin/mysqld) is running as mysql with PID 21990 (systemd+/proc check method).
Last edited: