diff options
author | Davi Arnaut <davi.arnaut@oracle.com> | 2011-01-12 18:36:39 -0200 |
---|---|---|
committer | Davi Arnaut <davi.arnaut@oracle.com> | 2011-01-12 18:36:39 -0200 |
commit | eb58939395bace2897a0dcc2139159db72a874fb (patch) | |
tree | f964ad6a049321f94c6d1b713b6deb0244aabbb3 /mysys/my_thr_init.c | |
parent | f8697642d20415ea2e6e85c4090d7ef0dff40241 (diff) | |
download | mariadb-git-eb58939395bace2897a0dcc2139159db72a874fb.tar.gz |
Bug#42054: SELECT CURDATE() is returning bad value
The problem from a user point of view was that on Solaris the
time related functions (e.g. NOW(), SYSDATE(), etc) would always
return a fixed time.
This bug was happening due to a logic in the time retrieving
wrapper function which would only call the time() function every
half second. This interval between calls would be calculated
using the gethrtime() and the logic relied on the fact that time
returned by it is monotonic.
Unfortunately, due to bugs in the gethrtime() implementation,
there are some cases where the time returned by it can drift
(See Solaris bug id 6600939), potentially causing the interval
calculation logic to fail.
Since newer versions of Solaris (10+) have alleviated the
performance degradation associated with time(2), the solution is
to simply directly rely on time() at each invocation.
This simplification has an upside that it allows us to eliminate
a lock which was used to control access to the variables used
to track the half second interval, thus improving the overall
scalability of timekeeping related functions (e.g. NOW()).
Benchmarks runs have shown no significant degradation associated
with this change. With this, there are actually improvements in
performance for cases involving many connections.
In summary, the changes introduced by this patch are:
a) my_time() and my_micro_time_and_time() no longer use gethrtime().
Instead, time() and gettimeofdate() are used correspondingly.
b) my_micro_time() is changed to not use gethrtime() so as to
have the same time source as my_micro_time_and_time().
There shouldn't be any performance impact from this change
since this function is used only a few times during statement
execution and, on Solaris, gettimeofday() shows acceptable
performance.
mysys/my_getsystime.c:
Use time() even if gethrtime() is available. Remove logic which
relied on gethrtime() to only call time() every half second.
Since gethrtime() is not used anymore, also remove it from
my_micro_time() to keep a common time source.
Also, function comments are cleaned up (fixed typos and wrong
information) and converted to doxygen.
mysys/my_thr_init.c:
Remove mutex which is no longer used.
mysys/mysys_priv.h:
Remove mutex which is no longer used.
Diffstat (limited to 'mysys/my_thr_init.c')
-rw-r--r-- | mysys/my_thr_init.c | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/mysys/my_thr_init.c b/mysys/my_thr_init.c index c4b56cde850..a672d8af818 100644 --- a/mysys/my_thr_init.c +++ b/mysys/my_thr_init.c @@ -25,7 +25,7 @@ pthread_key(struct st_my_thread_var*, THR_KEY_mysys); mysql_mutex_t THR_LOCK_malloc, THR_LOCK_open, THR_LOCK_lock, THR_LOCK_isam, THR_LOCK_myisam, THR_LOCK_heap, - THR_LOCK_net, THR_LOCK_charset, THR_LOCK_threads, THR_LOCK_time, + THR_LOCK_net, THR_LOCK_charset, THR_LOCK_threads, THR_LOCK_myisam_mmap; mysql_cond_t THR_COND_threads; @@ -219,7 +219,6 @@ my_bool my_thread_global_init(void) mysql_mutex_init(key_THR_LOCK_myisam_mmap, &THR_LOCK_myisam_mmap, MY_MUTEX_INIT_FAST); mysql_mutex_init(key_THR_LOCK_heap, &THR_LOCK_heap, MY_MUTEX_INIT_FAST); mysql_mutex_init(key_THR_LOCK_net, &THR_LOCK_net, MY_MUTEX_INIT_FAST); - mysql_mutex_init(key_THR_LOCK_time, &THR_LOCK_time, MY_MUTEX_INIT_FAST); mysql_cond_init(key_THR_COND_threads, &THR_COND_threads, NULL); #if !defined(HAVE_LOCALTIME_R) || !defined(HAVE_GMTIME_R) @@ -288,7 +287,6 @@ void my_thread_global_end(void) mysql_mutex_destroy(&THR_LOCK_myisam_mmap); mysql_mutex_destroy(&THR_LOCK_heap); mysql_mutex_destroy(&THR_LOCK_net); - mysql_mutex_destroy(&THR_LOCK_time); mysql_mutex_destroy(&THR_LOCK_charset); if (all_threads_killed) { |