Bug #71683 useless decimal digits in "has waited at ... for xxx.yy seconds" messages
| Submitted: | 12 Feb 2014 12:20 | Modified: | 12 Feb 2014 12:21 |
|---|---|---|---|
| Reporter: | Hartmut Holzgraefe | Email Updates: | |
| Status: | Open | Impact on me: | |
| Category: | MySQL Server: InnoDB storage engine | Severity: | S4 (Feature request) |
| Version: | 5.6.15 | OS: | Any |
| Assigned to: | CPU Architecture: | Any |
[12 Feb 2014 12:21]
Hartmut Holzgraefe
PS: shouldn't this code use ut_time() and ut_timediff() from ut0ut.h ?
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.048 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the
respective copyright holders.
It is not reviewed in advance
by Oracle and does not necessarily represent the opinion of
Oracle or any other party.
Description: The code generating this message is: fprintf(file, "--Thread %lu has waited at %s line %lu" " for %.2f seconds the semaphore:\n", (ulong) os_thread_pf(cell->thread), innobase_basename(cell->file), (ulong) cell->line, difftime(time(NULL), cell->reservation_time)); So the result of difftime() is printed using %.2f as format. difftime() never returns fractional if implemented according to the standard though: "... The difftime() function shall return the difference expressed in seconds as a type double. ..." (see eg. http://pubs.opengroup.org/onlinepubs/009695399/functions/difftime.html ) (the fact that it returns double instead of time_t is probably that time_t may be unsigned ...?) So those extra two decimals give a false sense of precision that isn't actually there, and just printing the number of seconds without decimals would be sufficient How to repeat: see above Suggested fix: change %.2f format specifier to %.0f, or use %d and cast to (int) ...?