CLIENT_STATISTICS are broken if hostname is > 16 chars
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
OurDelta |
Fix Released
|
Medium
|
Unassigned | ||
Percona patches |
Fix Released
|
Medium
|
Unassigned |
Bug Description
I noticed today that the CLIENT_STATISTICS tables were not working properly if the hostnames are longer
than 16 characters. I am running these packages from the ourdelta repository (centos5.2):
MySQL-OurDelta-
MySQL-OurDelta-
MySQL-OurDelta-
mysql> select count(*) from client_statistics;
+----------+
| count(*) |
+----------+
| 1485697 |
+----------+
1 row in set (1.62 sec)
mysql> select client from client_statistics limit 20;
+------
| client |
+------
| gonzo17i.bunchba |
| |
| gonzo23i.bunchba |
| gonzo20i.bunchba |
| gonzo20i.bunchba |
| gonzo23i.bunchba |
| gonzo20i.bunchba |
| gonzo20i.bunchba |
| gonzo17i.bunchba |
| gonzo17i.bunchba |
| gonzo20i.bunchba |
| gonzo23i.bunchba |
| gonzo20i.bunchba |
| gonzo17i.bunchba |
| gonzo23i.bunchba |
| gonzo20i.bunchba |
| gonzo17i.bunchba |
| gonzo20i.bunchba |
| gonzo15i.bunchba |
| gonzo17i.bunchba |
+------
20 rows in set (1.36 sec)
As you can see, there are lots of duplicate rows. The heart of the problem seems to be this
code from the google patch:
ourdelta-
Client name lengths are set to LIST_PROCESS_
This means that there will be rows in client stats table that will be distinct, but indistinguishable in the show client_statistics output. The CLIENT column should probably have the same length (its set in this line:
+ {"CLIENT", 16, MYSQL_TYPE_STRING, 0, 0, "Client"},
But the underlying problem seems to be in a different place.
There is a routine to initialize the statistics:
+void init_global_
+{
+ if (hash_init(
+ 0, 0, (hash_get_
+ (hash_free_
+ sql_print_
+ exit(1);
+ }
+}
The get_key_user_stats is shared between the global_user_stats and global_client_stats hash tables.
Here is the definition of that function:
+byte *get_key_
+ my_bool not_used __attribute_
+{
+ *length = strlen(
+ return (byte*)
+}
The "user_name" field is being shared between user and client statistics. This field is limited to 16 characters. But when a hash match is being looked for, we are comparing against a 64 char host name, and we are always inserting a new row.
Related branches
- OurDelta-core: Pending requested
- Diff: None lines
Changed in ourdelta: | |
importance: | Undecided → Medium |
status: | New → Confirmed |
status: | Confirmed → Fix Committed |
Changed in percona-patches: | |
importance: | Undecided → Medium |
status: | New → Fix Committed |
Changed in percona-patches: | |
status: | Fix Committed → Fix Released |
Changed in ourdelta: | |
status: | Fix Committed → Fix Released |
On Wed, Mar 4, 2009 at 3:35 PM, Neil Katin <email address hidden> wrote:
> Public bug reported: client. x86_64 5.0.67.d7-44.el5_2 installed server. x86_64 5.0.67.d7-44.el5_2 installed shared. x86_64 5.0.67.d7-44.el5_2 installed ------- -----+ ------- -----+ ------- -----+ mybranch/ mysql/5. 0/google/ userstatsv2/ userstatsv2- main.patch. HOST_LEN (64), but the CLIENT client_ stats(void) &global_ client_ stats, system_ charset_ info, key)get_ key_user_ stats, key)free_ user_stats, 0)) { error(" Initializing global_client_stats failed."); user_stats( USER_STATS *user_stats, uint *length, _((unused) )) user_stats- >user); user_stats- >user; /bugs.launchpad .net/bugs/ 338012
>
>
> I noticed today that the CLIENT_STATISTICS tables were not working properly
> if the hostnames are longer
> than 16 characters. I am running these packages from the ourdelta
> repository (centos5.2):
>
> MySQL-OurDelta-
> MySQL-OurDelta-
> MySQL-OurDelta-
>
> mysql> select count(*) from client_statistics;
> +----------+
> | count(*) |
> +----------+
> | 1485697 |
> +----------+
> 1 row in set (1.62 sec)
>
> mysql> select client from client_statistics limit 20;
> +------
> | client |
> +------
> | gonzo17i.bunchba |
> | |
> | gonzo23i.bunchba |
> | gonzo20i.bunchba |
> | gonzo20i.bunchba |
> | gonzo23i.bunchba |
> | gonzo20i.bunchba |
> | gonzo20i.bunchba |
> | gonzo17i.bunchba |
> | gonzo17i.bunchba |
> | gonzo20i.bunchba |
> | gonzo23i.bunchba |
> | gonzo20i.bunchba |
> | gonzo17i.bunchba |
> | gonzo23i.bunchba |
> | gonzo20i.bunchba |
> | gonzo17i.bunchba |
> | gonzo20i.bunchba |
> | gonzo15i.bunchba |
> | gonzo17i.bunchba |
> +------
> 20 rows in set (1.36 sec)
>
>
> As you can see, there are lots of duplicate rows. The heart of the problem
> seems to be this
> code from the google patch:
>
> ourdelta-
>
> Client name lengths are set to LIST_PROCESS_
> column is set to 16 characters.
> This means that there will be rows in client stats table that will be
> distinct, but indistinguishable in the show client_statistics output. The
> CLIENT column should probably have the same length (its set in this line:
>
> + {"CLIENT", 16, MYSQL_TYPE_STRING, 0, 0, "Client"},
>
> But the underlying problem seems to be in a different place.
>
> There is a routine to initialize the statistics:
>
> +void init_global_
> +{
> + if (hash_init(
> max_connections,
> + 0, 0, (hash_get_
> + (hash_free_
> + sql_print_
> + exit(1);
> + }
> +}
>
> The get_key_user_stats is shared between the global_user_stats and
> global_client_stats hash tables.
> Here is the definition of that function:
>
> +byte *get_key_
> + my_bool not_used __attribute_
> +{
> + *length = strlen(
> + return (byte*)
> +}
>
> The "user_name" field is being shared between user and client
> statistics. This field is limited to 16 characters. But when a hash
> match is being looked for, we are comparing against a 64 char host name,
> and we are always inserting a new row.
>
> ** Affects: ourdelta
> Importance: Undecided
> Status: New
>
> --
> CLIENT_STATISTICS are broken if hostname is > 16 chars
> https:/
> You re...