Bug #41327 FLUSH STATUS docs are inappropriate
Submitted: 9 Dec 2008 12:44 Modified: 9 Dec 2008 18:50
Reporter: Peter Laursen (Basic Quality Contributor) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Documentation Severity:S2 (Serious)
Version:5.0.67 - probably any 5+ OS:Any
Assigned to: CPU Architecture:Any
Tags: qc

[9 Dec 2008 12:44] Peter Laursen
Description:
It seems that we have been fooled by the change of FLUSH STATUS behavior between 4.x an 5.x.  I also think the MySQL documentation team has failed to update docs from first 5.0 release!

Docs 
http://dev.mysql.com/doc/refman/5.0/en/flush.html
tell

"This option adds the current thread's session status variable values to the global values and resets the session values to zero. It also resets the counters for key caches (default and named) to zero and sets Max_used_conections to the current number of open connections"

This I must understand like 'max_used_conections' behave a special way of behaviour (what I also can find by testing it), but there seems to be more 'specials'.  For instance 'threads_connected'.

How to repeat:
have a server isntance only used for this.  

1) restart server

2) connect from one client (we are using command line client)

3a) show session status like 'threads_connected' -- returns '2'
3b) show global status like 'threads_connected' -- returns '2'

4 connect from another client instance

5 again (from first client)
5a) show session status like 'threads_connected' -- returns '4'
5b) show global status like 'threads_connected' -- returns '4'

6 FLUSH STATUS from both clients 

7) again 
7a) show session status like 'threads_connected' -- returns '4'
7b) show global status like 'threads_connected' -- returns '4'

8) EXIT from 2nd client instance

9)again 
9a) show session status like 'threads_connected' -- returns '3'
9b) show global status like 'threads_connected' -- returns '3'

... hhmmm ... 3!  How comes "3" suddenly?

Suggested fix:
I cannot see how anybody should be able to foresee this from the (very short) documentation I quoted just above!

Provide proper documentation! Simple describe for *each and every* status variable how FLUSH STATUS (from both *this* and *that* session) affects the display for SESSION and GLOBAL option and why closing other connections  affects status variables from *this* connection!

I mark it S2 (serious)!!
[9 Dec 2008 15:31] Sveta Smirnova
Thank you for the report.

You quote documentation about 'Max_used_connections', but check 'threads_connedted'. According to http://dev.mysql.com/doc/refman/5.0/en/server-status-variables.html#statvar_Threads_connec... threads_connected shows the number of currently open connections.

Only bug I see in the documentation is misprint: Max_used_coNections instead of Max_used_coNNections. This should be fixed.
[9 Dec 2008 15:46] Peter Laursen
but how could it be 2 open conenctions and next 3 open connections after connecting and disconnecting from another client then?  Does the 'mysql' client create two connections and only close one?
[9 Dec 2008 16:07] Sveta Smirnova
I am sorry: I can not repeat this: always either 1 or 2 threads_connected for 2 clients. Also is interesting why you get 2 threads_connected after you connect with single client.
[9 Dec 2008 17:10] Paul DuBois
I fixed the typo: Max_user_conections -> Max_user_connections
[9 Dec 2008 17:35] Peter Laursen
The typo I even did not notice!

But I do not understand how 'threads_connected' can end up as "3" following the procedure described! probably SHOW FULL PROCESSLIST would tell if there is a thread left behind from second connection created.  

I will try that later then!  Some other obligations are there for a couple of hours!
[9 Dec 2008 18:50] Peter Laursen
Problem was a monitoring program connecting to the server! Thanks for fixing the typo!