Bug #12920 key_read_requests counter appears to re-set
Submitted: 31 Aug 2005 22:13 Modified: 15 Sep 2005 19:23
Reporter: Martyn Wendon Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:4.0.24-standard*log OS:Linux (Redhat Enterprise Server 3)
Assigned to: Ingo Strüwing CPU Architecture:Any

[31 Aug 2005 22:13] Martyn Wendon
Description:
I'm not sure if this a bug or expected behaviour, but my key_read_requests counter appears to have "rolled over" and started again from zero.

What makes me say that?

Well, this morning mytop was reporting it's usual 99.97% key efficiency, but this evening it's reporting -324%!!

Here's a snapshot of my key counters taken on 15th July (it's the only one I have to hand):

| Key_read_requests        | 34223463  |
| Key_reads                | 142930    |

Here they are now:

| Key_read_requests  | 11562673  |
| Key_reads          | 39597951  |

If this is a bug, it's annoying! It it's expected behaviour, it's still annoying!  We use key counters to monitor key efficiency (as should everyone!) but it's not showing us anything useful now!  The only way to work around the problem now is to restart mysql, but that would flush index caches and the query cache.

Thanks for listening,

Martyn

How to repeat:
I'm not sure how to repeat the problem, I guess you'd have to run a server like ours that's very busy, non-stop until the key_read_requests value rolls over.
[1 Sep 2005 5:12] John David Duncan
I cannot run a busy server to reproduce this, but I can verify that it is plausible. 

key_read_requests is _my_cache_r_requests, which is declared in mysys/mf_keycache.c (and as external in include/my_sys.h) as an unsigned long.  In the bug report, key_read_requests is greater than key_reads by a factor of about 239.  Given the second value of key_reads (39,597,951), key_read_requests should have rolled past the maximum value for a 32-bit ulong (4,294,967,296).   The data type is also ulong in 4.1 and 5.0.
[2 Sep 2005 9:46] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/internals/29231
[2 Sep 2005 9:56] Ingo Strüwing
John, thank you for the good analysis. Regards, Ingo
[14 Sep 2005 7:57] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/internals/29802
[14 Sep 2005 11:18] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/internals/29823
[15 Sep 2005 9:40] Ingo Strüwing
Pushed to 4.0.27, 4.1.15, and 5.0.13.
[15 Sep 2005 19:23] Paul DuBois
Noted in 4.0.27, 4.1.15, 5.0.13 changelogs.