Bug #82761 If binding to mysqlx port fails this is not visible from status vars
Submitted: 28 Aug 2016 12:46 Modified: 24 Jan 2017 12:05
Reporter: Daniël van Eeden (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Document Store: X Plugin Severity:S3 (Non-critical)
Version:5.7.14 OS:Any
Assigned to: CPU Architecture:Any

[28 Aug 2016 12:46] Daniël van Eeden
Description:
Related:
Bug #82759 	--dba enableXProtocol should do more error checking

When mysqlx plugin fails to bind to @@global.mysqlx_port it does not indicate this failure in the global status variables.

How to repeat:
From error log:
====================================================================
2016-08-28T12:15:18.608425Z 4 [Note] Plugin mysqlx reported: 'X plugin tcp connection enable at port 33060.'
2016-08-28T12:15:18.608487Z 4 [ERROR] Plugin mysqlx reported: 'Could not bind to port 33060: Address already in use (98)'
2016-08-28T12:15:18.608585Z 4 [Note] Plugin mysqlx reported: 'Scheduler "work" started.'
2016-08-28T12:15:18.608624Z 4 [Note] Plugin mysqlx reported: 'X plugin initialization successes'
2016-08-28T12:15:18.610336Z 0 [Warning] Plugin mysqlx reported: 'Failed at SSL configuration: "SSL context is not usable without certificate and private key"'
2016-08-28T12:15:18.610347Z 0 [Note] Plugin mysqlx reported: 'Using YaSSL for TCP connections'
2016-08-28T12:15:18.610350Z 0 [ERROR] Plugin mysqlx reported: 'Tcp socket creation or bind failed'
2016-08-28T12:15:18.610383Z 0 [ERROR] Plugin mysqlx reported: 'Error preparing to accept connections'
2016-08-28T12:15:18.610388Z 0 [ERROR] Plugin mysqlx reported: 'Delayed startup failed. Plugin is unable to accept connections.'
====================================================================

mysql [localhost] {msandbox} ((none)) > SELECT * FROM performance_schema.global_status WHERE variable_name LIKE 'mysqlx%';
+-------------------------------------+----------------+
| VARIABLE_NAME                       | VARIABLE_VALUE |
+-------------------------------------+----------------+
| Mysqlx_bytes_received               | 0              |
| Mysqlx_bytes_sent                   | 0              |
| Mysqlx_connection_accept_errors     | 0              |
| Mysqlx_connection_errors            | 0              |
| Mysqlx_connections_accepted         | 0              |
| Mysqlx_connections_closed           | 0              |
| Mysqlx_connections_rejected         | 0              |
| Mysqlx_crud_delete                  | 0              |
| Mysqlx_crud_find                    | 0              |
| Mysqlx_crud_insert                  | 0              |
| Mysqlx_crud_update                  | 0              |
| Mysqlx_errors_sent                  | 0              |
| Mysqlx_expect_close                 | 0              |
| Mysqlx_expect_open                  | 0              |
| Mysqlx_init_error                   | 0              |
| Mysqlx_notice_other_sent            | 0              |
| Mysqlx_notice_warning_sent          | 0              |
| Mysqlx_rows_sent                    | 0              |
| Mysqlx_sessions                     | 0              |
| Mysqlx_sessions_accepted            | 0              |
| Mysqlx_sessions_closed              | 0              |
| Mysqlx_sessions_fatal_error         | 0              |
| Mysqlx_sessions_killed              | 0              |
| Mysqlx_sessions_rejected            | 0              |
| Mysqlx_ssl_accepts                  | 0              |
| Mysqlx_ssl_active                   |                |
| Mysqlx_ssl_cipher                   |                |
| Mysqlx_ssl_cipher_list              |                |
| Mysqlx_ssl_ctx_verify_depth         | 0              |
| Mysqlx_ssl_ctx_verify_mode          | 0              |
| Mysqlx_ssl_finished_accepts         | 0              |
| Mysqlx_ssl_server_not_after         |                |
| Mysqlx_ssl_server_not_before        |                |
| Mysqlx_ssl_verify_depth             |                |
| Mysqlx_ssl_verify_mode              |                |
| Mysqlx_ssl_version                  |                |
| Mysqlx_stmt_create_collection       | 0              |
| Mysqlx_stmt_create_collection_index | 0              |
| Mysqlx_stmt_disable_notices         | 0              |
| Mysqlx_stmt_drop_collection         | 0              |
| Mysqlx_stmt_drop_collection_index   | 0              |
| Mysqlx_stmt_enable_notices          | 0              |
| Mysqlx_stmt_ensure_collection       | 0              |
| Mysqlx_stmt_execute_mysqlx          | 0              |
| Mysqlx_stmt_execute_sql             | 0              |
| Mysqlx_stmt_execute_xplugin         | 0              |
| Mysqlx_stmt_kill_client             | 0              |
| Mysqlx_stmt_list_clients            | 0              |
| Mysqlx_stmt_list_notices            | 0              |
| Mysqlx_stmt_list_objects            | 0              |
| Mysqlx_stmt_ping                    | 0              |
| Mysqlx_worker_threads               | 2              |
| Mysqlx_worker_threads_active        | 0              |
+-------------------------------------+----------------+
53 rows in set (0.00 sec)

mysql [localhost] {msandbox} ((none)) > SELECT * FROM performance_schema.global_variables WHERE variable_name LIKE 'mysqlx%';
+-----------------------------------+----------------+
| VARIABLE_NAME                     | VARIABLE_VALUE |
+-----------------------------------+----------------+
| mysqlx_connect_timeout            | 30             |
| mysqlx_idle_worker_thread_timeout | 60             |
| mysqlx_max_allowed_packet         | 1048576        |
| mysqlx_max_connections            | 100            |
| mysqlx_min_worker_threads         | 2              |
| mysqlx_port                       | 33060          |
| mysqlx_ssl_ca                     |                |
| mysqlx_ssl_capath                 |                |
| mysqlx_ssl_cert                   |                |
| mysqlx_ssl_cipher                 |                |
| mysqlx_ssl_crl                    |                |
| mysqlx_ssl_crlpath                |                |
| mysqlx_ssl_key                    |                |
+-----------------------------------+----------------+
13 rows in set (0.01 sec)

Suggested fix:
Set Mysqlx_init_error to >= 1 if binding to the mysqlx port fails.

SELECT VARIABLE_VALUE FROM performance_schema.global_status WHERE variable_name='Mysqlx_init_error';

Or return a failure when loading the plugin if this happens.

SELECT COUNT(*) FROM information_schema.plugins WHERE plugin_name='mysqlx' AND plugin_status='ACTIVE';

Or create a mysqlx_accepting_connections status variable..
[28 Aug 2016 18:47] MySQL Verification Team
Hello Daniël,

Thank you for the report.

Thanks,
Umesh
[15 Sep 2016 8:46] Simon Mudd
There's also a MySQL X protocol unix socket and the same applies.
If this binding is not successful how do you know?

root@localhost [(none)]> select @@version, @@mysqlx_socket;
+---------------+-------------------+
| @@version     | @@mysqlx_socket   |
+---------------+-------------------+
| 8.0.0-dmr-log | /tmp/mysqlx8.sock |
+---------------+-------------------+
1 row in set (0.00 sec)
[24 Jan 2017 12:05] Tony Bedford
Posted by developer:
 
An entry has been added to the 5.7.17 changelog:

When X Plugin failed to bind to @@global.mysqlx_port it did not indicate this failure in the global status variables.