Bug #28149 overflow in some "SHOW STATUS"-variables
Submitted: 28 Apr 2007 18:27 Modified: 18 Jun 2007 16:55
Reporter: Patrick Lehmann Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Logging Severity:S3 (Non-critical)
Version:5.0.42-BK, 5.0.30-Debian_1-log OS:Linux (Debian 3.1)
Assigned to: Sergei Glukhov CPU Architecture:Any
Tags: overflow, show status

[28 Apr 2007 18:27] Patrick Lehmann
Description:
Hi,

I have written a statistic-script for mysql.
It uses "SHOW GLOBAL STATUS" to collect some informations about the server usage.
The interval is set to 600 seconds. Here the everage data:
Connections: 1,064
Questions: 13,534
Bytes transfered: 17,310,227 (in and out)
The Server is running for 8 Days, 10 Hours, 46 Minutes

So this shoud be 1,216.6 intervals =>
Connections: 1,294,462
Questions: 16,465,464
Bytes: 19.6 GiB (in and out)

SHOW STATUS has the following information:
Connections: 1,062,180
Questions: 26,692,543
Bytes: 4,9 GiB (in and out)

I have never seen a value für bytes transfered about 4 GiB.

I think the variables for "Bytes_received" and "Bytes_sent" are defined as Integer(32 bit) and so there's an overflow at 4 GiB limit.

How to repeat:
In my opion it could be fixed by defining "Bytes_received" and "Bytes_sent" as BigInteger(64 bit)
[29 Apr 2007 11:38] Valeriy Kravchuk
Thank you for a bug report. In sql/sql_class.h these variables are declared as follows:

typedef struct system_status_var
{
  ulong bytes_received;
  ulong bytes_sent;
...

That is, they are unsigned long. On my platform unsigned long is 4 bytes long:

openxs@suse:~/work/mysql-5.0> cat ul.c
#include <stdio.h>
#include <stdlib.h>

main() {
  printf("\nSize of ulong is: %d\n", sizeof (unsigned long));
  return 0;
}
openxs@suse:~/work/mysql-5.0> gcc -o ul ul.c
openxs@suse:~/work/mysql-5.0> ./ul

Size of ulong is: 4
openxs@suse:~/work/mysql-5.0> uname -a
Linux suse 2.6.11.4-20a-default #1 Wed Mar 23 21:52:37 UTC 2005 i686 i686 i386 GNU/Linux

So, this really looks like a problem to be fixed (on 32-bit platforms, at least)
[4 Jun 2007 12:49] 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/commits/28055

ChangeSet@1.2471, 2007-06-04 17:47:33+05:00, gluh@mysql.com +4 -0
  Bug#28149 overflow in some "SHOW STATUS"-variables
  changed bytes_received, bytes_sent status variables to ulonglong
[9 Jun 2007 12:50] 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/commits/28458

ChangeSet@1.2526, 2007-06-09 17:46:09+05:00, gluh@mysql.com +4 -0
  Bug#28149 overflow in some "SHOW STATUS"-variables
  changed bytes_received, bytes_sent status variables to longlong
[14 Jun 2007 19:00] Bugs System
Pushed into 5.0.44
[14 Jun 2007 19:00] Bugs System
Pushed into 5.1.20-beta
[18 Jun 2007 16:55] Paul DuBois
Noted in 5.0.44, 5.1.20 changelogs.

The Bytes_received and Bytes_sent status variables could hold only
32-bit values (not 64-bit values) on some platforms.
[21 Feb 2009 9:11] Sveta Smirnova
Bug seems to be not fixed properly: see bug #43040 for details.