Bug #34517 SHOW GLOBAL STATUS does not work properly in embedded server.
Submitted: 13 Feb 2008 9:50 Modified: 1 Feb 2009 0:07
Reporter: Alexander Nozdrin Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Embedded Library ( libmysqld ) Severity:S3 (Non-critical)
Version:5.1 OS:Any
Assigned to: Alexey Botchkov CPU Architecture:Any
Triage: D3 (Medium)

[13 Feb 2008 9:50] Alexander Nozdrin
Description:
SHOW GLOBAL STATUS does not take into account session-scope values
when run in embedded server.

How to repeat:
1. Create the following test file:

mysql-test/t/qqq.test
------------------
SHOW GLOBAL STATUS LIKE 'com_select';
SHOW STATUS LIKE 'com_select';

SELECT 1;

SHOW GLOBAL STATUS LIKE 'com_select';
SHOW STATUS LIKE 'com_select';
------------------

2. Run under the test suite, create result file:
> ./mtr --record qqq

3. mysql-test/r/qqq.result should be like:
-------------------
SHOW GLOBAL STATUS LIKE 'com_select';
Variable_name   Value
Com_select      0

SHOW STATUS LIKE 'com_select';
Variable_name   Value
Com_select      0

SELECT 1;
1
1

SHOW GLOBAL STATUS LIKE 'com_select';
Variable_name   Value
Com_select      1

SHOW STATUS LIKE 'com_select';
Variable_name   Value
Com_select      1
-------------------

Note, that SHOW GLOBAL STATUS and SHOW STATUS return the same results.

4. Execute qqq.test under the test suite in embedded mode:
> ./mtr --embedded qqq

There will be the following diff:
-------------------
 SHOW GLOBAL STATUS LIKE 'com_select';
 Variable_name  Value
-Com_select     1
+Com_select     0
 SHOW STATUS LIKE 'com_select';
 Variable_name  Value
 Com_select     1
-------------------

The problem is that SHOW GLOBAL STATUS returns 0 (that's a bug),
while SHOW STATUS returns 1 (that's correct).

Suggested fix:
SHOW GLOBAL STATUS "is implemented" in sql_show.cc:calc_sum_of_all_status()
function.

The idea of that function is that it takes global values and then iterates
through all thread/sessions and add their values. Threads/sessions are
registered in the global variable 'threads', defined in mysqld.cc
(I_List<THD> threads;). The problem seems that threads is empty in embedded
mode, i.e. 'dummy embedded thread' is not registered in this list.
[13 Feb 2008 12:12] Susanne Ebrecht
Verified as described.
[24 Mar 2008 13:52] 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/44361

ChangeSet@1.2601, 2008-03-24 17:41:59+04:00, holyfoot@mysql.com +1 -0
  Bug#34517 SHOW GLOBAL STATUS does not work properly in embedded server.
  
  GLOBAL STATUS is calculated by studying the list of threads. In the
  embedded server threads were not linked to the internal list, so the
  calculation always returns 0. Fixed by 'linking' the embedded-server
  threads to the same list.
[24 Mar 2008 13:53] 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/44362

ChangeSet@1.2570, 2008-03-24 17:43:20+04:00, holyfoot@mysql.com +2 -0
  Bug #34517 SHOW GLOBAL STATUS does not work properly in embedded server.
  
  test case added
[5 Sep 2008 8:30] 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/53301

2728 Alexey Botchkov	2008-09-05
      Bug#34517 SHOW GLOBAL STATUS does not work properly in embedded server.
        
        GLOBAL STATUS is calculated by studying the list of threads. In the
        embedded server threads were not linked to the internal list, so the
        calculation always returns 0. Fixed by 'linking' the embedded-server
        threads to the same list
      
      per-file comments
      
      libmysqld/lib_sql.cc
          Bug#34517 SHOW GLOBAL STATUS does not work properly in embedded server.
          
          Add newly created 'threads' to the internal thread list.
          Remove them from the list as they're freed.
      
      mysql-test/r/information_schema.result
              test result
      
      mysql-test/t/information_schema.test
              test case
[17 Nov 2008 17:20] 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/58976

2711 Alexey Botchkov	2008-11-17
      Bug#34517 SHOW GLOBAL STATUS does not work properly in embedded server.
      
            GLOBAL STATUS is calculated by studying the list of threads. In the
              embedded server threads were not linked to the internal list, so the
              calculation always returns 0. Fixed by 'linking' the embedded-server
              threads to the same list
      
      per-file comments:
        libmysqld/lib_sql.cc
      Bug#34517 SHOW GLOBAL STATUS does not work properly in embedded server.
          Add newly created 'threads' to the internal thread list.
          Remove them from the list as they're freed.
      
        mysql-test/r/information_schema.result
      Bug#34517 SHOW GLOBAL STATUS does not work properly in embedded server.
          test result
      
        mysql-test/t/information_schema.test
      Bug#34517 SHOW GLOBAL STATUS does not work properly in embedded server.
          test case added
[8 Dec 2008 10:19] Bugs System
Pushed into 5.1.31  (revid:holyfoot@mysql.com-20081117160603-637w82fvmw0sulox) (version source revid:patrick.crews@sun.com-20081126180318-v685u61mpgoc176x) (pib:5)
[8 Dec 2008 11:30] Bugs System
Pushed into 6.0.9-alpha  (revid:holyfoot@mysql.com-20081117160603-637w82fvmw0sulox) (version source revid:ingo.struewing@sun.com-20081121151447-dtf2ofz2ys0zqed1) (pib:5)
[8 Dec 2008 23:31] Paul Dubois
Noted in 5.1.31, 6.0.9 changelog.

SHOW GLOBAL STATUS shows values that aggregate the session status
values for all threads. This did not work correctly for the embedded
server.
[19 Jan 2009 11:26] Bugs System
Pushed into 5.1.31-ndb-6.2.17 (revid:tomas.ulin@sun.com-20090119095303-uwwvxiibtr38djii) (version source revid:tomas.ulin@sun.com-20090108105244-8opp3i85jw0uj5ib) (merge vers: 5.1.31-ndb-6.2.17) (pib:6)
[19 Jan 2009 13:04] Bugs System
Pushed into 5.1.31-ndb-6.3.21 (revid:tomas.ulin@sun.com-20090119104956-guxz190n2kh31fxl) (version source revid:tomas.ulin@sun.com-20090119104956-guxz190n2kh31fxl) (merge vers: 5.1.31-ndb-6.3.21) (pib:6)
[19 Jan 2009 16:10] Bugs System
Pushed into 5.1.31-ndb-6.4.1 (revid:tomas.ulin@sun.com-20090119144033-4aylstx5czzz88i5) (version source revid:tomas.ulin@sun.com-20090119144033-4aylstx5czzz88i5) (merge vers: 5.1.31-ndb-6.4.1) (pib:6)
[28 Jan 2009 11:10] Lars Thalmann
There are still comments in 5.1 main test cases about things that
should be fixed as this bug gets fixed.

Re-opening this bug, so that the test cases get fixed.
[1 Feb 2009 0:05] 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/64762

2769 Davi Arnaut	2009-01-31
      Remove duplicated test for Bug#34517
[1 Feb 2009 0:07] Davi Arnaut
Closed as above patch hopefully fixes the issue.
[3 Feb 2009 9:39] Bugs System
Pushed into 5.1.32 (revid:joro@sun.com-20090203090549-gos3v4320vimrzg6) (version source revid:azundris@mysql.com-20090202131035-zuf2kdg8u8r177fi) (merge vers: 5.1.32) (pib:6)
[4 Feb 2009 11:14] Bugs System
Pushed into 6.0.10-alpha (revid:kostja@sun.com-20090204104420-mw1i2u9lum4bxjo6) (version source revid:joro@sun.com-20090201143058-0ddvdak8hydjz3od) (merge vers: 6.0.10-alpha) (pib:6)
[17 Feb 2009 14:58] Bugs System
Pushed into 5.1.32-ndb-6.3.23 (revid:tomas.ulin@sun.com-20090217131017-6u8qz1edkjfiobef) (version source revid:tomas.ulin@sun.com-20090203133556-9rclp06ol19bmzs4) (merge vers: 5.1.32-ndb-6.3.22) (pib:6)
[17 Feb 2009 16:45] Bugs System
Pushed into 5.1.32-ndb-6.4.3 (revid:tomas.ulin@sun.com-20090217134419-5ha6xg4dpedrbmau) (version source revid:tomas.ulin@sun.com-20090203133556-9rclp06ol19bmzs4) (merge vers: 5.1.32-ndb-6.3.22) (pib:6)
[17 Feb 2009 18:22] Bugs System
Pushed into 5.1.32-ndb-6.2.17 (revid:tomas.ulin@sun.com-20090217134216-5699eq74ws4oxa0j) (version source revid:tomas.ulin@sun.com-20090202111723-1zzwax187rtls913) (merge vers: 5.1.32-ndb-6.2.17) (pib:6)