• Davi Arnaut's avatar
    Bug#42054: SELECT CURDATE() is returning bad value · 644f0c1d
    Davi Arnaut authored
    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.
    
    The solution is to retrieve the correct time whenever a drift in
    the time returned by gethrtime() is detected. That is, do not
    use the cached time whenever the values (previous and current)
    returned by gethrtime() are not monotonically increasing.
    
    mysys/my_getsystime.c:
      Do not used the cached time if gethrtime is not monotonic.
    644f0c1d
my_getsystime.c 6.17 KB