Bug #58525 include/wait_for_status_var.inc compares numbers as strings in while loop
Submitted: 26 Nov 2010 17:58 Modified: 28 Jan 2011 15:46
Reporter: Bjørn Munch Email Updates:
Status: Closed Impact on me:
None 
Category:Tests: Server Severity:S3 (Non-critical)
Version:5.1, 5.6.1 OS:Any
Assigned to: Bernt Marius Johnsen CPU Architecture:Any

[26 Nov 2010 17:58] Bjørn Munch
Description:
Strange failure seen running rpl.rpl_heartbeat_basic:

---
**** ERROR: failed while waiting for slave_received_heartbeats 99 ****
Note: the following output may have changed since the failure was detected
**** Showing STATUS, PROCESSLIST ****
SHOW  STATUS LIKE 'slave_received_heartbeats';
Variable_name	Value
Slave_received_heartbeats	703
---

There should be a > before 99 in the error due to a mistyped var name (actually correctly spelled...)

But the following query shows the value compared as > 99 is 703.

How to repeat:
Seen in PB

Suggested fix:
The while loop which eventually terminates is:

while (`SELECT NOT('$_show_status_value' $_status_var_comparsion '$status_var_value')`)

This actally does '703' > '99', comparing as strings and this is false.

Fix is to remove the ' and thus compare as numbers.

Other tests may also have been affected.
[27 Nov 2010 13:33] Sveta Smirnova
Thank you for the feedback.

In which tree had you seen such failures? I only found valgrind failures for this bug in mysql-trunk, but because another reason. I also found no test rpl_heartbeat_basic in 5.1
[27 Nov 2010 13:55] Sveta Smirnova
Verified as described and discussed on IRC. Problem is not particular test which fails, but code in include file.

Test case:

create table t1(f1 int);
create table t2(f1 int);
create table t3(f1 int);
create table t4(f1 int);
create table t5(f1 int);
create table t6(f1 int);
create table t7(f1 int);
create table t8(f1 int);
create table t9(f1 int);
create table t10(f1 int);
create table t11(f1 int);
create table t12(f1 int);
drop table t1;
drop table t2;
drop table t3;
drop table t4;
drop table t5;
drop table t6;
drop table t7;
drop table t8;
drop table t9;
let $status_var_value= query_get_value(SHOW STATUS LIKE 'Com_drop_table', Value, 1);
let $status_var= Com_drop_table;
let $status_var_comparsion= >;
drop table t10;
drop table t11;
drop table t12;
--source include/wait_for_status_var.inc
--echo Com_select event received
--echo $status_var_value
SHOW STATUS LIKE 'Com_drop_table';
[27 Nov 2010 13:57] Sveta Smirnova
Result in my case:

**** ERROR: failed while waiting for  Com_drop_table  9 ****
Note: the following output may have changed since the failure was detected
**** Showing STATUS, PROCESSLIST ****
SHOW  STATUS LIKE 'Com_drop_table';
Variable_name   Value
Com_drop_table  12

But 12 > 9
[7 Dec 2010 21:12] 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/126268

3210 Serge Kozlov	2010-12-08
      Bug#54820: 
      master_connect_retty increased for Valgrind environment
      Bug#58525:
      separate string and numbers for comparing
[7 Dec 2010 21:46] Bjørn Munch
Gah, yes I see you have to do something of the sort to be able to support string values.

Alternatively, you could check $_show_status_value for "numberness" and if it's not a number, do

let $_show_status_value= '$_show_status_value';

Then you can use the unquoted variable in the test, simplifying that code. The one place I found where a string is actually used:

suite/rpl/t/rpl_semi_sync.test:let $status_var_value= OFF;

This would need to be changed to 'OFF'.
[29 Dec 2010 20:01] 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/127690

3449 Serge Kozlov	2010-12-29
      Bug#54820: master_connect_retry increased for Valgrind environment support
      Bug#58525: separate string and numbers for comparing
[13 Jan 2011 21: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/128691

3241 Serge Kozlov	2011-01-14
      Bug#54820: master_connect_retry increased for Valgrind environment support
      Bug#58525: separate string and numbers for comparing
[13 Jan 2011 21:52] Bugs System
Pushed into mysql-trunk 5.6.2 (revid:serge.kozlov@oracle.com-20110113213621-4qccnwyy72pxtnhh) (version source revid:serge.kozlov@oracle.com-20110113213621-4qccnwyy72pxtnhh) (merge vers: 5.6.2) (pib:24)
[13 Jan 2011 21:54] Bugs System
Pushed into mysql-5.5 5.5.9 (revid:serge.kozlov@oracle.com-20110113211817-xzrirqyu3adanfvv) (version source revid:serge.kozlov@oracle.com-20110113211817-xzrirqyu3adanfvv) (merge vers: 5.5.9) (pib:24)
[14 Jan 2011 10:13] Serge Kozlov
The bug fixed by patch for bug#54820.
[14 Jan 2011 17:27] Paul DuBois
Changes to test suite. No changelog entry needed.