diff options
author | Karthik Kamath <karthik.kamath@oracle.com> | 2016-10-13 14:48:45 +0530 |
---|---|---|
committer | Karthik Kamath <karthik.kamath@oracle.com> | 2016-10-13 14:48:45 +0530 |
commit | 149212772804e93983f80b63099ba9e1241ddf4f (patch) | |
tree | a976129fe922ef75d66ae6aa7d2bf216139fa452 /sql/sql_parse.cc | |
parent | bf8eab91ec1d718519f2fe5eb1c717f5e1eacc07 (diff) | |
download | mariadb-git-149212772804e93983f80b63099ba9e1241ddf4f.tar.gz |
BUG#23499695: MYSQL SERVER NORMAL SHUTDOWN WITH TIME STAMP
700101
ANALYSIS:
=========
To set the time 'start_time' of query in THD, current time
is obtained by calling 'gettimeofday()'. On Solaris
platform, due to some system level issues, time obtained is
invalid i.e. its either greater than 2038 (max signed value
to hold microseconds since 1970) or 1970 (0 microseconds
since 1970). In these cases, validation checks infer that
the 'start_time' is invalid and mysql server initiates the
shutdown process. But the reason for shutdown is not logged.
FIX:
====
We are now logging appropriate message when shutdown is
triggered in the above mentioned scenarios. Now, even if
the initial validation checks infer that the 'start_time'
is invalid, server shutdown is not initiated immediately.
Before initiating the server shutdown, the process of
setting 'start_time' and validating it is reiterated (for
max 5 times). If correct time is obtained in these 5
iterations then server continues to run.
Diffstat (limited to 'sql/sql_parse.cc')
-rw-r--r-- | sql/sql_parse.cc | 48 |
1 files changed, 39 insertions, 9 deletions
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index fd3623c6148..ac3901997f3 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -889,17 +889,47 @@ bool dispatch_command(enum enum_server_command command, THD *thd, thd->enable_slow_log= TRUE; thd->lex->sql_command= SQLCOM_END; /* to avoid confusing VIEW detectors */ thd->set_time(); - if (!thd->is_valid_time()) + if (thd->is_valid_time() == false) { /* - If the time has got past 2038 we need to shut this server down - We do this by making sure every command is a shutdown and we - have enough privileges to shut the server down - - TODO: remove this when we have full 64 bit my_time_t support + If the time has gone past 2038 we need to shutdown the server. But + there is possibility of getting invalid time value on some platforms. + For example, gettimeofday() might return incorrect value on solaris + platform. Hence validating the current time with 5 iterations before + initiating the normal server shutdown process because of time getting + past 2038. */ - thd->security_ctx->master_access|= SHUTDOWN_ACL; - command= COM_SHUTDOWN; + const int max_tries= 5; + sql_print_warning("Current time has got past year 2038. Validating current " + "time with %d iterations before initiating the normal " + "server shutdown process.", max_tries); + + int tries= 0; + while (++tries <= max_tries) + { + thd->set_time(); + if (thd->is_valid_time() == true) + { + sql_print_warning("Iteration %d: Obtained valid current time from " + "system", tries); + break; + } + sql_print_warning("Iteration %d: Current time obtained from system is " + "greater than 2038", tries); + } + if (tries > max_tries) + { + /* + If the time has got past 2038 we need to shut this server down. + We do this by making sure every command is a shutdown and we + have enough privileges to shut the server down + + TODO: remove this when we have full 64 bit my_time_t support + */ + sql_print_error("This MySQL server doesn't support dates later than 2038"); + thd->security_ctx->master_access|= SHUTDOWN_ACL; + command= COM_SHUTDOWN; + } } thd->set_query_id(next_query_id()); inc_thread_running(); |