Bug #83024 Internals manual does not explain COM_SLEEP in details
Submitted: 16 Sep 2016 17:15 Modified: 11 Jul 2017 11:09
Reporter: Valeriy Kravchuk Email Updates:
Status: Won't fix Impact on me:
None 
Category:MySQL Server: Documentation Severity:S3 (Non-critical)
Version: OS:Any
Assigned to: CPU Architecture:Any
Tags: COM_SLEEP, missing manual, slow log

[16 Sep 2016 17:15] Valeriy Kravchuk
Description:
Take a look at https://dev.mysql.com/doc/internals/en/com-sleep.html. This page is useless, it does not explain when server uses this command.

In reality it is used in different places:

openxs@ao756:~/git/mysql-server$ grep -rn COM_SLEEP *
include/mysql/plugin_audit.h.pp:130:  COM_SLEEP,
include/mysql.h.pp:35:  COM_SLEEP,
include/my_command.h:30:  COM_SLEEP,
libmysqld/lib_sql.cc:752:  thd->set_command(COM_SLEEP);
sql/sql_connect.cc:825:  thd->set_command(COM_SLEEP);
sql/protocol_classic.cc:1391:    /* Initialize with COM_SLEEP packet */
sql/protocol_classic.cc:1392:    raw_packet[0]= (uchar) COM_SLEEP;
sql/sql_show.cc:2085:    else if (tmp->get_command() == COM_SLEEP)
sql/sql_parse.cc:261:  server_command_flags[COM_SLEEP]=               CF_ALLOW_PROTOCOL_PLUGIN;
sql/sql_parse.cc:1857:  case COM_SLEEP:
sql/sql_parse.cc:1900:  thd->set_command(COM_SLEEP);
sql/sql_audit.cc:746:        command == COM_SLEEP || /* Deprecated commands from here. */
sql/srv_session.cc:920:  thd.set_command(COM_SLEEP);
openxs@ao756:~/git/mysql-server$

(this is from current 8.0 code)

It would be nice to explain when exactly it is used and why one may find entries like these:

SET timestamp=1473712798;
# administrator command: Sleep;
# Time: 160912 20:39:59
# User@Host: user[host] @ [192.168.1.51]
# Thread_id: 36310042 Schema: somedb QC_hit: No
# Query_time: 17.201526 Lock_time: 0.000000 Rows_sent: 0 Rows_examined: 0

in the slow log.

How to repeat:
Try to explain what does this entry mean in the slow query log:

SET timestamp=1473712798;
# administrator command: Sleep;
# Time: 160912 20:39:59
# User@Host: user[host] @ [192.168.1.51]
# Thread_id: 36310042 Schema: somedb QC_hit: No
# Query_time: 17.201526 Lock_time: 0.000000 Rows_sent: 0 Rows_examined: 0

Why Sleep took time, was it a problem, why this was logged as slow query etc

Suggested fix:
Document all cases of COM-SLEEP use in the server code in internal manual.

Explain in the manual for slow query log what entries like this:

SET timestamp=1473712798;
# administrator command: Sleep;
# Time: 160912 20:39:59
# User@Host: user[host] @ [192.168.1.51]
# Thread_id: 36310042 Schema: somedb QC_hit: No
# Query_time: 17.201526 Lock_time: 0.000000 Rows_sent: 0 Rows_examined: 0

mean.
[16 Sep 2016 20:19] MySQL Verification Team
Thank you for the bug report.
[5 Jul 2017 17:12] Stefan Hinz
Posted by developer:
 
No more updates are made to the MySQL Internals documentation, because it's in the process of being replaced by https://dev.mysql.com/doc/dev/mysql-server/latest/.