Bug #97600 Perfschema socket stats are not captured for SSL connections
Submitted: 12 Nov 20:05 Modified: 26 Nov 3:43
Reporter: Herman Lee Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Performance Schema Severity:S3 (Non-critical)
Version:8.0.17 OS:Any
Assigned to: Marc Alff CPU Architecture:Any

[12 Nov 20:05] Herman Lee
Description:
Performance schema tables such as socket_summary_by_event_name does not report correct stats for SSL connections. It looks like the SSL read/write paths are not instrumented with performance schema calls.

For example: vio_ssl_write in vio/viossl.cc (https://github.com/mysql/mysql-server/blob/8.0/vio/viossl.cc#L311) vs. vio_write in vio/viosocket.cc (https://github.com/mysql/mysql-server/blob/8.0/vio/viosocket.cc#L218).

The call in vio_write() calls into mysql_socket_send() which has instrumented perfschema code. The call in vio_ssl_write() calls into SSL_write() directly, without any perfschema instrumentation.

How to repeat:
Start mysqld:

Connection 1:

mysql --no-defaults -P 13000 -h 127.0.0.1 -u root --ssl-mode=DISABLED test

CREATE TABLE t (a int, primary key (a)) ENGINE=INNODB;
INSERT INTO t values (1), (2), (3);

SELECT EVENT_NAME, SUM_NUMBER_OF_BYTES_WRITE, COUNT_WRITE FROM performance_schema.socket_summary_by_event_name;

SELECT * FROM t;

SELECT EVENT_NAME, SUM_NUMBER_OF_BYTES_WRITE, COUNT_WRITE FROM performance_schema.socket_summary_by_event_name; /* Note values incremented */

Connection 2:

mysql --no-defaults -P 13000 -h 127.0.0.1 -u root --ssl-mode=REQUIRED test

SELECT EVENT_NAME, SUM_NUMBER_OF_BYTES_WRITE, COUNT_WRITE FROM performance_schema.socket_summary_by_event_name;

SELECT * FROM t;

SELECT EVENT_NAME, SUM_NUMBER_OF_BYTES_WRITE, COUNT_WRITE FROM performance_schema.socket_summary_by_event_name; /* Note values are not incremented */
[13 Nov 6:28] Umesh Shastry
Hello Herman Lee,

Thank you for the report and test case.
Verified as described with 8.0.18 build.

regards,
Umesh
[13 Nov 16:18] Marc Alff
Performance schema instrumentation is missing for SSL,
related to:
Bug#93896 PFS.socket_summary_* tables not updated for SSL connections
[26 Nov 3:43] Paul Dubois
Posted by developer:
 
Fixed in 8.0.19.

For connections encrypted with OpenSSL, network I/O at the socket
level was not reported by the Performance Schema. Also, network I/O
performed while the server was in an IDLE state was not reported by
the Performance Schema.