IP: 0.0.0.0 PORT: 50603 STATE: ACTIVE 

Socket instruments have names of the form wait/io/socket/sql/ socket_type  and are used like this: 

1. The server has a listening socket for each network protocol that it supports. The instruments associated with listening sockets for TCP/IP or Unix socket file connections have a socket_type  value of server_tcpip_socket  or server_unix_socket , respectively. 

2. When a listening socket detects a connection, the server transfers the connection to a new socket managed by a separate thread. The instrument for the new connection thread has a socket_type value of client_connection . 

3. When a connection terminates, the row in socket_instances  corresponding to it is deleted. 

The socket_instances  table has these columns: 

• EVENT_NAME 

The name of the wait/io/socket/*  instrument that produced the event. This is a NAME  value from the setup_instruments  table. Instrument names may have multiple parts and form a hierarchy, as discussed in Section 27.6, “Performance Schema Instrument Naming Conventions” . 

• OBJECT_INSTANCE_BEGIN 

This column uniquely identifies the socket. The value is the address of an object in memory. 

• THREAD_ID 

The internal thread identifier assigned by the server. Each socket is managed by a single thread, so each socket can be mapped to a thread which can be mapped to a server process. 

• SOCKET_ID 

The internal file handle assigned to the socket. 

• IP 

The client IP address. The value may be either an IPv4 or IPv6 address, or blank to indicate a Unix socket file connection. 

• PORT 

The TCP/IP port number, in the range from 0 to 65535. 

• STATE 

The socket status, either IDLE  or ACTIVE . Wait times for active sockets are tracked using the corresponding socket instrument. Wait times for idle sockets are tracked using the idle  instrument. 

A socket is idle if it is waiting for a request from the client. When a socket becomes idle, the event row in socket_instances  that is tracking the socket switches from a status of ACTIVE  to IDLE . The EVENT_NAME  value remains wait/io/socket/* , but timing for the instrument is suspended. Instead, an event is generated in the events_waits_current  table with an EVENT_NAME  value of idle . 

When the next request is received, the idle  event terminates, the socket instance switches from IDLE to ACTIVE , and timing of the socket instrument resumes. 

